예제 #1
0
        public OCBlockData GetBlock(int x, int y, int z)
        {
            OCChunk chunk = null;

            if (_lastRequestedChunk != null)
            {
                Vector3i requestedChunkPosition = OCChunk.ToChunkPosition(x, y, z);
                if (requestedChunkPosition.x == _lastRequestedChunk.GetPosition().x)
                {
                    if (requestedChunkPosition.y == _lastRequestedChunk.GetPosition().y)
                    {
                        if (requestedChunkPosition.z == _lastRequestedChunk.GetPosition().z)
                        {
                            chunk = _lastRequestedChunk;
                        }
                    }
                }
            }

            if (chunk == null)
            {
                chunk = GetChunk(OCChunk.ToChunkPosition(x, y, z));
                _lastRequestedChunk = chunk;
            }

            if (chunk == null)
            {
                return(OCBlockData.CreateInstance <OCBlockData>());
            }
            return(chunk.GetBlock(OCChunk.ToLocalPosition(x, y, z)));
        }
예제 #2
0
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Private Member Functions

        //---------------------------------------------------------------------------

        private static void Build(OpenCog.Map.OCChunk chunk, bool onlyLight)
        {
            OpenCog.Map.OCMap map = chunk.GetMap();
            _meshData.Clear();
            for (int z = 0; z < OpenCog.Map.OCChunk.SIZE_Z; z++)
            {
                for (int y = 0; y < OpenCog.Map.OCChunk.SIZE_Y; y++)
                {
                    for (int x = 0; x < OpenCog.Map.OCChunk.SIZE_X; x++)
                    {
                        OCBlockData blockData = chunk.GetBlock(x, y, z);
                        if (blockData != null)
                        {
                            OCBlock block = blockData.block;
                            if (block != null)
                            {
                                Vector3i localPos = new Vector3i(x, y, z);
                                Vector3i worldPos = OpenCog.Map.OCChunk.ToWorldPosition(chunk.GetPosition(), localPos);
                                if (worldPos.y > 0)
                                {
                                    block.Build(localPos, worldPos, map, _meshData, onlyLight);
                                }
                            }
                        }
                    }
                }
            }
        }