My Project
TerrainFilters.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
5  class TTerrain;
6 
7 
13  {
14  public:
15  CTerrainFilters(void);
16  ~CTerrainFilters(void);
17 
20  Addition=0,
21  Subtract,
22  Multiplication,
23  Division,
24  Minimum,
25  Maximum
26  };
34  };
35  public:
39 
49  void Flatten (FlattenOperation flatten_op, float elevation,float factor, float center_x, float center_y, float radius);
58  void RadialScale (float center_x, float center_y, float scale_factor, float min_dist,float max_dist, float smooth_factor, int frequency);
59 
60  /*
61  * This creates a Gaussian hill at the specified location with the specified parameters.
62  * it actually adds the hill to the original terrain surface.
63  * Here ElevNew(x,y) =
64  |(x,y)-(center_x,center_y)| < radius*smooth_factor, ElevOld(x,y)+hscale*exp(-[(x-center_x)^2+(y-center_y)^2]/(2*standard_deviation^2) ),
65  |(x,y)-(center_x,center_y)| > radius*smooth_factor, minimize hill effect.
66  * @param center_x: the center of the affected circle. value in the range [0,1]
67  * @param center_y: the center of the affected circle.value in the range [0,1]
68  * @param radius: the radius of the affected circle.value in the range [0,0.5]
69  * @param hscale: scale factor. One can think of it as the maximum height of the Gaussian Hill. this value can be negative
70  * @param standard_deviation: standard deviation of the unit height value. should be in the range (0,1).
71  * 0.1 is common value. larger than that will just make a flat hill with smoothing.
72  * @param smooth_factor: value is between [0,1]. 1 means fully transformed; 0 means nothing is changed
73  */
74  void GaussianHill (float x,float y,float radius,float hscale,float standard_deviation,float smooth_factor);
75 
79  void Spherical ( float offset);
80  /*
81  * return the sum of the neighboring cells in a square size with
82  * sides 1+(size*2) long
83  */
84  static float grid_neighbour_sum_size(TTerrain*terrain,int x, int y,int size);
85  /*
86  * return the average of the neighboring cells in a square size with
87  * sides 1+(size*2) long
88  */
89  static float grid_neighbour_average_size(TTerrain*terrain,
90  int x,
91  int y,
92  int size);
104  void Roughen_Smooth (bool roughen, bool big_grid,float factor);
105 
112  void Ramp(float x1, float y1, float height1, float x2, float y2, float height2, float radius, float borderpercentage=0.5f, float factor=1.0f);
113 
125  void SetConstEdgeHeight(float fHeight=0, int nSmoothPixels=7);
126 
131  void Merge (TTerrain *terrain_1,
132  TTerrain *terrain_2,
133  float weight_1,
134  float weight_2,
135  MergeOperation operation);
136 
137  private:
139  TTerrain* m_pTerrainData;
140  };
141 }
void Flatten(FlattenOperation flatten_op, float elevation, float factor, float center_x, float center_y, float radius)
Flatten the terrain both up and down to the specified elevation, using using the tightness parameter ...
Definition: TerrainFilters.cpp:72
temp height field terrain data used by terrain filters.
Definition: TTerrain.h:16
void Roughen_Smooth(bool roughen, bool big_grid, float factor)
square filter for sharpening and smoothing.
Definition: TerrainFilters.cpp:467
different physics engine has different winding order.
Definition: EventBinding.h:32
TTerrain * GetTerrainData()
get the terrain data that is associated with this filter.
Definition: TerrainFilters.cpp:67
void SetConstEdgeHeight(float fHeight=0, int nSmoothPixels=7)
load height field from file
Definition: TerrainFilters.cpp:598
void RadialScale(float center_x, float center_y, float scale_factor, float min_dist, float max_dist, float smooth_factor, int frequency)
Note: terrain data should be in normalized space with height in the range [0,1].
Definition: TerrainFilters.cpp:152
void Ramp(float x1, float y1, float height1, float x2, float y2, float height2, float radius, float borderpercentage=0.5f, float factor=1.0f)
create a ramp (inclined slope) from height(x1,y1) to height(x2,y2).
Definition: TerrainFilters.cpp:632
void Merge(TTerrain *terrain_1, TTerrain *terrain_2, float weight_1, float weight_2, MergeOperation operation)
merge two terrains, and save the result to the current terrain.
Definition: TerrainFilters.cpp:502
void Spherical(float offset)
offset in a spherical region
Definition: TerrainFilters.cpp:353
Flatten the terrain up and down to the specified elevation.
Definition: TerrainFilters.h:33
Flatten the terrain down to the specified elevation.
Definition: TerrainFilters.h:31
Perform filtering on a terrain height field.
Definition: TerrainFilters.h:12
Flatten the terrain up to the specified elevation.
Definition: TerrainFilters.h:29
FlattenOperation
Definition: TerrainFilters.h:27
MergeOperation
used in the merge function
Definition: TerrainFilters.h:19