Ejemplo n.º 1
0
        void XQuad(float x, int side, bool swapU, float shade)
        {
            int        texId = game.BlockInfo.GetTextureLoc(block, side), texIndex = 0;
            TextureRec rec = atlas.GetTexRec(texId, 1, out texIndex);

            FlushIfNotSame(texIndex);
            FastColour col = bright ? FastColour.White : FastColour.Scale(this.col, shade);

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

            rec.U1 = minBB.Z; rec.U2 = maxBB.Z;
            rec.V1 = vOrigin + (1 - minBB.Y) * atlas.invElementSize;
            rec.V2 = vOrigin + (1 - maxBB.Y) * atlas.invElementSize * 15.99f / 16f;
            if (swapU)
            {
                rec.SwapU();
            }

            cache.vertices[index++] = new VertexP3fT2fC4b(x, 0, minBB.Z - 0.5f, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x, height, minBB.Z - 0.5f, rec.U1, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x, height, maxBB.Z - 0.5f, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x, 0, maxBB.Z - 0.5f, rec.U2, rec.V1, col);
        }
Ejemplo n.º 2
0
        void ZQuad(float z, int side, bool swapU, float shade)
        {
            int        texId = game.BlockInfo.GetTextureLoc(block, side), texIndex = 0;
            TextureRec rec = atlas.GetTexRec(texId, 1, out texIndex);

            FlushIfNotSame(texIndex);
            FastColour col = bright ? FastColour.White : FastColour.Scale(this.col, shade);

            float vOrigin = rec.V1;

            rec.U1 = minBB.X; rec.U2 = maxBB.X;
            rec.V1 = vOrigin + minBB.Y * atlas.invElementSize;
            rec.V2 = vOrigin + maxBB.Y * atlas.invElementSize * 15.99f / 16f;
            if (swapU)
            {
                rec.SwapU();
            }

            cache.vertices[index++] = new VertexPos3fTex2fCol4b(minBB.X - 0.5f, 0, z, rec.U1, rec.V2, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(minBB.X - 0.5f, height, z, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(maxBB.X - 0.5f, height, z, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(maxBB.X - 0.5f, 0, z, rec.U2, rec.V2, col);
        }