Beispiel #1
0
        private BlockSide ModifySide(BlockSide side, SideTile part)
        {
            BlockSide modifiedSide = new BlockSide();

            modifiedSide.Vertices = side.Vertices;
            modifiedSide.Normal   = side.Normal;
            modifiedSide.UV       = new Vector2[4];
            modifiedSide.UV[0]    = side.UV[0];
            modifiedSide.UV[1]    = side.UV[1];
            modifiedSide.UV[2]    = side.UV[2];
            modifiedSide.UV[3]    = side.UV[3];

            int rotation = part.Rotation;

            if (part.Flip)
            {
                rotation += 4;
            }

            float[] uvStuff = new float[4]
            {
                0.0f,
                0.0f,
                1.0f,
                1.0f
            };

            modifiedSide.UV    = new Vector2[4];
            modifiedSide.UV[0] = new Vector2(uvStuff[_rotations[rotation][0]], uvStuff[_rotations[rotation][1]]);
            modifiedSide.UV[1] = new Vector2(uvStuff[_rotations[rotation][2]], uvStuff[_rotations[rotation][3]]);
            modifiedSide.UV[2] = new Vector2(uvStuff[_rotations[rotation][4]], uvStuff[_rotations[rotation][5]]);
            modifiedSide.UV[3] = new Vector2(uvStuff[_rotations[rotation][6]], uvStuff[_rotations[rotation][7]]);

            return(modifiedSide);
        }
Beispiel #2
0
        public void Read(BinaryReader reader)
        {
            Left   = new SideTile(reader.ReadUInt16());
            Right  = new SideTile(reader.ReadUInt16());
            Top    = new SideTile(reader.ReadUInt16());
            Bottom = new SideTile(reader.ReadUInt16());
            Lid    = new SideTile(reader.ReadUInt16());

            Arrows = reader.ReadByte();

            SlopeType = new SlopeType(reader.ReadByte());
        }
Beispiel #3
0
        private void DrawSide(BlockSide side, SideTile part, Vector3 offset, bool isLid)
        {
            if (part.Sprite > 0)
            {
                if (_isCol && (!part.Wall && !isLid))
                {
                    if (_block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_DOWNLEFT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_DOWNRIGHT &&
                        _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_UPLEFT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_UPRIGHT)
                    {
                        return;
                    }
                }

                BlockSide modifiedSide = ModifySide(side, part);

                ushort sprite = part.Sprite;

                string   materialName = string.Format("gbh/bil/{0}", sprite);
                Material material     = MaterialManager.FindMaterial(materialName);

                var bank = GetBank(material.BaseName);
                bank.ReserveSpace(side.Vertices.Length, (side.Vertices.Length == 4) ? 6 : 4);

                int vertIndex = bank.numVertex;

                bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 0, offset, part, material);
                bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 1, offset, part, material);
                bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 2, offset, part, material);

                bank.indices[bank.numIndex++] = (short)(vertIndex + 0);
                bank.indices[bank.numIndex++] = (short)(vertIndex + 1);
                bank.indices[bank.numIndex++] = (short)(vertIndex + 2);

                if (side.Vertices.Length == 4)
                {
                    bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 3, offset, part, material);

                    bank.indices[bank.numIndex++] = (short)(vertIndex + 2);
                    bank.indices[bank.numIndex++] = (short)(vertIndex + 3);
                    bank.indices[bank.numIndex++] = (short)(vertIndex + 0);
                }
            }
        }
Beispiel #4
0
 private VertexPositionNormalTexture GetVertex(BlockSide side, int vertex, Vector3 offset, SideTile part, Material material)
 {
     return(new VertexPositionNormalTexture(side.Vertices[vertex] + offset, side.Normal, material.TransformUV(side.UV[vertex])));
 }