public Mesh GenLodCell(WorldChunk <sbyte> chunk)
        {
            Mesh mesh = new Mesh();
            int  lod  = 1;

            for (int x = 0; x < volume.ChunkSize; x++)
            {
                for (int y = 0; y < volume.ChunkSize; y++)
                {
                    for (int z = 0; z < volume.ChunkSize; z++)
                    {
                        Vector3i position;                         //new Vector3i(x, y, z);
                        position.X = x;
                        position.Y = y;
                        position.Z = z;
                        PolygonizeCell(chunk.GetPosition(), position, ref mesh, lod);
                    }
                }
            }

            return(mesh);
        }
        public Mesh GenLodCell(WorldChunk<sbyte> chunk)
        {
            Mesh mesh = new Mesh();
            int lod = 1;

            for (int x = 0; x < volume.ChunkSize; x++)
            {
                for (int y = 0; y < volume.ChunkSize; y++)
                {
                    for (int z = 0; z < volume.ChunkSize; z++)
                    {
                        Vector3i position; //new Vector3i(x, y, z);
                        position.X = x;
                        position.Y = y;
                        position.Z = z;
                        PolygonizeCell(chunk.GetPosition(), position, ref mesh, lod);
                    }
                }
            }

            return mesh;
        }
        public void ExtractMesh(WorldChunk<sbyte> wc)
        {
            int lod = 1;
            Vector3i position = wc.GetPosition();
            Vector3 posXna = position.ToVector3();

            //Logger.GetLogger().Log(null, "" + dst);

            var m = _surfaceExtractor.GenLodCell(wc);
            var v = Converters.ConvertMeshToXna(m, LodColors[0]);
            var i = m.GetIndices();

            var chunk = new Chunk
            {
                BoundingBox = new BoundingBox(posXna, posXna + new Vector3(wc.Size(), wc.Size(), wc.Size())),
                Position = posXna,
                Lod = lod
            };

            if (i.Length > 0 && v.Length > 0)
            {
                chunk.VertexBuffer = new VertexBuffer(_gd, typeof(VertexPositionTextureNormalColor), v.Length, BufferUsage.WriteOnly);
                chunk.VertexBuffer.SetData(v);
                chunk.IndexBuffer = new IndexBuffer(_gd, IndexElementSize.SixteenBits, i.Length, BufferUsage.WriteOnly);
                chunk.IndexBuffer.SetData(i);

                Console.WriteLine("Chunk has : " + v.Length + " Vertices " + i.Length + " Indices");

                if (_chunks.ContainsKey(posXna))
                {
                    Chunk removed;
                    _chunks.TryRemove(posXna, out removed);
                }
                _chunks.TryAdd(posXna, chunk);
            }
        }
        public void ExtractMesh(WorldChunk <sbyte> wc)
        {
            int      lod      = 1;
            Vector3i position = wc.GetPosition();
            Vector3  posXna   = position.ToVector3();

            //Logger.GetLogger().Log(null, "" + dst);

            var m = _surfaceExtractor.GenLodCell(wc);
            var v = Converters.ConvertMeshToXna(m, LodColors[0]);
            var i = m.GetIndices();

            var chunk = new Chunk
            {
                BoundingBox = new BoundingBox(posXna, posXna + new Vector3(wc.Size(), wc.Size(), wc.Size())),
                Position    = posXna,
                Lod         = lod
            };

            if (i.Length > 0 && v.Length > 0)
            {
                chunk.VertexBuffer = new VertexBuffer(_gd, typeof(VertexPositionTextureNormalColor), v.Length, BufferUsage.WriteOnly);
                chunk.VertexBuffer.SetData(v);
                chunk.IndexBuffer = new IndexBuffer(_gd, IndexElementSize.SixteenBits, i.Length, BufferUsage.WriteOnly);
                chunk.IndexBuffer.SetData(i);

                Console.WriteLine("Chunk has : " + v.Length + " Vertices " + i.Length + " Indices");

                if (_chunks.ContainsKey(posXna))
                {
                    Chunk removed;
                    _chunks.TryRemove(posXna, out removed);
                }
                _chunks.TryAdd(posXna, chunk);
            }
        }