示例#1
0
        void RenderTile(TileDrawInfo drawInfo, VertexPos3Tex2[] vertices, int index)
        {
            Tile tile = drawInfo.CurrentTile;

            X      = tile.X;
            Y      = tile.Y;
            height = tile.Height;

            RectangleF texRec = TerrainHelper.GetTexRec(tile.TerrainId);

            vertices[index]          = new VertexPos3Tex2(X, height, Y, texRec.Left, texRec.Top);
            vertices[index + 1]      = new VertexPos3Tex2(X + tileWidth, height, Y, texRec.Right, texRec.Top);
            vertices[index + 2]      = new VertexPos3Tex2(X + tileWidth, height, Y + tileWidth, texRec.Right, texRec.Bottom);
            vertices[index + 3]      = new VertexPos3Tex2(X, height, Y + tileWidth, texRec.Left, texRec.Bottom);
            drawInfo.TotalTriangles += 2;
        }
示例#2
0
        void RenderTile(TileDrawInfo drawInfo)
        {
            Tile tile = drawInfo.CurrentTile;

            const int xWidth = 1, yWidth = 1;

            float X = tile.X * xWidth;
            float Y = tile.Y * yWidth;

            float x1 = X, y1 = Y;
            //X = ( x1 * xWidth / 2f ) + ( y1 * xWidth / 2f );
            //Y = ( y1 * yWidth / 2f ) - ( x1 * yWidth / 2f );
            float z = 1;

            /*if( ( tile.X % 2 ) == 0 ) {
             *      //X /= 2f;
             *      //X += xWidth / 2f;
             *      //y += yWidth / 2f;
             *      //Y /= 2f;
             *      Y += yWidth * 5;
             *      Y -= (int)( yWidth / 2f );
             *      //return;
             *      //return;
             * } else {
             *      X /= 2f;
             * }*/

            RectangleF texRec = TerrainHelper.GetTexRec(tile.TerrainId);

            float Width = xWidth;
            float Depth = yWidth;

            float xHalf = Width / 2;

            GL.TexCoord2(0f, 0f); GL.Vertex3(X - xHalf, z, Y + Depth / 4);               // Bottom left
            GL.TexCoord2(1f, 0f); GL.Vertex3(X + xHalf, z, Y + Depth / 4);               // Bottom Right
            GL.TexCoord2(1f, 1f); GL.Vertex3(X + xHalf, z, Y - 3 * Depth / 4);           // Top Right
            GL.TexCoord2(0f, 1f); GL.Vertex3(X - xHalf, z, Y - 3 * Depth / 4);           // Top Left

            //VertexPosUv( x, height, y, texRec.Left, texRec.Top );
            //VertexPosUv( x + tileWidth, height, y, texRec.Right, texRec.Top );
            //VertexPosUv( x + tileWidth, height, y + tileHeight, texRec.Right, texRec.Bottom );
            //VertexPosUv( x, height, y + tileHeight, texRec.Left, texRec.Bottom );

            drawInfo.TotalTriangles += 2;
        }