Esempio n. 1
0
 public int this[int x, int y, int z]
 {
     get
     {
         // Console.WriteLine(string.Format("{0} {1} {2} {3}", x / CHUNK_SIZE, y / CHUNK_SIZE, z / CHUNK_SIZE,this.chunks.GetLength(2)));
         // Console.WriteLine(string.Format("{0} {1} {2} {3}",x % CHUNK_SIZE, y % CHUNK_SIZE, z % CHUNK_SIZE,this.chunks.GetLength(2)));
         if (x < 0 || y < 0 || z < 0 || x >= worldWidth || y >= worldHeight || z >= worldLength)
         {
             return((int)VoxelTypes.Air);
         }
         ChunkStruct c = this.chunks[x / CHUNK_SIZE, y / CHUNK_SIZE, z / CHUNK_SIZE];
         // if(c.chunkData.Length ==1){
         //     // if(!c.uncompressVoxData()){
         //     //     return 0;
         //     // }
         //     c.uncompressVoxData();
         //     // c.currentlyWorked = true;
         //     // c.chunkData = SnappyCodec.Uncompress(c.compChunkData);
         //     // c.chunkData = new byte[1];
         //     // return c[x % CHUNK_SIZE, y % CHUNK_SIZE, z % CHUNK_SIZE];
         //     // return 0;
         // }
         return(c[x % CHUNK_SIZE, y % CHUNK_SIZE, z % CHUNK_SIZE]);
     }
     set
     {
         this.chunks[x / CHUNK_SIZE, y / CHUNK_SIZE, z / CHUNK_SIZE][x % CHUNK_SIZE, y % CHUNK_SIZE, z % CHUNK_SIZE] = (byte)value;
     }
 }
Esempio n. 2
0
 private void setChunkValues(ChunkStruct chunk)
 {
     for (int x = 0; x < CHUNK_SIZE; x++)
     {
         for (int y = 0; y < CHUNK_SIZE; y++)
         {
             for (int z = 0; z < CHUNK_SIZE; z++)
             {
                 chunk[x, y, z] = (byte)VoxelTypes.Default;
             }
         }
     }
 }
Esempio n. 3
0
        bool IVoxelDataPopulate.InitializeVoxelData(ChunkStruct[,,] chunkList)
        {
            Console.WriteLine("Curr Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId + " Total MEM Usage: " + GC.GetTotalMemory(true));
            for (int i = 0; i < CHUNK_X_COUNT; i++)
            {
                for (int j = 0; j < CHUNK_Y_COUNT; j++)
                {
                    for (int k = 0; k < CHUNK_Z_COUNT; k++)
                    {
                        chunkList[i, j, k] = new ChunkStruct(CHUNK_SIZE, VOX_SIZE, i, j, k);
                        setChunkValues(chunkList[i, j, k]);
                        chunkList[i, j, k].compChunkData = Snappy.SnappyCodec.Compress(chunkList[i, j, k].chunkData);
                        chunkList[i, j, k].chunkData     = new byte[1];
                    }
                }
            }

            Console.WriteLine("Curr Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId + " Total MEM Usage: " + GC.GetTotalMemory(true));
            return(true);
        }
Esempio n. 4
0
 private void setChunkValues(ChunkStruct chunk)
 {
     for (int x = 0; x < CHUNK_SIZE; x++)
     {
         for (int z = 0; z < CHUNK_SIZE; z++)
         {
             //Console.WriteLine(string.Format("DX: {0}, DZ: {1}",chunk.Dx+x,chunk.Dz+z));
             int height = (int)Mathf.Lerp(1, CHUNK_SIZE * CHUNK_Y_COUNT, noise.GetNoise(chunk.Dx * CHUNK_SIZE + x, chunk.Dz * CHUNK_SIZE + z));
             if (height <= 1)
             {
                 height = 1;
             }
             // int height = (int)Mathf.Lerp(1, CHUNK_SIZE*CHUNK_Y_COUNT, 0.25f);
             for (int y = 0; y < CHUNK_SIZE; y++)
             {
                 if ((chunk.Dy * CHUNK_SIZE + y) < height)
                 {
                     chunk[x, y, z] = 1;
                 }
             }
         }
     }
 }
Esempio n. 5
0
        public bool InitializeVoxelData(ChunkStruct[,,] chunkList)
        {
            noise = new FastNoise(1337);
            noise.SetNoiseType(FastNoise.NoiseType.CubicFractal);
            Console.WriteLine("Curr Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId + " Total MEM Usage: " + GC.GetTotalMemory(true));
            for (int i = 0; i < CHUNK_X_COUNT; i++)
            {
                for (int j = 0; j < CHUNK_Y_COUNT; j++)
                {
                    for (int k = 0; k < CHUNK_Z_COUNT; k++)
                    {
                        chunkList[i, j, k] = new ChunkStruct(CHUNK_SIZE, VOX_SIZE, i, j, k);
                        setChunkValues(chunkList[i, j, k]);
                        // chunkList[i, j, k].compressVoxData();
                        // chunkList[i, j, k].compChunkData = Snappy.SnappyCodec.Compress(chunkList[i, j, k].chunkData);
                        // chunkList[i, j, k].chunkData = new byte[1];
                    }
                }
            }

            Console.WriteLine("Curr Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId + " Total MEM Usage: " + GC.GetTotalMemory(true));
            return(true);
        }