Example #1
0
        void DrawX(int x, int z1, int z2, int y1, int y2, int axisSize,
                   int col, ref VertexP3fT2fC4b *v)
        {
            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);
                    *          v   = new VertexP3fT2fC4b(x, y1, z1, rec.U1, rec.V2, col); v++;
                    *          v   = new VertexP3fT2fC4b(x, y2, z1, rec.U1, rec.V1, col); v++;
                    *          v   = new VertexP3fT2fC4b(x, y2, z2, rec.U2, rec.V1, col); v++;
                    *          v   = new VertexP3fT2fC4b(x, y1, z2, rec.U2, rec.V2, col); v++;
                }
            }
        }
Example #2
0
        public virtual void RenderHotbarItems()
        {
            Model.ModelCache cache = game.ModelCache;

            for (int i = 0; i < Inventory.BlocksPerRow; i++)
            {
                BlockID block = game.Inventory[i];
                if (BlockInfo.Draw[block] != DrawType.Sprite)
                {
                    continue;
                }
                int x     = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2);
                int y     = (int)(Y + (Height - barHeight));
                int lower = (int)(3 * game.GuiHotbarScale);
                int side  = (int)(8 * game.GuiHotbarScale);
                int outer = (int)(16 * game.GuiHotbarScale);

                y += lower;
                x -= side;

                if (BlockInfo.Draw[block] == DrawType.Sprite)
                {
                    int        texLoc = BlockInfo.GetTextureLoc(block, Side.Right);
                    TextureRec rec    = TerrainAtlas1D.GetTexRec(texLoc, 1, out texIndex);

                    Texture tex = new Texture(0, (int)x, (int)y, outer, outer, rec);
                    IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index);

                    game.Graphics.BindTexture(TerrainAtlas1D.TexIds[texIndex]);
                    game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index);
                }
            }
            index    = 0;
            texIndex = 0;
        }
Example #3
0
        void SpriteXQuad(int side, bool firstPart)
        {
            int        texId = game.BlockInfo.GetTextureLoc(block, side), texIndex = 0;
            TextureRec rec = atlas.GetTexRec(texId, 1, out texIndex);

            FlushIfNotSame(texIndex);
            if (height != 1)
            {
                rec.V2 = rec.V1 + height * atlas.invElementSize * (15.99f / 16f);
            }
            FastColour col = bright ? FastColour.White : this.col;

            float x1, x2, z1, z2;

            if (firstPart)
            {
                rec.U1 = 0; rec.U2 = 0.5f; x1 = -5.5f / 16;
                x2     = 0.0f / 16; z1 = 5.5f / 16; z2 = 0.0f / 16;
            }
            else
            {
                rec.U1 = 0.5f; rec.U2 = 1f; x1 = 0.0f / 16;
                x2     = 5.5f / 16; z1 = 0.0f / 16; z2 = -5.5f / 16;
            }

            cache.vertices[index++] = new VertexPos3fTex2fCol4b(x1, 0, z1, rec.U1, rec.V2, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(x1, 1, z1, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(x2, 1, z2, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(x2, 0, z2, rec.U2, rec.V2, col);
        }
Example #4
0
        void DrawY(int x1, int z1, int x2, int z2, float y, int axisSize,
                   int col, float offset, float yOffset, ref VertexP3fT2fC4b *v)
        {
            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);
                    *          v   = new VertexP3fT2fC4b(x1 + offset, y + yOffset, z1 + offset, rec.U1, rec.V1, col); v++;
                    *          v   = new VertexP3fT2fC4b(x1 + offset, y + yOffset, z2 + offset, rec.U1, rec.V2, col); v++;
                    *          v   = new VertexP3fT2fC4b(x2 + offset, y + yOffset, z2 + offset, rec.U2, rec.V2, col); v++;
                    *          v   = new VertexP3fT2fC4b(x2 + offset, y + yOffset, z1 + offset, rec.U2, rec.V1, col); v++;
                }
            }
        }
Example #5
0
        void SpriteZQuad(int side, bool firstPart)
        {
            int        texId = game.BlockInfo.GetTextureLoc(block, side), texIndex = 0;
            TextureRec rec = atlas.GetTexRec(texId, 1, out texIndex);

            FlushIfNotSame(texIndex);
            if (height != 1)
            {
                rec.V2 = rec.V1 + height * atlas.invElementSize * (15.99f / 16f);
            }
            FastColour col = bright ? FastColour.White : this.col;

            float p1, p2;

            if (firstPart)                // Need to break into two quads for when drawing a sprite model in hand.
            {
                rec.U1 = 0.5f; p1 = -5.5f / 16; p2 = 0.0f / 16;
            }
            else
            {
                rec.U2 = 0.5f; p1 = 0.0f / 16; p2 = 5.5f / 16;
            }
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(p1, 0, p1, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(p1, 1, p1, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(p2, 1, p2, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexPos3fTex2fCol4b(p2, 0, p2, rec.U1, rec.V2, col);
        }
Example #6
0
        void DrawHearts()
        {
            Model.ModelCache cache = game.ModelCache;
            int index = 0, health = game.LocalPlayer.Health;
            int inner = (int)(7 * game.GuiHotbarScale);
            int middle = (int)(8 * game.GuiHotbarScale);
            int outer = (int)(9 * game.GuiHotbarScale);

            int selBlockSize = (int)(23 * game.GuiHotbarScale);
            int offset       = middle - inner;
            int y            = Y + (Height - selBlockSize - outer);

            for (int heart = 0; heart < 10; heart++)
            {
                Texture tex = new Texture(0, X + middle * heart, y, outer, outer, backRec);
                IGraphicsApi.Make2DQuad(ref tex, PackedCol.White, cache.vertices, ref index);
                if (health <= 0)
                {
                    continue;
                }

                TextureRec rec = (health >= 2) ? fullRec : halfRec;
                tex = new Texture(0, X + middle * heart + offset, y + offset, inner, inner, rec);
                IGraphicsApi.Make2DQuad(ref tex, PackedCol.White, cache.vertices, ref index);
                health -= 2;
            }

            game.Graphics.BindTexture(game.Gui.IconsTex);
            game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index);
        }
Example #7
0
        void DrawZ(int z, int x1, int x2, int y1, int y2, int axisSize,
                   int col, ref VertexP3fT2fC4b *v)
        {
            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);
                    *          v   = new VertexP3fT2fC4b(x1, y1, z, rec.U1, rec.V2, col); v++;
                    *          v   = new VertexP3fT2fC4b(x1, y2, z, rec.U1, rec.V1, col); v++;
                    *          v   = new VertexP3fT2fC4b(x2, y2, z, rec.U2, rec.V1, col); v++;
                    *          v   = new VertexP3fT2fC4b(x2, y1, z, rec.U2, rec.V2, col); v++;
                }
            }
        }
Example #8
0
 public Particle( Game game, Vector3 pos, Vector3 velocity, double lifetime, TextureRec rec )
 {
     this.game = game;
     Position = lastPos = nextPos = pos;
     Velocity = velocity;
     Lifetime = (float)lifetime;
     Rectangle = rec;
 }
Example #9
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);
        }
Example #10
0
        void BreakBlockEffect(object sender, BlockChangedEventArgs e)
        {
            if (e.Block != 0)
            {
                return;
            }
            Vector3I position = e.Coords;
            byte     block    = e.OldBlock;

            Vector3    startPos = new Vector3(position.X, position.Y, position.Z);
            int        texLoc = game.BlockInfo.GetTextureLoc(block, Side.Left), texIndex = 0;
            TextureRec baseRec = game.TerrainAtlas1D.GetTexRec(texLoc, 1, out texIndex);
            float      uScale = (1 / 16f), vScale = (1 / 16f) * game.TerrainAtlas1D.invElementSize;

            Vector3 minBB = game.BlockInfo.MinBB[block];
            Vector3 maxBB = game.BlockInfo.MaxBB[block];
            int     minU = Math.Min((int)(minBB.X * 16), (int)(minBB.Z * 16));
            int     maxU = Math.Min((int)(maxBB.X * 16), (int)(maxBB.Z * 16));
            int     minV = (int)(16 - maxBB.Y * 16), maxV = (int)(16 - minBB.Y * 16);
            int     maxUsedU = maxU, maxUsedV = maxV;

            // This way we can avoid creating particles which outside the bounds and need to be clamped
            if (minU < 12 && maxU > 12)
            {
                maxUsedU = 12;
            }
            if (minV < 12 && maxV > 12)
            {
                maxUsedV = 12;
            }

            for (int i = 0; i < 30; i++)
            {
                double  velX     = rnd.NextDouble() * 0.8 - 0.4;            // [-0.4, 0.4]
                double  velZ     = rnd.NextDouble() * 0.8 - 0.4;
                double  velY     = rnd.NextDouble() + 0.2;
                Vector3 velocity = new Vector3((float)velX, (float)velY, (float)velZ);

                double  xOffset = rnd.NextDouble() - 0.5;                // [-0.5, 0.5]
                double  yOffset = (rnd.NextDouble() - 0.125) * maxBB.Y;
                double  zOffset = rnd.NextDouble() - 0.5;
                Vector3 pos     = startPos + new Vector3(0.5f + (float)xOffset,
                                                         (float)yOffset, 0.5f + (float)zOffset);

                TextureRec rec = baseRec;
                rec.U1 = baseRec.U1 + rnd.Next(minU, maxUsedU) * uScale;
                rec.V1 = baseRec.V1 + rnd.Next(minV, maxUsedV) * vScale;
                rec.U2 = Math.Min(baseRec.U1 + maxU * uScale, rec.U1 + 4 * uScale) - 0.01f * uScale;
                rec.V2 = Math.Min(baseRec.V1 + maxV * vScale, rec.V1 + 4 * vScale) - 0.01f * vScale;
                double life = 0.3 + rnd.NextDouble() * 0.7;

                TerrainParticle p = AddParticle(terrainParticles, ref terrainCount, false);
                p.ResetState(pos, velocity, life);
                p.rec    = rec;
                p.texLoc = texLoc;
            }
        }
        void AddChar(int charIndex, ref int index)
        {
            int        width = widths[charIndex];
            TextureRec xy    = new TextureRec(curX, posTex.Y1, width, posTex.Height);
            TextureRec uv    = new TextureRec((baseWidth + charIndex * 16) / texWidth,
                                              posTex.V1, width / texWidth, posTex.V2);

            curX += width;
            IGraphicsApi.Make2DQuad(xy, uv, game.ModelCache.vertices, ref index);
        }
Example #12
0
        const byte c = 255;         // avoids 'ambiguous match' compile errors.
        void DraqSquareShadow(VertexP3fT2fC4b[] verts, ref int index, float y, byte alpha, float x, float z)
        {
            int        col = new FastColour(c, c, c, alpha).ToArgb();
            TextureRec rec = new TextureRec(63 / 128f, 63 / 128f, 1 / 128f, 1 / 128f);

            verts[index++] = new VertexP3fT2fC4b(x, y, z, rec.U1, rec.V1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z, rec.U2, rec.V1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, rec.U2, rec.V2, col);
            verts[index++] = new VertexP3fT2fC4b(x, y, z + 1, rec.U1, rec.V2, col);
        }
        void DraqSquareShadow(VertexP3fT2fC4b[] verts, ref int index, float y, byte alpha, float x, float z)
        {
            FastColour col = FastColour.White; col.A = alpha;
            TextureRec rec = new TextureRec(63 / 128f, 63 / 128f, 1 / 128f, 1 / 128f);

            verts[index++] = new VertexP3fT2fC4b(x, y, z, rec.U1, rec.V1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z, rec.U2, rec.V1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, rec.U2, rec.V2, col);
            verts[index++] = new VertexP3fT2fC4b(x, y, z + 1, rec.U1, rec.V2, col);
        }
Example #14
0
        void SpriteXQuad(bool firstPart, bool mirror, BlockID block, ref int lastTexIndex, ModelCache cache, float dispX, float dispY, float dispZ, float scale)
        {
            int texLoc = BlockInfo.GetTextureLoc(block, Side.Right);

            TextureRec rec = Atlas1D.GetTexRec(texLoc, 1, out texIndex);

            if (lastTexIndex != texIndex)
            {
                if (lastTexIndex != -1)
                {
                    game.Graphics.BindTexture(Atlas1D.TexIds[lastTexIndex]);
                    UpdateVB();
                }

                lastTexIndex = texIndex;
                index        = 0;
            }
            PackedCol col = cols[0];

            if (BlockInfo.Tinted[block])
            {
                col *= BlockInfo.FogCol[block];
            }

            float x1 = 0, x2 = 0, z1 = 0, z2 = 0;

            if (firstPart)
            {
                if (mirror)
                {
                    rec.U2 = 0.5f; x2 = -5.5f / 16; z2 = 5.5f / 16;
                }
                else
                {
                    rec.U1 = 0.5f; x1 = -5.5f / 16; z1 = 5.5f / 16;
                }
            }
            else
            {
                if (mirror)
                {
                    rec.U1 = 0.5f; x1 = 5.5f / 16; z1 = -5.5f / 16;
                }
                else
                {
                    rec.U2 = 0.5f; x2 = 5.5f / 16; z2 = -5.5f / 16;
                }
            }

            cache.vertices[index++] = new VertexP3fT2fC4b(x1 * scale + dispX, dispY, z1 * scale + dispZ, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x1 * scale + dispX, scale + dispY, z1 * scale + dispZ, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x2 * scale + dispX, scale + dispY, z2 * scale + dispZ, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x2 * scale + dispX, dispY, z2 * scale + dispZ, rec.U1, rec.V2, col);
        }
Example #15
0
        const byte c = 255;         // avoids 'ambiguous match' compile errors.
        static void DrawSquareShadow(VertexP3fT2fC4b[] verts, ref int index,
                                     float y, float x, float z)
        {
            int        col = new FastColour(c, c, c, (byte)220).Pack();
            TextureRec rec = new TextureRec(63 / 128f, 63 / 128f, 1 / 128f, 1 / 128f);

            verts[index++] = new VertexP3fT2fC4b(x, y, z, rec.U1, rec.V1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z, rec.U2, rec.V1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, rec.U2, rec.V2, col);
            verts[index++] = new VertexP3fT2fC4b(x, y, z + 1, rec.U1, rec.V2, col);
        }
        void DrawHearts()
        {
            Model.ModelCache cache = game.ModelCache;
            int index = 0, health = game.LocalPlayer.Health;
            int damage = this.damage;
            int inner  = (int)(7 * game.GuiHotbarScale);
            int middle = (int)(8 * game.GuiHotbarScale);
            int outer  = (int)(9 * game.GuiHotbarScale);

            int selBlockSize = (int)(23 * game.GuiHotbarScale);
            int offset       = middle - inner;
            int y            = Y + (Height - selBlockSize - outer);

            bool flash = false;

            if (damageTime <= 10 && damageTime >= 8 ||
                damageTime >= 14 && damageTime <= 17)
            {
                flash = true;
            }

            TextureRec rec2 = flash ? backRecHurt : backRec;

            for (int heart = 0; heart < 10; heart++)
            {
                Texture tex = new Texture(0, X + middle * heart, y, outer, outer, rec2);
                IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index);

                if (damage > 0 && health <= 1 && flash)
                {
                    if (health == 1)
                    {
                        damage += 1;
                    }
                    TextureRec rec3 = (damage >= 2) ? fullRecHurt : halfRecHurt;
                    tex = new Texture(0, X + middle * heart + offset, y + offset, inner, inner, rec3);
                    IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index);
                    damage -= 2;
                }
                if (health <= 0)
                {
                    continue;
                }

                TextureRec rec = (health >= 2) ? fullRec : halfRec;
                tex = new Texture(0, X + middle * heart + offset, y + offset, inner, inner, rec);
                IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index);
                health -= 2;
            }

            game.Graphics.BindTexture(game.Gui.IconsTex);
            game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index);
        }
Example #17
0
        void SpriteZQuad(bool firstPart, bool mirror, BlockID block, ref int lastTexIndex, ModelCache cache, float dispX, float dispY, float dispZ, float scale)
        {
            int        texLoc = BlockInfo.GetTextureLoc(block, Side.Back);
            TextureRec rec    = Atlas1D.GetTexRec(texLoc, 1, out texIndex);

            if (lastTexIndex != texIndex)
            {
                if (lastTexIndex != -1)
                {
                    game.Graphics.BindTexture(Atlas1D.TexIds[lastTexIndex]);
                    UpdateVB();
                }

                lastTexIndex = texIndex;
                index        = 0;
            }
            PackedCol col = cols[0];

            if (BlockInfo.Tinted[block])
            {
                col *= BlockInfo.FogCol[block];
            }

            float p1 = 0, p2 = 0;

            if (firstPart)
            { // Need to break into two quads for when drawing a sprite model in hand.
                if (mirror)
                {
                    rec.U1 = 0.5f; p1 = -5.5f / 16;
                }
                else
                {
                    rec.U2 = 0.5f; p2 = -5.5f / 16;
                }
            }
            else
            {
                if (mirror)
                {
                    rec.U2 = 0.5f; p2 = 5.5f / 16;
                }
                else
                {
                    rec.U1 = 0.5f; p1 = 5.5f / 16;
                }
            }

            cache.vertices[index++] = new VertexP3fT2fC4b(p1 * scale + dispX, dispY, p1 * scale + dispZ, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(p1 * scale + dispX, scale + dispY, p1 * scale + dispZ, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(p2 * scale + dispX, scale + dispY, p2 * scale + dispZ, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(p2 * scale + dispX, dispY, p2 * scale + dispZ, rec.U1, rec.V2, col);
        }
Example #18
0
        void RepositionSelectionTexture()
        {
            int hSize = (int)selBlockSize;

            float scale = game.GuiHotbarScale;
            int   vSize = (int)(22 * scale);
            int   y     = Y + (Height - (int)(23 * scale));

            TextureRec rec = new TextureRec(0, 22 / 256f, 24 / 256f, 22 / 256f);

            selTex = new Texture(0, 0, y, hSize, vSize, rec);
        }
Example #19
0
        protected void DoRender(Game game, ref Vector2 size, ref TextureRec rec,
                                int col, VertexP3fT2fC4b[] vertices, ref int index)
        {
            Vector3 p111, p121, p212, p222;

            Utils.CalcBillboardPoints(size, Position, ref game.View,
                                      out p111, out p121, out p212, out p222);

            vertices[index++] = new VertexP3fT2fC4b(ref p111, rec.U1, rec.V2, col);
            vertices[index++] = new VertexP3fT2fC4b(ref p121, rec.U1, rec.V1, col);
            vertices[index++] = new VertexP3fT2fC4b(ref p222, rec.U2, rec.V1, col);
            vertices[index++] = new VertexP3fT2fC4b(ref p212, rec.U2, rec.V2, col);
        }
Example #20
0
        unsafe void MakeVb()
        {
            if (game.Graphics.LostContext)
            {
                return;
            }
            game.Graphics.DeleteVb(ref vb);
            VertexP3fT2fC4b *vertices = stackalloc VertexP3fT2fC4b[count];
            IntPtr           start    = (IntPtr)vertices;
            const float      pos      = 0.5f;
            TextureRec       rec;
            int col = game.World.Env.CloudsCol.Pack();

            // Render the front quad
            rec = new TextureRec(1 / 4f, 1 / 2f, 1 / 4f, 1 / 2f);
            *vertices = new VertexP3fT2fC4b(pos, -pos, -pos, rec.U1, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, -pos, -pos, rec.U2, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, pos, -pos, rec.U2, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, pos, -pos, rec.U1, rec.V1, col); vertices++;
            // Render the left quad
            rec = new TextureRec(0 / 4f, 1 / 2f, 1 / 4f, 1 / 2f);
            *vertices = new VertexP3fT2fC4b(pos, -pos, pos, rec.U1, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, -pos, -pos, rec.U2, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, pos, -pos, rec.U2, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, pos, pos, rec.U1, rec.V1, col); vertices++;
            // Render the back quad
            rec = new TextureRec(3 / 4f, 1 / 2f, 1 / 4f, 1 / 2f);
            *vertices = new VertexP3fT2fC4b(-pos, -pos, pos, rec.U1, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, -pos, pos, rec.U2, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, pos, pos, rec.U2, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, pos, pos, rec.U1, rec.V1, col); vertices++;
            // Render the right quad
            rec = new TextureRec(2 / 4f, 1 / 2f, 1 / 4f, 1 / 2f);
            *vertices = new VertexP3fT2fC4b(-pos, -pos, -pos, rec.U1, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, -pos, pos, rec.U2, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, pos, pos, rec.U2, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, pos, -pos, rec.U1, rec.V1, col); vertices++;
            // Render the top quad
            rec = new TextureRec(1 / 4f, 0 / 2f, 1 / 4f, 1 / 2f);
            *vertices = new VertexP3fT2fC4b(-pos, pos, -pos, rec.U2, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, pos, pos, rec.U2, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, pos, pos, rec.U1, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, pos, -pos, rec.U1, rec.V2, col); vertices++;
            // Render the bottom quad
            rec = new TextureRec(2 / 4f, 0 / 2f, 1 / 4f, 1 / 2f);
            *vertices = new VertexP3fT2fC4b(-pos, -pos, -pos, rec.U2, rec.V2, col); vertices++;
            *vertices = new VertexP3fT2fC4b(-pos, -pos, pos, rec.U2, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, -pos, pos, rec.U1, rec.V1, col); vertices++;
            *vertices = new VertexP3fT2fC4b(pos, -pos, -pos, rec.U1, rec.V2, col); vertices++;
            vb = game.Graphics.CreateVb(start, VertexFormat.P3fT2fC4b, count);
        }
Example #21
0
        protected void DoRender( Game game, ref Vector2 size, ref TextureRec rec,
            VertexP3fT2fC4b[] vertices, ref int index)
        {
            Vector3 p111, p121, p212, p222;
            Utils.CalcBillboardPoints( size, Position, ref game.View,
                                      out p111, out p121, out p212, out p222 );
            World map = game.World;
            FastColour col = map.IsLit( Position ) ? map.Env.Sunlight : map.Env.Shadowlight;

            vertices[index++] = new VertexP3fT2fC4b( p111, rec.U1, rec.V2, col );
            vertices[index++] = new VertexP3fT2fC4b( p121, rec.U1, rec.V1, col );
            vertices[index++] = new VertexP3fT2fC4b( p222, rec.U2, rec.V1, col );
            vertices[index++] = new VertexP3fT2fC4b( p212, rec.U2, rec.V2, col );
        }
        void DrawBubbles()
        {
            Model.ModelCache cache = game.ModelCache;
            int index = 0, air = Utils.Ceil(((float)game.LocalPlayer.Air / 30f));
            int damage = this.damage;
            int inner  = (int)(7 * game.GuiHotbarScale);
            int middle = (int)(8 * game.GuiHotbarScale);
            int outer  = (int)(9 * game.GuiHotbarScale);

            int selBlockSize = (int)(23 * game.GuiHotbarScale);
            //int offset = middle - inner;
            //int offset = (int)(101 * game.GuiHotbarScale);
            int y = Y + (Height - selBlockSize - outer * 2);

            if (air > 0)
            {
                drowning = false;
            }
            if ((float)game.LocalPlayer.Air / 30 == air && !drowning)
            {
                this.pop = 3;
                if (air == 0)
                {
                    drowning = true;
                }
            }

            bool pop = (this.pop > 0);

            TextureRec rec2 = BubbleRec;

            for (int heart = 0; heart < 10; heart++)
            {
                if (air <= 0 && !pop)
                {
                    continue;
                }
                if (pop && air == 0)
                {
                    rec2 = PoppedRec;
                    pop  = false;
                }
                Texture tex = new Texture(0, X + middle * heart, y, outer, outer, rec2);
                IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index);
                air -= 1;
            }

            game.Graphics.BindTexture(game.Gui.IconsTex);
            game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index);
        }
Example #23
0
        public static void Make2DQuad(TextureRec xy, TextureRec uv,
                                      VertexPos3fTex2fCol4b[] vertices, ref int index)
        {
            float x1 = xy.U1, y1 = xy.V1, x2 = xy.U2, y2 = xy.V2;

                        #if USE_DX
            x1 -= 0.5f; x2 -= 0.5f;
            y1 -= 0.5f; y2 -= 0.5f;
                        #endif
            vertices[index++] = new VertexPos3fTex2fCol4b(x1, y1, 0, uv.U1, uv.V1, FastColour.White);
            vertices[index++] = new VertexPos3fTex2fCol4b(x2, y1, 0, uv.U2, uv.V1, FastColour.White);
            vertices[index++] = new VertexPos3fTex2fCol4b(x2, y2, 0, uv.U2, uv.V2, FastColour.White);
            vertices[index++] = new VertexPos3fTex2fCol4b(x1, y2, 0, uv.U1, uv.V2, FastColour.White);
        }
        public void BreakBlockEffect(Vector3I position, byte block)
        {
            Vector3     startPos = new Vector3(position.X, position.Y, position.Z);
            int         texLoc   = game.BlockInfo.GetTextureLoc(block, TileSide.Left);
            TextureRec  baseRec  = game.TerrainAtlas.GetTexRec(texLoc);
            const float uvScale  = (1 / 16f) * TerrainAtlas2D.invElementSize;
            const float elemSize = 4 * uvScale;

            Vector3 minBB = game.BlockInfo.MinBB[block];
            Vector3 maxBB = game.BlockInfo.MaxBB[block];
            int     minU = Math.Min((int)(minBB.X * 16), (int)(minBB.Z * 16));
            int     maxU = Math.Min((int)(maxBB.X * 16), (int)(maxBB.Z * 16));
            int     minV = (int)(16 - maxBB.Y * 16), maxV = (int)(16 - minBB.Y * 16);

            // This way we can avoid creating particles which outside the bounds and need to be clamped
            if (minU < 13 && maxU > 13)
            {
                maxU = 13;
            }
            if (minV < 13 && maxV > 13)
            {
                maxV = 13;
            }

            for (int i = 0; i < 30; i++)
            {
                double  velX     = rnd.NextDouble() * 0.8 - 0.4;            // [-0.4, 0.4]
                double  velZ     = rnd.NextDouble() * 0.8 - 0.4;
                double  velY     = rnd.NextDouble() + 0.2;
                Vector3 velocity = new Vector3((float)velX, (float)velY, (float)velZ);

                double  xOffset = rnd.NextDouble() - 0.5;                // [-0.5, 0.5]
                double  yOffset = (rnd.NextDouble() - 0.125) * maxBB.Y;
                double  zOffset = rnd.NextDouble() - 0.5;
                Vector3 pos     = startPos + new Vector3(0.5f + (float)xOffset,
                                                         (float)yOffset, 0.5f + (float)zOffset);

                TextureRec rec = baseRec;
                rec.U1 = baseRec.U1 + rnd.Next(minU, maxU) * uvScale;
                rec.V1 = baseRec.V1 + rnd.Next(minV, maxV) * uvScale;
                rec.U2 = Math.Min(baseRec.U1 + maxU * uvScale, rec.U1 + elemSize);
                rec.V2 = Math.Min(baseRec.V1 + maxV * uvScale, rec.V1 + elemSize);
                double life = 0.3 + rnd.NextDouble() * 0.7;

                TerrainParticle p = AddParticle(terrainParticles, ref terrainCount, false);
                p.ResetState(pos, velocity, life);
                p.rec = rec;
            }
        }
        protected void DoRender(Game game, ref Vector2 size, ref TextureRec rec,
                                VertexP3fT2fC4b[] vertices, ref int index)
        {
            Vector3 p111, p121, p212, p222;

            Utils.CalcBillboardPoints(size, Position, ref game.View,
                                      out p111, out p121, out p212, out p222);
            World      map = game.World;
            FastColour col = map.IsLit(Position) ? map.Env.Sunlight : map.Env.Shadowlight;

            vertices[index++] = new VertexP3fT2fC4b(p111, rec.U1, rec.V2, col);
            vertices[index++] = new VertexP3fT2fC4b(p121, rec.U1, rec.V1, col);
            vertices[index++] = new VertexP3fT2fC4b(p222, rec.U2, rec.V1, col);
            vertices[index++] = new VertexP3fT2fC4b(p212, rec.U2, rec.V2, col);
        }
Example #26
0
        void SpriteXQuad(bool firstPart, bool mirror)
        {
            int        texLoc = BlockInfo.GetTextureLoc(block, Side.Right);
            TextureRec rec    = Atlas1D.GetTexRec(texLoc, 1, out texIndex);

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

            PackedCol col = cols[0];

            if (BlockInfo.Tinted[block])
            {
                col *= BlockInfo.FogCol[block];
            }

            float x1 = 0, x2 = 0, z1 = 0, z2 = 0;

            if (firstPart)
            {
                if (mirror)
                {
                    rec.U2 = 0.5f; x2 = -5.5f / 16; z2 = 5.5f / 16;
                }
                else
                {
                    rec.U1 = 0.5f; x1 = -5.5f / 16; z1 = 5.5f / 16;
                }
            }
            else
            {
                if (mirror)
                {
                    rec.U1 = 0.5f; x1 = 5.5f / 16; z1 = -5.5f / 16;
                }
                else
                {
                    rec.U2 = 0.5f; x2 = 5.5f / 16; z2 = -5.5f / 16;
                }
            }

            cache.vertices[index++] = new VertexP3fT2fC4b(x1, 0, z1, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x1, 1, z1, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x2, 1, z2, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x2, 0, z2, rec.U1, rec.V2, col);
        }
Example #27
0
        void SpriteZQuad(bool firstPart, bool mirror)
        {
            int        texLoc = BlockInfo.GetTextureLoc(block, Side.Back);
            TextureRec rec    = Atlas1D.GetTexRec(texLoc, 1, out texIndex);

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

            PackedCol col = cols[0];

            if (BlockInfo.Tinted[block])
            {
                col *= BlockInfo.FogCol[block];
            }

            float p1 = 0, p2 = 0;

            if (firstPart)               // Need to break into two quads for when drawing a sprite model in hand.
            {
                if (mirror)
                {
                    rec.U1 = 0.5f; p1 = -5.5f / 16;
                }
                else
                {
                    rec.U2 = 0.5f; p2 = -5.5f / 16;
                }
            }
            else
            {
                if (mirror)
                {
                    rec.U2 = 0.5f; p2 = 5.5f / 16;
                }
                else
                {
                    rec.U1 = 0.5f; p1 = 5.5f / 16;
                }
            }

            cache.vertices[index++] = new VertexP3fT2fC4b(p1, 0, p1, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(p1, 1, p1, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(p2, 1, p2, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(p2, 0, p2, rec.U1, rec.V2, col);
        }
        void YQuad(float y, int side, 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.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 VertexP3fT2fC4b(minBB.X - 0.5f, y, minBB.Z - 0.5f, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(maxBB.X - 0.5f, y, minBB.Z - 0.5f, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(maxBB.X - 0.5f, y, maxBB.Z - 0.5f, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(minBB.X - 0.5f, y, maxBB.Z - 0.5f, rec.U1, rec.V2, col);
        }
Example #29
0
        void SpriteXQuad(int side, bool firstPart, bool mirror)
        {
            int        texId = game.BlockInfo.GetTextureLoc(block, side), texIndex = 0;
            TextureRec rec = atlas.GetTexRec(texId, 1, out texIndex);

            FlushIfNotSame(texIndex);
            if (height != 1)
            {
                rec.V2 = rec.V1 + height * atlas.invElementSize * (15.99f / 16f);
            }
            int col = this.col;

            float x1 = 0, x2 = 0, z1 = 0, z2 = 0;

            if (firstPart)
            {
                if (mirror)
                {
                    rec.U2 = 0.5f; x2 = -5.5f / 16; z2 = 5.5f / 16;
                }
                else
                {
                    rec.U1 = 0.5f; x1 = -5.5f / 16; z1 = 5.5f / 16;
                }
            }
            else
            {
                if (mirror)
                {
                    rec.U1 = 0.5f; x1 = 5.5f / 16; z1 = -5.5f / 16;
                }
                else
                {
                    rec.U2 = 0.5f; x2 = 5.5f / 16; z2 = -5.5f / 16;
                }
            }

            cache.vertices[index++] = new VertexP3fT2fC4b(x1, 0, z1, rec.U2, rec.V2, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x1, 1, z1, rec.U2, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x2, 1, z2, rec.U1, rec.V1, col);
            cache.vertices[index++] = new VertexP3fT2fC4b(x2, 0, z2, rec.U1, rec.V2, col);
        }
Example #30
0
        void RenderTerrain()
        {
            for (int i = 0; i < Atlas2D.TilesPerRow * Atlas2D.TilesPerRow;)
            {
                int index = 0, texIdx = 0, end = i + Atlas1D.TilesPerAtlas;

                for (; i < end; i++)
                {
                    TextureRec rec = Atlas1D.GetTexRec(i + baseTexLoc, 1, out texIdx);
                    int        x = i % Atlas2D.TilesPerRow, y = i / Atlas2D.TilesPerRow;

                    Texture tex = new Texture(0, xOffset + x * tileSize, yOffset + y * tileSize,
                                              tileSize, tileSize, rec);
                    IGraphicsApi.Make2DQuad(ref tex, PackedCol.White, vertices, ref index);
                }

                game.Graphics.BindTexture(Atlas1D.TexIds[texIdx]);
                game.Graphics.UpdateDynamicVb_IndexedTris(dynamicVb, vertices, index);
            }
        }
        void DrawPosition()
        {
            int        index = 0;
            TextureRec xy    = new TextureRec(2, posTex.Y1, baseWidth, posTex.Height);
            TextureRec uv    = new TextureRec(0, posTex.V1, posTex.U2, posTex.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);

            api.BindTexture(posTex.ID);
            api.UpdateDynamicIndexedVb(DrawMode.Triangles,
                                       game.ModelCache.vb, game.ModelCache.vertices, index, index * 6 / 4);
        }
        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);
        }
 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 );
 }
        void AddChar( int charIndex, ref int index )
        {
            int width = widths[charIndex];
            TextureRec xy = new TextureRec( curX, posTex.Y1, width, posTex.Height );
            TextureRec uv = new TextureRec( (baseWidth + charIndex * 16) / texWidth,
                                           posTex.V1, width / texWidth, posTex.V2 );

            curX += width;
            IGraphicsApi.Make2DQuad( xy, uv, game.ModelCache.vertices, ref index );
        }
        void DrawPosition()
        {
            int index = 0;
            TextureRec xy = new TextureRec( 2, posTex.Y1, baseWidth, posTex.Height );
            TextureRec uv = new TextureRec( 0, posTex.V1, posTex.U2, posTex.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 );

            api.BindTexture( posTex.ID );
            api.UpdateDynamicIndexedVb( DrawMode.Triangles,
                                       game.ModelCache.vb, game.ModelCache.vertices, index, index * 6 / 4 );
        }
        void DrawX( int x, int z1, int z2, int y1, int y2, int axisSize, FastColour col, ref VertexP3fT2fC4b* 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 VertexP3fT2fC4b( x, y1, z1, rec.U1, rec.V2, col );
                    *vertices++ = new VertexP3fT2fC4b( x, y2, z1, rec.U1, rec.V1, col );
                    *vertices++ = new VertexP3fT2fC4b( x, y2, z2, rec.U2, rec.V1, col );
                    *vertices++ = new VertexP3fT2fC4b( x, y1, z2, rec.U2, rec.V2, col );
                }
            }
        }
        void DrawY( int x1, int z1, int x2, int z2, float y, int axisSize, FastColour col, float offset, ref VertexP3fT2fC4b* 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 VertexP3fT2fC4b( x1 + offset, y + offset, z1 + offset, rec.U1, rec.V1, col );
                    *vertices++ = new VertexP3fT2fC4b( x1 + offset, y + offset, z2 + offset, rec.U1, rec.V2, col );
                    *vertices++ = new VertexP3fT2fC4b( x2 + offset, y + offset, z2 + offset, rec.U2, rec.V2, col );
                    *vertices++ = new VertexP3fT2fC4b( x2 + offset, y + offset, z1 + offset, rec.U2, rec.V1, col );
                }
            }
        }
        void DrawZ( int z, int x1, int x2, int y1, int y2, int axisSize, FastColour col, ref VertexP3fT2fC4b* 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 VertexP3fT2fC4b( x1, y1, z, rec.U1, rec.V2, col );
                    *vertices++ = new VertexP3fT2fC4b( x1, y2, z, rec.U1, rec.V1, col );
                    *vertices++ = new VertexP3fT2fC4b( x2, y2, z, rec.U2, rec.V1, col );
                    *vertices++ = new VertexP3fT2fC4b( x2, y1, z, rec.U2, rec.V2, col );
                }
            }
        }
Example #39
0
 void DraqSquareShadow( VertexP3fT2fC4b[] verts, ref int index, float y, byte alpha, float x, float z )
 {
     FastColour col = FastColour.White; col.A = alpha;
     TextureRec rec = new TextureRec( 63/128f, 63/128f, 1/128f, 1/128f );
     verts[index++] = new VertexP3fT2fC4b( x, y, z, rec.U1, rec.V1, col );
     verts[index++] = new VertexP3fT2fC4b( x + 1, y, z, rec.U2, rec.V1, col );
     verts[index++] = new VertexP3fT2fC4b( x + 1, y, z + 1, rec.U2, rec.V2, col );
     verts[index++] = new VertexP3fT2fC4b( x, y, z + 1, rec.U1, rec.V2, col );
 }
 void MakeBackgroundTexture()
 {
     TextureRec rec = new TextureRec( 0, 0, 182/256f, 22/256f );
     backTex = new Texture( 0, X, Y, Width, Height, rec );
 }
Example #41
0
 public TerrainParticle( Game game, Vector3 pos, Vector3 velocity, double lifetime, TextureRec rec )
     : base(game, pos, velocity, lifetime, rec)
 {
 }
Example #42
0
        unsafe void MakeVb()
        {
            VertexP3fT2fC4b* vertices = stackalloc VertexP3fT2fC4b[count];
            IntPtr start = (IntPtr)vertices;
            const float pos = 0.5f;
            TextureRec rec;
            FastColour col = game.World.Env.CloudsCol;

            // Render the front quad
            rec = new TextureRec( 1/4f, 1/2f, 1/4f, 1/2f );
            *vertices++ = new VertexP3fT2fC4b(  pos, -pos, -pos, rec.U1, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b( -pos, -pos, -pos, rec.U2, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b( -pos,  pos, -pos, rec.U2, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b(  pos,  pos, -pos, rec.U1, rec.V1, col );
            // Render the left quad
            rec = new TextureRec( 0/4f, 1/2f, 1/4f, 1/2f );
            *vertices++ = new VertexP3fT2fC4b(  pos, -pos,  pos, rec.U1, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b(  pos, -pos, -pos, rec.U2, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b(  pos,  pos, -pos, rec.U2, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b(  pos,  pos,  pos, rec.U1, rec.V1, col );
            // Render the back quad
            rec = new TextureRec( 3/4f, 1/2f, 1/4f, 1/2f );
            *vertices++ = new VertexP3fT2fC4b( -pos, -pos,  pos, rec.U1, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b(  pos, -pos,  pos, rec.U2, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b(  pos,  pos,  pos, rec.U2, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b( -pos,  pos,  pos, rec.U1, rec.V1, col );
            // Render the right quad
            rec = new TextureRec( 2/4f, 1/2f, 1/4f, 1/2f );
            *vertices++ = new VertexP3fT2fC4b( -pos, -pos, -pos, rec.U1, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b( -pos, -pos,  pos, rec.U2, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b( -pos,  pos,  pos, rec.U2, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b( -pos,  pos, -pos, rec.U1, rec.V1, col );
            // Render the top quad
            rec = new TextureRec( 1/4f, 0/2f, 1/4f, 1/2f );
            *vertices++ = new VertexP3fT2fC4b( -pos,  pos, -pos, rec.U2, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b( -pos,  pos,  pos, rec.U2, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b(  pos,  pos,  pos, rec.U1, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b(  pos,  pos, -pos, rec.U1, rec.V2, col );
            // Render the bottom quad
            rec = new TextureRec( 2/4f, 0/2f, 1/4f, 1/2f );
            *vertices++ = new VertexP3fT2fC4b( -pos, -pos, -pos, rec.U2, rec.V2, col );
            *vertices++ = new VertexP3fT2fC4b( -pos, -pos,  pos, rec.U2, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b(  pos, -pos,  pos, rec.U1, rec.V1, col );
            *vertices++ = new VertexP3fT2fC4b(  pos, -pos, -pos, rec.U1, rec.V2, col );
            vb = game.Graphics.CreateVb( start, VertexFormat.P3fT2fC4b, count );
        }