Exemple #1
0
        private Dictionary <string, RenderBank <VertexPositionNormalTexture> > MakeBanks(bool isCol)
        {
            var banks = new Dictionary <string, RenderBank <VertexPositionNormalTexture> >();

            _workingBanks = banks;
            _isCol        = isCol;

            for (int z = (isCol ? 1 : 0); z < 7; z++)
            {
                for (int x = X; x < (X + _size); x++)
                {
                    for (int y = Y; y < (Y + _size); y++)
                    {
                        BlockInfo     block    = MapManager.GetBlock(x, y, z);
                        BlockGeometry geometry = MapGeometry.GetBlock(block.SlopeType.Slope);

                        Vector3 offsetVector = new Vector3(x, -y, z);

                        if (geometry != null)
                        {
                            _block = block;
                            DrawSide(geometry.Sides[MapGeometry.SIDE_TOP], block.Top, offsetVector, false);
                            DrawSide(geometry.Sides[MapGeometry.SIDE_BOTTOM], block.Bottom, offsetVector, false);
                            DrawSide(geometry.Sides[MapGeometry.SIDE_LEFT], block.Left, offsetVector, false);
                            DrawSide(geometry.Sides[MapGeometry.SIDE_RIGHT], block.Right, offsetVector, false);
                            DrawSide(geometry.Sides[MapGeometry.SIDE_LID], block.Lid, offsetVector, true);
                        }
                    }
                }
            }

            // remove reference
            _workingBanks = null;

            return(banks);
        }
Exemple #2
0
        private static BlockGeometry DoBlock(Vector3 topLeft, Vector3 topRight, Vector3 bottomLeft, Vector3 bottomRight)
        {
            BlockGeometry block = new BlockGeometry();

            // lid
            block.Sides[SIDE_LID].Vertices[0] = new Vector3(topLeft.X, -topLeft.Y, topLeft.Z);
            block.Sides[SIDE_LID].Vertices[1] = new Vector3(topRight.X, -topRight.Y, topRight.Z);
            block.Sides[SIDE_LID].Vertices[2] = new Vector3(bottomRight.X, -bottomRight.Y, bottomRight.Z);
            block.Sides[SIDE_LID].Vertices[3] = new Vector3(bottomLeft.X, -bottomLeft.Y, bottomLeft.Z);

            block.Sides[SIDE_LID].UV[0] = new Vector2(topLeft.X, topLeft.Y);
            block.Sides[SIDE_LID].UV[1] = new Vector2(topRight.X, topRight.Y);
            block.Sides[SIDE_LID].UV[2] = new Vector2(bottomRight.X, bottomRight.Y);
            block.Sides[SIDE_LID].UV[3] = new Vector2(bottomLeft.X, bottomLeft.Y);

            block.Sides[SIDE_LID].Normal = CalculateNormal(block.Sides[SIDE_LID], true);

            // top
            block.Sides[SIDE_TOP].Vertices[0] = new Vector3(topRight.X, -topRight.Y, topRight.Z);
            block.Sides[SIDE_TOP].Vertices[1] = new Vector3(topLeft.X, -topLeft.Y, topLeft.Z);
            block.Sides[SIDE_TOP].Vertices[2] = new Vector3(topLeft.X, -topLeft.Y, 0.0f);
            block.Sides[SIDE_TOP].Vertices[3] = new Vector3(topRight.X, -topRight.Y, 0.0f);

            block.Sides[SIDE_TOP].UV[0] = new Vector2(topRight.X, 0.0f);
            block.Sides[SIDE_TOP].UV[1] = new Vector2(topLeft.X, 0.0f);
            block.Sides[SIDE_TOP].UV[2] = new Vector2(topLeft.X, topLeft.Z);
            block.Sides[SIDE_TOP].UV[3] = new Vector2(topRight.X, topLeft.Z);

            block.Sides[SIDE_TOP].Normal = CalculateNormal(block.Sides[SIDE_TOP], true);

            // bottom
            block.Sides[SIDE_BOTTOM].Vertices[0] = new Vector3(bottomLeft.X, -bottomLeft.Y, bottomLeft.Z);
            block.Sides[SIDE_BOTTOM].Vertices[1] = new Vector3(bottomRight.X, -bottomRight.Y, bottomRight.Z);
            block.Sides[SIDE_BOTTOM].Vertices[2] = new Vector3(bottomRight.X, -bottomRight.Y, 0.0f);
            block.Sides[SIDE_BOTTOM].Vertices[3] = new Vector3(bottomLeft.X, -bottomLeft.Y, 0.0f);

            block.Sides[SIDE_BOTTOM].UV[0] = new Vector2(bottomLeft.X, 0.0f);
            block.Sides[SIDE_BOTTOM].UV[1] = new Vector2(bottomRight.X, 0.0f);
            block.Sides[SIDE_BOTTOM].UV[2] = new Vector2(bottomRight.X, bottomRight.Z);
            block.Sides[SIDE_BOTTOM].UV[3] = new Vector2(bottomLeft.X, bottomRight.Z);

            block.Sides[SIDE_BOTTOM].Normal = CalculateNormal(block.Sides[SIDE_BOTTOM], true);

            // left
            block.Sides[SIDE_LEFT].Vertices[0] = new Vector3(topLeft.X, -topLeft.Y, topLeft.Z);
            block.Sides[SIDE_LEFT].Vertices[1] = new Vector3(bottomLeft.X, -bottomLeft.Y, bottomLeft.Z);
            block.Sides[SIDE_LEFT].Vertices[2] = new Vector3(bottomLeft.X, -bottomLeft.Y, 0.0f);
            block.Sides[SIDE_LEFT].Vertices[3] = new Vector3(topLeft.X, -topLeft.Y, 0.0f);

            block.Sides[SIDE_LEFT].UV[0] = new Vector2(topLeft.Y, 0.0f);
            block.Sides[SIDE_LEFT].UV[1] = new Vector2(bottomLeft.Y, 0.0f);
            block.Sides[SIDE_LEFT].UV[2] = new Vector2(bottomLeft.Y, topLeft.Z);
            block.Sides[SIDE_LEFT].UV[3] = new Vector2(topLeft.Y, topLeft.Z);

            block.Sides[SIDE_LEFT].Normal = CalculateNormal(block.Sides[SIDE_LEFT], true);

            // right
            block.Sides[SIDE_RIGHT].Vertices[0] = new Vector3(bottomRight.X, -bottomRight.Y, bottomRight.Z);
            block.Sides[SIDE_RIGHT].Vertices[1] = new Vector3(topRight.X, -topRight.Y, topRight.Z);
            block.Sides[SIDE_RIGHT].Vertices[2] = new Vector3(topRight.X, -topRight.Y, 0.0f);
            block.Sides[SIDE_RIGHT].Vertices[3] = new Vector3(bottomRight.X, -bottomRight.Y, 0.0f);

            block.Sides[SIDE_RIGHT].UV[0] = new Vector2(bottomRight.Y, topRight.Z);
            block.Sides[SIDE_RIGHT].UV[1] = new Vector2(topRight.Y, topRight.Z);
            block.Sides[SIDE_RIGHT].UV[2] = new Vector2(topRight.Y, 0.0f);
            block.Sides[SIDE_RIGHT].UV[3] = new Vector2(bottomRight.Y, 0.0f);

            block.Sides[SIDE_RIGHT].Normal = CalculateNormal(block.Sides[SIDE_RIGHT], true);

            return(block);
        }