Example #1
0
 /** sets the height of a terrain area according to an array of heights.
  *  clip:true, only set the heights within a terrainArea, even if the array is bigger<br>
  *	clip:false, if the supplied array is bigger than the texture area, change heights outside of the area also
  */
 public void setHeights(terrainArea area, float[,] heights, bool clip)
 {
     echo(3, "SetHeights(terrainArea) called ");
     if (clip && (heights.GetLength(0) > area.sizeX || heights.GetLength(1) > area.sizeZ))
     {
         Transmute2d(area.getArray(), heights);
         terdata.SetHeights(area.x, area.z, area.getArray());
     }
     else
     {
         terdata.SetHeights(area.x, area.z, heights);
     }
 }
Example #2
0
 /// randomly deforms a terrain area, using perlin noise.
 public void randomizeArea(float minheight, float maxheight, terrainArea area, float smoothness)
 {
     echo(3, "randomizeArea() called ");
     smoothness   = (0.9888f / smoothness);
     float[,] arr = area.getArray();
     for (int i = 0; i <= area.sizeX; i++)
     {
         for (int j = 0; j <= area.sizeZ; j++)
         {
             arr[i, j] = ((maxheight - minheight) * (Mathf.PerlinNoise((area.x + i + randomSeed) * smoothness, (area.z + j + randomSeed) * smoothness))) + minheight;
         }
     }
     terdata.SetHeights(area.x, area.z, arr);
 }
Example #3
0
 ///sets the height of a terrain area to a global world(Y-axis) height.
 public void setHeightW(terrainArea area, float worldHeight)
 {
     echo(3, "setHeightW(terrainArea) called ");
     Populate2d(area.getArray(), worldToTerrainSpace(new Vector3(0, worldHeight, 0)).y);
     terdata.SetHeights(area.x, area.z, area.getArray());
 }
Example #4
0
 /** sets the height of a terrain area.
  *  So long as (0.0f <= height >= 1.0f)
  */
 public void setHeight(terrainArea area, float height)
 {
     echo(3, "setHeight(terrainArea) called ");
     Populate2d(area.getArray(), height);
     terdata.SetHeights(area.x, area.z, area.getArray());
 }