Esempio n. 1
0
        void SpriteZQuad(byte block, bool firstPart)
        {
            int        texLoc = game.BlockInfo.GetTextureLoc(block, Side.Right);
            TextureRec rec    = atlas.GetTexRec(texLoc, 1, out texIndex);

            if (lastIndex != texIndex)
            {
                Flush();
            }

            VertexP3fT2fC4b v = default(VertexP3fT2fC4b);

            v.Colour = colNormal;

            float x1 = firstPart ? 0.5f : -0.1f, x2 = firstPart ? 1.1f : 0.5f;

            rec.U1 = firstPart ? 0.0f : 0.5f; rec.U2 = (firstPart ? 0.5f : 1.0f) * (15.99f / 16f);
            float minX = scale * (1 - x1 * 2), maxX = scale * (1 - x2 * 2);
            float minY = scale * (1 - 0 * 2), maxY = scale * (1 - 1.1f * 2);

            v.X = minX; v.Y = minY; v.Z = 0; v.U = rec.U2; v.V = rec.V2; Transform(ref v);
            v.X = minX; v.Y = maxY; v.Z = 0; v.U = rec.U2; v.V = rec.V1; Transform(ref v);
            v.X = maxX; v.Y = maxY; v.Z = 0; v.U = rec.U1; v.V = rec.V1; Transform(ref v);
            v.X = maxX; v.Y = minY; v.Z = 0; v.U = rec.U1; v.V = rec.V2; Transform(ref v);
        }
Esempio n. 2
0
        void MakeSelectionTexture()
        {
            int        hSize = (int)selBlockSize;
            int        vSize = (int)Math.Floor(23 * 2 * game.GuiHotbarScale);
            int        y     = game.Height - vSize;
            TextureRec rec   = new TextureRec(0, 22 / 256f, 24 / 256f, 24 / 256f);

            selTex = new Texture(0, 0, y, hSize, vSize, rec);
        }
Esempio n. 3
0
        static void SpriteXQuad(byte block, int side, bool firstPart)
        {
            int        texLoc = info.GetTextureLoc(block, side);
            TextureRec rec    = atlas.GetTexRec(texLoc, 1, out texIndex);

            FlushIfNotSame();

            FastColour col = colNormal;
            float      z1 = firstPart ? -0.1f : 0.5f, z2 = firstPart ? 0.5f : 1.1f;

            rec.U1 = firstPart ? 0.0f : 0.5f; rec.U2 = (firstPart ? 0.5f : 1.0f) * (15.99f / 16f);

            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(0.5f), Make(0.0f), Make(z1), rec.U1, rec.V2, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(0.5f), Make(1.1f), Make(z1), rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(0.5f), Make(1.1f), Make(z2), rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(0.5f), Make(0.0f), Make(z2), rec.U2, rec.V2, col);
        }
Esempio n. 4
0
        static void YQuad(byte block, float y, int side)
        {
            int        texLoc = info.GetTextureLoc(block, side);
            TextureRec rec    = atlas.GetTexRec(texLoc, 1, out texIndex);

            FlushIfNotSame();
            FastColour col = colNormal;

            float vOrigin = (texLoc % atlas.elementsPerAtlas1D) * atlas.invElementSize;

            rec.U1 = minBB.X; rec.U2 = maxBB.X;
            rec.V1 = vOrigin + minBB.Z * atlas.invElementSize;
            rec.V2 = vOrigin + maxBB.Z * atlas.invElementSize * (15.99f / 16f);

            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(minBB.X), y, Make(minBB.Z), rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(maxBB.X), y, Make(minBB.Z), rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(maxBB.X), y, Make(maxBB.Z), rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(Make(minBB.X), y, Make(maxBB.Z), rec.U1, rec.V2, col);
        }
Esempio n. 5
0
        void DrawPosition()
        {
            int index = 0;
            TextureRec xy = new TextureRec( 2, posTexture.Y1, baseWidth, posTexture.Height );
            TextureRec uv = new TextureRec( 0, 0, posTexture.U2, posTexture.V2 );
            IGraphicsApi.Make2DQuad( xy, uv, game.ModelCache.vertices, ref index );

            Vector3I pos = Vector3I.Floor( game.LocalPlayer.Position );
            curX = baseWidth + 2;
            AddChar( 13, ref index );
            AddInt( pos.X, ref index, true );
            AddInt( pos.Y, ref index, true );
            AddInt( pos.Z, ref index, false );
            AddChar( 14, ref index );

            graphicsApi.BindTexture( posTexture.ID );
            graphicsApi.DrawDynamicIndexedVb( DrawMode.Triangles,
                                             game.ModelCache.vb, game.ModelCache.vertices, index, index * 6 / 4 );
        }
Esempio n. 6
0
        void AddChar( int charIndex, ref int index )
        {
            int width = widths[charIndex];
            TextureRec xy = new TextureRec( curX, posTexture.Y1, width, posTexture.Height );
            TextureRec uv = new TextureRec( (baseWidth + charIndex * 16) / texWidth, 0, width / texWidth, posTexture.V2 );

            curX += width;
            IGraphicsApi.Make2DQuad( xy, uv, game.ModelCache.vertices, ref index );
        }
Esempio n. 7
0
 public Texture( int id, int x, int y, int width, int height, 
     TextureRec rec)
     : this(id, x, y, width, height, rec.U1, rec.U2, rec.V1, rec.V2)
 {
 }
Esempio n. 8
0
        void MakeBackgroundTexture()
        {
            TextureRec rec = new TextureRec(0, 0, 182 / 256f, 22 / 256f);

            backTex = new Texture(0, X, Y, Width, Height, rec);
        }
Esempio n. 9
0
        void DrawZ( int z, int x1, int x2, int y1, int y2, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices )
        {
            int endX = x2, endY = y2, startY = y1;
            for( ; x1 < endX; x1 += axisSize ) {
                x2 = x1 + axisSize;
                if( x2 > endX ) x2 = endX;
                y1 = startY;
                for( ; y1 < endY; y1 += axisSize ) {
                    y2 = y1 + axisSize;
                    if( y2 > endY ) y2 = endY;

                    TextureRec rec = new TextureRec( 0, 0, x2 - x1, y2 - y1 );
                    *vertices++ = new VertexPos3fTex2fCol4b( x1, y1, z, rec.U1, rec.V1, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x1, y2, z, rec.U1, rec.V2, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x2, y2, z, rec.U2, rec.V2, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x2, y1, z, rec.U2, rec.V1, col );
                }
            }
        }
Esempio n. 10
0
        void DrawY( int x1, int z1, int x2, int z2, int y, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices )
        {
            int endX = x2, endZ = z2, startZ = z1;
            for( ; x1 < endX; x1 += axisSize ) {
                x2 = x1 + axisSize;
                if( x2 > endX ) x2 = endX;
                z1 = startZ;
                for( ; z1 < endZ; z1 += axisSize ) {
                    z2 = z1 + axisSize;
                    if( z2 > endZ ) z2 = endZ;

                    TextureRec rec = new TextureRec( 0, 0, x2 - x1, z2 - z1 );
                    *vertices++ = new VertexPos3fTex2fCol4b( x1, y, z1, rec.U1, rec.V1, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x1, y, z2, rec.U1, rec.V2, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x2, y, z2, rec.U2, rec.V2, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x2, y, z1, rec.U2, rec.V1, col );
                }
            }
        }
Esempio n. 11
0
        void DrawX( int x, int z1, int z2, int y1, int y2, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices )
        {
            int endZ = z2, endY = y2, startY = y1;
            for( ; z1 < endZ; z1 += axisSize ) {
                z2 = z1 + axisSize;
                if( z2 > endZ ) z2 = endZ;
                y1 = startY;
                for( ; y1 < endY; y1 += axisSize ) {
                    y2 = y1 + axisSize;
                    if( y2 > endY ) y2 = endY;

                    TextureRec rec = new TextureRec( 0, 0, z2 - z1, y2 - y1 );
                    *vertices++ = new VertexPos3fTex2fCol4b( x, y1, z1, rec.U1, rec.V1, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x, y2, z1, rec.U1, rec.V2, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x, y2, z2, rec.U2, rec.V2, col );
                    *vertices++ = new VertexPos3fTex2fCol4b( x, y1, z2, rec.U2, rec.V1, col );
                }
            }
        }