示例#1
0
 public HeightMap createMirrorY()
 {
     HeightMap map = new HeightMap();
     ushort[] backmap = createReverseYMap(heightMap, pow2);
     map.setBackend(backmap, pow2, rangeMin, rangeMax);
     return map;
 }
示例#2
0
        public MyGrassPatch(HeightMap heightMap, int size)
        {
            MyGrassPatch.width = size;
            MyGrassPatch.length = size;
            this.heightMap = heightMap;
            System.Random rSeed = new Random();

            //triangleCount = length * width * bladeBySquare * bladeBySquare * nbSegment * 2 * 4 * 2;
            triangleCount = length * width * bladeBySquare * bladeBySquare * nbSegment * 4;

            vertices = new DataStream((12+8) * triangleCount * 3, true, true);
            for (int i = 0; i < width;i++)
                for (int j = 0; j < length; j++)
                {
                    for (int xb = 0;xb < bladeBySquare;xb++)
                        for (int yb = 0; yb < bladeBySquare; yb++)
                        {
                            float x = i + xb * 1f / bladeBySquare + ((float)rSeed.NextDouble()-0.5f) * 0.2f;
                            float z = j + yb * 1f / bladeBySquare + ((float)rSeed.NextDouble() - 0.5f) * 0.2f;
                            //float x = i + xb * 1f / bladeBySquare;
                            //float z = j + yb * 1f / bladeBySquare;
                            addBlade(x, heightMap.getHeight(x, z), z, 1.0f + (float)rSeed.NextDouble() * 0.2f, (float)(rSeed.NextDouble()*Math.PI));
                        }
                }
            vertices.Position = 0;
        }
示例#3
0
        public MyTerrain(HeightMap heightMap,int size)
        {
            MyTerrain.width = size;
            MyTerrain.length = size;
            this.heightMap = heightMap;

            vertices = new DataStream((12+8) * triangleCount * 3, true, true);
            for (int i = 0; i < width;i++)
                for (int j = 0; j < length; j++)
                {
                    float height;
                    height = heightMap.getHeight((float)i, (float)j);
                    vertices.Write(new Vector3(0.0f + i, height, 0.0f + j));
                    vertices.Write(new Vector2(0.0f, 0.0f));
                    height = heightMap.getHeight((float)i, (float)j+1f);
                    vertices.Write(new Vector3(0.0f + i, height, 1.0f + j));
                    vertices.Write(new Vector2(0.0f, 0.0f));
                    height = heightMap.getHeight((float)i+1, (float)j);
                    vertices.Write(new Vector3(1.0f + i, height, 0.0f + j));
                    vertices.Write(new Vector2(0.0f, 0.0f));
                    height = heightMap.getHeight((float)i, (float)j + 1);
                    vertices.Write(new Vector3(0.0f + i, height, 1.0f + j));
                    vertices.Write(new Vector2(0.0f, 0.0f));
                    height = heightMap.getHeight((float)i + 1, (float)j + 1);
                    vertices.Write(new Vector3(1.0f + i, height, 1.0f + j));
                    vertices.Write(new Vector2(0.0f, 0.0f));
                    height = heightMap.getHeight((float)i + 1, (float)j);
                    vertices.Write(new Vector3(1.0f + i, height, 0.0f + j));
                    vertices.Write(new Vector2(0.0f, 0.0f));

                }
            vertices.Position = 0;
        }
示例#4
0
 public static HeightMap generateHeightMap(int pow2, float rangeMin, float rangeMax)
 {
     PerlinNoise2D noise = new PerlinNoise2D();
     ushort[] heightMap = noise.createMap(6);
     HeightMap map = new HeightMap();
     map.setBackend(heightMap, pow2, rangeMin, rangeMax);
     return map;
 }