예제 #1
0
        public VoxelMap()
        {
            map = new byte[size,size,size];

            Vector3f min = new Vector3f(size/2, size/2, size/2);
            Vector3f max = new Vector3f(size, size, size);
            float length = (max - min).Length;

            //setBox(new Vector3i(15, 5, 5), new Vector3i(10, 10, 10), (byte)-100);
            //setBox(new Vector3i(19, 9, 9), new Vector3i(10, 10, 10), -100);

            //setBox(new Vector3i(0, 0, 0), new Vector3i(size, 20, size), 100);

            Random rnd = new Random();
            PerlinNoise perlin = new PerlinNoise(rnd.Next());

            for(int x=5;x<size-5;x++)
                for(int y=5;y<size-5;y++)
                    for (int z = 5; z < size-5; z++)
                    {
                        float div = 128.0f;

                        double val = SimplexNoise.noise(x/div,y/div,z/div);
              		                val *= 1 << 7;
                        map[x, y, z] = (byte)(val);
                    }

            /*for (int x = 1; x < size; x++)
                for (int z = 1; z < size; z++)
                {
                    float div = 128.0f;
                    double val = SimplexNoise.noise(x / div, z / div);

                    double grenze = val*100.0;
                    int y = 1;
                    for (; y < grenze; y++)
                    {
                        map[x, y, z] = (sbyte)(-120);
                    }
                }*/
        }