Exemplo n.º 1
0
        public override _16x256x16VoxChunk GenerateVoxChunk(int uniqueID)
        {
            int[] position = _16x256x16VoxChunk.DefaultDecoderFromUniqueID2StPosition(uniqueID);
            offset = new Vector2(position[0], position[1]);
            GenNodes();

            byte[]             data  = new byte[_16x256x16VoxChunk.Count];
            _16x256x16VoxChunk chunk = new _16x256x16VoxChunk(uniqueID, data);

            for (int x = 0; x < _16x256x16VoxChunk.Width; x++)
            {
                for (int z = 0; z < _16x256x16VoxChunk.Length; z++)
                {
                    TNode node   = nodes[x, z];
                    int   height = (int)node.elevation;
                    byte  type   = (byte)(node.ttype);

                    for (int y = 0; y < height; y++)
                    {
                        chunk.SetVoxel(x, y, z, type);
                    }
                }
            }

            return(chunk);
        }
Exemplo n.º 2
0
        // 删除指定位置的Voxel
        public void DeleteVoxel()
        {
            if (selectChunk == null)
            {
                return;
            }

            int[] local = new int[] { 0, 0, 0 };
            local[0] = (int)(selectVoxelPosition.x) % _16x256x16VoxChunk.Width;
            local[1] = (int)(selectVoxelPosition.y) % _16x256x16VoxChunk.Height;
            local[2] = (int)(selectVoxelPosition.z) % _16x256x16VoxChunk.Length;

            selectChunk.SetVoxel(local[0], local[1], local[2], _16x256x16VoxChunk.EmptyType);

            // 更新该chunk的MeshObj
            UpdateChunk(selectChunk);
        }
Exemplo n.º 3
0
        public override _16x256x16VoxChunk GenerateVoxChunk(int uniqueID)
        {
            byte[]             voxData = new byte[_16x256x16VoxChunk.Count];
            _16x256x16VoxChunk result  = new _16x256x16VoxChunk(uniqueID, voxData);

            offset = _16x256x16VoxChunk.DefaultDecoderFromUniqueID2StPosition(uniqueID);

            for (int lx = 0; lx < _16x256x16VoxChunk.Width; lx++)
            {
                for (int lz = 0; lz < _16x256x16VoxChunk.Length; lz++)
                {
                    int groundHeight     = GenBaseGround(lx, lz);
                    int SnowLayerHeight  = GenSnowLayer(lx, lz);
                    int GlassLayerHeight = GenGlassLayer(lx, lz);

                    for (int h = 0; h < groundHeight; h++)
                    {
                        result.SetVoxel(lx, h, lz, (byte)VoxelType.Ground);
                    }

                    int snowSubGround = SnowLayerHeight - groundHeight;
                    if (snowSubGround > 0 && snowSubGround < snowDepth)
                    {
                        for (int h = SnowLayerHeight; h >= groundHeight; h--)
                        {
                            result.SetVoxel(lx, h, lz, (byte)VoxelType.Snow);
                        }
                    }

                    int glassSubGround = GlassLayerHeight - groundHeight;
                    if (glassSubGround > 0 && glassSubGround < glassDepth)
                    {
                        for (int h = glassSubGround; h >= groundHeight; h--)
                        {
                            result.SetVoxel(lx, h, lz, (byte)VoxelType.Glass);
                        }
                    }
                }
            }

            return(result);
        }
        public override _16x256x16VoxChunk GenerateVoxChunk(int uniqueID)
        {
            byte[]             voxData = new byte[_16x256x16VoxChunk.Count];
            _16x256x16VoxChunk res     = new _16x256x16VoxChunk(uniqueID, voxData);

            for (int x = 0; x < _16x256x16VoxChunk.Width; x++)
            {
                for (int z = 0; z < _16x256x16VoxChunk.Length; z++)
                {
                    int plainHeight = (int)(PlainSample(uniqueID, x, z) + 0.5f);

                    for (int y = 0; y < plainHeight; y++)
                    {
                        res.SetVoxel(x, y, z, 0x02);
                    }
                }
            }
            return(res);
        }