Exemplo n.º 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++;
                }
            }
        }
Exemplo n.º 2
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++;
                }
            }
        }
Exemplo n.º 3
0
        void DrawCoords(VertexP3fT2fC4b[] verts, ref int index, ShadowData data,
                        float x1, float z1, float x2, float z2)
        {
            Vector3 cen = entity.Position;

            if (lequal(x2, x1) || lequal(z2, z1))
            {
                return;
            }
            float u1 = (x1 - cen.X) * 16 / (radius * 2) + 0.5f;
            float v1 = (z1 - cen.Z) * 16 / (radius * 2) + 0.5f;
            float u2 = (x2 - cen.X) * 16 / (radius * 2) + 0.5f;
            float v2 = (z2 - cen.Z) * 16 / (radius * 2) + 0.5f;

            if (u2 <= 0 || v2 <= 0 || u1 >= 1 || v1 >= 1)
            {
                return;
            }

            x1 = Math.Max(x1, cen.X - radius / 16f); u1 = Math.Max(u1, 0);
            z1 = Math.Max(z1, cen.Z - radius / 16f); v1 = Math.Max(v1, 0);
            x2 = Math.Min(x2, cen.X + radius / 16f); u2 = Math.Min(u2, 1);
            z2 = Math.Min(z2, cen.Z + radius / 16f); v2 = Math.Min(v2, 1);

            int col = new FastColour(c, c, c, data.A).ToArgb();

            verts[index++] = new VertexP3fT2fC4b(x1, data.Y, z1, u1, v1, col);
            verts[index++] = new VertexP3fT2fC4b(x2, data.Y, z1, u2, v1, col);
            verts[index++] = new VertexP3fT2fC4b(x2, data.Y, z2, u2, v2, col);
            verts[index++] = new VertexP3fT2fC4b(x1, data.Y, z2, u1, v2, col);
        }
Exemplo n.º 4
0
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                float       t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;           // Inlined RotY
                v.X          *= scale; v.Y *= scale; v.Z *= scale;
                v.X          += pos.X; v.Y += pos.Y; v.Z += pos.Z;
                vertex.X      = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.Colour = part.Count == boxVertices ? cols[i >> 2] : otherCol;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * uScale;
                }
                finVertices[index++] = vertex;
            }
        }
Exemplo n.º 5
0
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                float       t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;           // Inlined RotY
                v.X *= scale; v.Y *= scale; v.Z *= scale;
                v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z;

                FastColour col = part.Count == boxVertices ?
                                 cols[i >> 2] : FastColour.Scale(this.col, 0.7f);
                vertex.X = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * uScale;
                }
                cache.vertices[index++] = vertex;
            }
        }
Exemplo n.º 6
0
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                vertex.X      = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.Colour = cols[i >> 2];

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * uScale;
                }
                finVertices[index++] = vertex;
            }
        }
        void DrawCloudsY(int x1, int z1, int x2, int z2, int y, int axisSize, int col, VertexP3fT2fC4b[] vertices)
        {
            int endX = x2, endZ = z2, startZ = z1;
            // adjust range so that largest negative uv coordinate is shifted to 0 or above.
            float offset = Utils.CeilDiv(-x1, 2048);
            int   i      = 0;

            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;
                    }

                    vertices[i++] = new VertexP3fT2fC4b(x1, y + 0.1f, z1, x1 / 2048f + offset, z1 / 2048f + offset, col);
                    vertices[i++] = new VertexP3fT2fC4b(x1, y + 0.1f, z2, x1 / 2048f + offset, z2 / 2048f + offset, col);
                    vertices[i++] = new VertexP3fT2fC4b(x2, y + 0.1f, z2, x2 / 2048f + offset, z2 / 2048f + offset, col);
                    vertices[i++] = new VertexP3fT2fC4b(x2, y + 0.1f, z1, x2 / 2048f + offset, z1 / 2048f + offset, col);
                }
            }
        }
Exemplo n.º 8
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++;
                }
            }
        }
Exemplo n.º 9
0
        void RebuildEdges(int y, int axisSize)
        {
            BlockID block = game.World.Env.EdgeBlock;

            edgesVertices = 0;
            for (int i = 0; i < rects.Length; i++)
            {
                Rectangle r = rects[i];
                edgesVertices += Utils.CountVertices(r.Width, r.Height, axisSize);                 // YPlanes outside
            }
            VertexP3fT2fC4b[] v = new VertexP3fT2fC4b[edgesVertices];
            int index           = 0;

            fullColEdge = game.BlockInfo.FullBright[block];
            int col = fullColEdge ? FastColour.WhitePacked : map.Env.Sun;

            if (game.BlockInfo.Tinted[block])
            {
                col = Utils.Tint(col, game.BlockInfo.FogColour[block]);
            }

            for (int i = 0; i < rects.Length; i++)
            {
                Rectangle r = rects[i];
                DrawY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, y, axisSize, col,
                      HorOffset(block), YOffset(block), v, ref index);
            }
            edgesVb = gfx.CreateVb(v, VertexFormat.P3fT2fC4b, edgesVertices);
        }
Exemplo n.º 10
0
        protected void DrawTransform(float dispX, float dispY, float dispZ, float rotX, float rotY, float rotZ, float scale, ModelPart part, bool head)
        {
            float cosX = (float)Math.Cos(-rotX), sinX = (float)Math.Sin(-rotX);
            float cosY = (float)Math.Cos(-rotY), sinY = (float)Math.Sin(-rotY);
            float cosZ = (float)Math.Cos(-rotZ), sinZ = (float)Math.Sin(-rotZ);

            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];

                // Prepare the vertex coordinates for rotation
                v.X -= part.RotX; v.Y -= part.RotY; v.Z -= part.RotZ;
                float t = 0;

                // Rotate locally.
                if (Rotate == RotateOrder.ZYX)
                {
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t; // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;  // Inlined RotY
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t; // Inlined RotX
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t; // Inlined RotX
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t; // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;  // Inlined RotY
                }
                else if (Rotate == RotateOrder.YZX)
                {
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;  // Inlined RotY
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t; // Inlined RotZ
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t; // Inlined RotX
                }

                // Rotate globally
                if (head)
                {
                    t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t; // Inlined RotY
                }
                //Scale box at pivot
                v.X *= scale; v.Y *= scale; v.Z *= scale;

                vertex.X = v.X + part.RotX; vertex.Y = v.Y + part.RotY; vertex.Z = v.Z + part.RotZ;
                // Translate part
                vertex.X += dispX; vertex.Y += dispY; vertex.Z += dispZ;

                vertex.Col = cols[i >> 2];

                vertex.U             = (v.U & UVMask) * uScale - (v.U >> UVMaxShift) * 0.01f * uScale;
                vertex.V             = (v.V & UVMask) * vScale - (v.V >> UVMaxShift) * 0.01f * vScale;
                finVertices[index++] = vertex;
            }
        }
Exemplo n.º 11
0
 void TransformVertices()
 {
     for (int i = 0; i < index; i++)
     {
         VertexP3fT2fC4b v = cache.vertices[i];
         float           t = 0;
         t = CosX * v.Y + SinX * v.Z; v.Z = -SinX * v.Y + CosX * v.Z; v.Y = t;                        // Inlined RotX
         cache.vertices[i] = v;
     }
 }
        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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public void InitCache()
        {
            vertices = new VertexP3fT2fC4b[24 * 12];
            vb       = api.CreateDynamicVb(VertexFormat.P3fT2fC4b, vertices.Length);
            IModel model = new HumanoidModel(game);

            model.CreateParts();
            cache["humanoid"]           = model;
            cache["human"]              = cache["humanoid"];
            game.Events.TextureChanged += TextureChanged;
        }
Exemplo n.º 15
0
 void TransformVertices()
 {
     for (int i = 0; i < index; i++)
     {
         VertexP3fT2fC4b v = cache.vertices[i];
         float           t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;       // Inlined RotY
         v.X *= scale; v.Y *= scale; v.Z *= scale;
         v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z;
         cache.vertices[i] = v;
     }
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        const byte c = 255;         // avoids 'ambiguous match' compile errors.
        static void DrawSquareShadow(VertexP3fT2fC4b[] verts, ref int index,
                                     float y, float x, float z)
        {
            PackedCol   col = new PackedCol(c, c, c, (byte)220);
            const float uv1 = 63 / 128f, uv2 = 64 / 128f;

            verts[index++] = new VertexP3fT2fC4b(x, y, z, uv1, uv1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z, uv2, uv1, col);
            verts[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, uv2, uv2, col);
            verts[index++] = new VertexP3fT2fC4b(x, y, z + 1, uv1, uv2, col);
        }
Exemplo n.º 18
0
        void RebuildSides(int y, int axisSize)
        {
            BlockID block = game.World.Env.SidesBlock;

            sidesVertices = 0;
            if (BlockInfo.Draw[block] == DrawType.Gas)
            {
                return;
            }

            for (int i = 0; i < rects.Length; i++)
            {
                Rectangle r = rects[i];
                sidesVertices += Utils.CountVertices(r.Width, r.Height, axisSize);             // YQuads outside
            }
            sidesVertices += Utils.CountVertices(map.Width, map.Length, axisSize);             // YQuads beneath map
            sidesVertices += 2 * Utils.CountVertices(map.Width, Math.Abs(y), axisSize);        // ZQuads
            sidesVertices += 2 * Utils.CountVertices(map.Length, Math.Abs(y), axisSize);       // XQuads

            VertexP3fT2fC4b[] v = new VertexP3fT2fC4b[sidesVertices];
            int index           = 0;

            fullBrightSides = BlockInfo.FullBright[block];
            int col = fullBrightSides ? FastColour.WhitePacked : map.Env.Shadow;

            if (BlockInfo.Tinted[block])
            {
                col = Utils.Tint(col, BlockInfo.FogColour[block]);
            }

            for (int i = 0; i < rects.Length; i++)
            {
                Rectangle r = rects[i];
                DrawY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, y, axisSize, col, 0, YOffset(block), v, ref index);
            }

            // Work properly for when ground level is below 0
            int y1 = 0, y2 = y;

            if (y < 0)
            {
                y1 = y; y2 = 0;
            }
            DrawY(0, 0, map.Width, map.Length, 0, axisSize, col, 0, 0, v, ref index);
            DrawZ(0, 0, map.Width, y1, y2, axisSize, col, v, ref index);
            DrawZ(map.Length, 0, map.Width, y1, y2, axisSize, col, v, ref index);
            DrawX(0, 0, map.Length, y1, y2, axisSize, col, v, ref index);
            DrawX(map.Width, 0, map.Length, y1, y2, axisSize, col, v, ref index);

            fixed(VertexP3fT2fC4b *ptr = v)
            {
                sidesVb = game.Graphics.CreateVb((IntPtr)ptr, VertexFormat.P3fT2fC4b, sidesVertices);
            }
        }
        void RebuildClouds(int extent, int axisSize)
        {
            extent = Utils.AdjViewDist(extent);
            int x1 = -extent, x2 = map.Width + extent;
            int z1 = -extent, z2 = map.Length + extent;

            cloudVertices = Utils.CountVertices(x2 - x1, z2 - z1, axisSize);

            VertexP3fT2fC4b[] vertices = new VertexP3fT2fC4b[cloudVertices];
            DrawCloudsY(x1, z1, x2, z2, map.Env.CloudHeight, axisSize, map.Env.CloudsCol.Pack(), vertices);
            cloudsVb = gfx.CreateVb(vertices, VertexFormat.P3fT2fC4b, cloudVertices);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        protected void DrawRotate(float angleX, float angleY, float angleZ, ModelPart part, bool head)
        {
            float           cosX = (float)Math.Cos(-angleX), sinX = (float)Math.Sin(-angleX);
            float           cosY = (float)Math.Cos(-angleY), sinY = (float)Math.Sin(-angleY);
            float           cosZ = (float)Math.Cos(-angleZ), sinZ = (float)Math.Sin(-angleZ);
            float           x = part.RotX, y = part.RotY, z = part.RotZ;
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                v.X -= x; v.Y -= y; v.Z -= z;
                float t = 0;

                // Rotate locally
                if (Rotate == RotateOrder.ZYX)
                {
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                }

                // Rotate globally
                if (head)
                {
                    t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t;                     // Inlined RotY
                }
                vertex.X      = v.X + x; vertex.Y = v.Y + y; vertex.Z = v.Z + z;
                vertex.Colour = cols[i >> 2];

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * vScale;
                }
                finVertices[index++] = vertex;
            }
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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 );
        }
Exemplo n.º 24
0
        void RebuildClouds(int extent, int axisSize)
        {
            extent = Utils.AdjViewDist(extent);
            int x1 = -extent, x2 = map.Width + extent;
            int z1 = -extent, z2 = map.Length + extent;

            cloudVertices = Utils.CountVertices(x2 - x1, z2 - z1, axisSize);

            VertexP3fT2fC4b[] vertices = new VertexP3fT2fC4b[cloudVertices];
            DrawCloudsY(x1, z1, x2, z2, map.Env.CloudHeight, axisSize, map.Env.CloudsCol, vertices);
            fixed(VertexP3fT2fC4b *ptr = vertices)
            {
                cloudsVb = game.Graphics.CreateVb((IntPtr)ptr, VertexFormat.P3fT2fC4b, cloudVertices);
            }
        }
        public override void Render( Game game, double delta, float t,
            VertexP3fT2fC4b[] vertices, ref int index)
        {
            Position = Vector3.Lerp( lastPos, nextPos, t );
            Vector3 p111, p121, p212, p222;
            Utils.CalcBillboardPoints( terrainSize, Position, ref game.View,
                                      out p111, out p121, out p212, out p222 );
            World map = game.World;
            FastColour col = map.IsLit( Vector3I.Floor( Position ) ) ? map.Sunlight : map.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 );
        }
Exemplo n.º 26
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 MakeRainForSquare(int x, float y, float height, int z, FastColour col, ref int index)
        {
            float worldV = vOffset + (z & 1) / 2f - (x & 0x0F) / 16f;
            float v1     = y / 6f + worldV;
            float v2     = (y + height) / 6f + worldV;

            vertices[index++] = new VertexP3fT2fC4b(x, y, z, 0, v1, col);
            vertices[index++] = new VertexP3fT2fC4b(x, y + height, z, 0, v2, col);
            vertices[index++] = new VertexP3fT2fC4b(x + 1, y + height, z + 1, 1, v2, col);
            vertices[index++] = new VertexP3fT2fC4b(x + 1, y, z + 1, 1, v1, col);

            vertices[index++] = new VertexP3fT2fC4b(x + 1, y, z, 1, v1, col);
            vertices[index++] = new VertexP3fT2fC4b(x + 1, y + height, z, 1, v2, col);
            vertices[index++] = new VertexP3fT2fC4b(x, y + height, z + 1, 0, v2, col);
            vertices[index++] = new VertexP3fT2fC4b(x, y, z + 1, 0, v1, col);
        }
Exemplo n.º 28
0
 void ZQuad2(float z, float x1, float y1, float x2, float y2, float u, float v, bool flip)
 {
     if (!flip)
     {
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y1, z, 0, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y2, z, 0, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y2, z, u, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y1, z, u, v, col2);
     }
     else
     {
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y1, z, 0, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y2, z, 0, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y2, z, u, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y1, z, u, v, col2);
     }
 }
Exemplo n.º 29
0
 void YQuad2(float y, float x1, float z1, float x2, float z2, float u, float v, bool flip)
 {
     if (!flip)
     {
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y, z1, 0, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y, z2, 0, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y, z2, u, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y, z1, u, 0, col2);
     }
     else
     {
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y, z1, 0, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x2, y, z2, 0, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y, z2, u, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x1, y, z1, u, 0, col2);
     }
 }
Exemplo n.º 30
0
 void XQuad2(float x, float z1, float y1, float z2, float y2, float u, float v, bool flip)
 {
     if (!flip)
     {
         vertices2[index2++] = new VertexP3fT2fC4b(x, y1, z1, 0, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x, y2, z1, 0, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x, y2, z2, u, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x, y1, z2, u, v, col2);
     }
     else
     {
         vertices2[index2++] = new VertexP3fT2fC4b(x, y1, z2, 0, v, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x, y2, z2, 0, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x, y2, z1, u, 0, col2);
         vertices2[index2++] = new VertexP3fT2fC4b(x, y1, z1, u, v, col2);
     }
 }
Exemplo n.º 31
0
        private void DrawTranslate(float dispX, float dispY, float dispZ, ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                vertex.X   = v.X + dispX; vertex.Y = v.Y + dispY; vertex.Z = v.Z + dispZ;
                vertex.Col = cols[i >> 2];

                vertex.U             = (v.U & UVMask) * uScale - (v.U >> UVMaxShift) * 0.01f * uScale;
                vertex.V             = (v.V & UVMask) * vScale - (v.V >> UVMaxShift) * 0.01f * vScale;
                finVertices[index++] = vertex;
            }
        }
Exemplo n.º 32
0
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                vertex.X      = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.Colour = cols[i >> 2];

                vertex.U             = (v.U & UVMask) * uScale - (v.U >> UVMaxShift) * 0.01f * uScale;
                vertex.V             = (v.V & UVMask) * vScale - (v.V >> UVMaxShift) * 0.01f * vScale;
                finVertices[index++] = vertex;
            }
        }
        void DrawBackground()
        {
            VertexP3fT2fC4b[] vertices = game.ModelCache.vertices;
            int index = 0, atlasIndex = 0;
            int drawnY = 0, height = game.Height;
            FastColour col = new FastColour( 64, 64, 64 );

            int texLoc = game.BlockInfo.GetTextureLoc( (byte)Block.Dirt, Side.Top );
            TerrainAtlas1D atlas = game.TerrainAtlas1D;
            TextureRec tex = atlas.GetTexRec( texLoc, 1, out atlasIndex );
            tex.U2 = (float)game.Width / 64;
            bool bound = false;

            while( drawnY < height ) {
                float x1 = 0, x2 = game.Width;
                float y1 = drawnY, y2 = drawnY + 64;
                #if USE_DX
                // NOTE: see "https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx",
                // i.e. the msdn article called "Directly Mapping Texels to Pixels (Direct3D 9)" for why we have to do this.
                x1 -= 0.5f; x2 -= 0.5f;
                y1 -= 0.5f; y2 -= 0.5f;
                #endif

                vertices[index++] = new VertexP3fT2fC4b( x1, y1, 0, tex.U1, tex.V1, col );
                vertices[index++] = new VertexP3fT2fC4b( x2, y1, 0, tex.U2, tex.V1, col );
                vertices[index++] = new VertexP3fT2fC4b( x2, y2, 0, tex.U2, tex.V2, col );
                vertices[index++] = new VertexP3fT2fC4b( x1, y2, 0, tex.U1, tex.V2, col );
                if( index >= vertices.Length )
                    DrawBackgroundVertices( ref index, atlasIndex, ref bound );
                drawnY += 64;
            }
            DrawBackgroundVertices( ref index, atlasIndex, ref bound );
        }
        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 );
                }
            }
        }
Exemplo n.º 36
0
 public override void Render( Game game, double delta, float t,
     VertexP3fT2fC4b[] vertices, ref int index)
 {
     Position = Vector3.Lerp( lastPos, nextPos, t );
     Vector2 size = Big ? bigSize : (Tiny ? tinySize : smallSize);
     DoRender( game, ref size, ref rec, vertices, ref index );
 }
        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 );
                }
            }
        }
Exemplo n.º 38
0
        void ResetClouds( int extent, int axisSize )
        {
            extent = Utils.AdjViewDist( extent );
            int x1 = -extent, x2 = map.Width + extent;
            int z1 = -extent, z2 = map.Length + extent;
            cloudVertices = Utils.CountVertices( x2 - x1, z2 - z1, axisSize );

            VertexP3fT2fC4b[] vertices = new VertexP3fT2fC4b[cloudVertices];
            DrawCloudsY( x1, z1, x2, z2, map.Env.CloudHeight, axisSize, map.Env.CloudsCol, vertices );
            cloudsVb = graphics.CreateVb( vertices, VertexFormat.P3fT2fC4b, cloudVertices );
        }
        void MakeRainForSquare( int x, float y, float height, int z, FastColour col, ref int index )
        {
            float worldV = vOffset + (z & 1) / 2f - (x & 0x0F) / 16f;
            float v1 = y / 6f + worldV;
            float v2 = (y + height) / 6f + worldV;

            vertices[index++] = new VertexP3fT2fC4b( x, y, z, 0, v2, col );
            vertices[index++] = new VertexP3fT2fC4b( x, y + height, z, 0, v1, col );
            vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z + 1, 2, v1, col );
            vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z + 1, 2, v2, col );

            vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z, 2, v2, col );
            vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z, 2, v1, col );
            vertices[index++] = new VertexP3fT2fC4b( x, y + height, z + 1, 0, v1, col );
            vertices[index++] = new VertexP3fT2fC4b( x, y, z + 1, 0, v2, col );
        }
Exemplo n.º 40
0
        void DrawCloudsY( int x1, int z1, int x2, int z2, int y, int axisSize, FastColour col, VertexP3fT2fC4b[] vertices )
        {
            int endX = x2, endZ = z2, startZ = z1;
            // adjust range so that largest negative uv coordinate is shifted to 0 or above.
            float offset = Utils.CeilDiv( -x1, 2048 );
            int i = 0;

            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;

                    vertices[i++] = new VertexP3fT2fC4b( x1, y + 0.1f, z1, x1 / 2048f + offset, z1 / 2048f + offset, col );
                    vertices[i++] = new VertexP3fT2fC4b( x1, y + 0.1f, z2, x1 / 2048f + offset, z2 / 2048f + offset, col );
                    vertices[i++] = new VertexP3fT2fC4b( x2, y + 0.1f, z2, x2 / 2048f + offset, z2 / 2048f + offset, col );
                    vertices[i++] = new VertexP3fT2fC4b( x2, y + 0.1f, z1, x2 / 2048f + offset, z1 / 2048f + offset, col );
                }
            }
        }
Exemplo n.º 41
0
        void DrawCoords( VertexP3fT2fC4b[] verts, ref int index, ShadowData data, 
            float x1, float z1, float x2, float z2)
        {
            Vector3 centre = entity.Position;
            BlockInfo info = game.BlockInfo;

            if( lequal( x2, x1 ) || lequal( z2, z1 ) ) return;
            float u1 = (x1 - centre.X) * 16/14f + 0.5f;
            float v1 = (z1 - centre.Z) * 16/14f + 0.5f;
            float u2 = (x2 - centre.X) * 16/14f + 0.5f;
            float v2 = (z2 - centre.Z) * 16/14f + 0.5f;
            if( u2 <= 0 || v2 <= 0 || u1 >= 1 || v1 >= 1 ) return;

            x1 = Math.Max( x1, centre.X - 7/16f ); u1 = Math.Max( u1, 0 );
            z1 = Math.Max( z1, centre.Z - 7/16f ); v1 = Math.Max( v1, 0 );
            x2 = Math.Min( x2, centre.X + 7/16f ); u2 = Math.Min( u2, 1 );
            z2 = Math.Min( z2, centre.Z + 7/16f ); v2 = Math.Min( v2, 1 );

            FastColour col = FastColour.White; col.A = data.A;
            verts[index++] = new VertexP3fT2fC4b( x1, data.Y, z1, u1, v1, col );
            verts[index++] = new VertexP3fT2fC4b( x2, data.Y, z1, u2, v1, col );
            verts[index++] = new VertexP3fT2fC4b( x2, data.Y, z2, u2, v2, col );
            verts[index++] = new VertexP3fT2fC4b( x1, data.Y, z2, u1, v2, col );
        }
Exemplo n.º 42
0
        void DrawCircle( VertexP3fT2fC4b[] verts, ref int index, 
            ShadowData* data, int dataCount, float x, float z)
        {
            x = Utils.Floor( x ); z = Utils.Floor( z );
            BlockInfo info = game.BlockInfo;
            Vector3 min = info.MinBB[data[0].Block], max = info.MaxBB[data[0].Block];

            DrawCoords( verts, ref index, data[0], x + min.X, z + min.Z, x + max.X, z + max.Z );
            for( int i = 1; i < dataCount; i++ ) {
                Vector3 nMin = info.MinBB[data[i].Block], nMax = info.MaxBB[data[i].Block];
                DrawCoords( verts, ref index, data[i], x + min.X, z + nMin.Z, x + max.X, z + min.Z );
                DrawCoords( verts, ref index, data[i], x + min.X, z + max.Z, x + max.X, z + nMax.Z );

                DrawCoords( verts, ref index, data[i], x + nMin.X, z + nMin.Z, x + min.X, z + nMax.Z );
                DrawCoords( verts, ref index, data[i], x + max.X, z + nMin.Z, x + nMax.X, z + nMax.Z );
                min = nMin; max = nMax;
            }
        }
Exemplo n.º 43
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 );
 }
Exemplo n.º 44
0
 public override void Render( Game game, double delta, float t,
     VertexP3fT2fC4b[] vertices, ref int index)
 {
     Position = Vector3.Lerp( lastPos, nextPos, t );
     DoRender( game, ref terrainSize, ref rec, vertices, ref index );
 }
Exemplo n.º 45
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 );
        }
Exemplo n.º 46
0
 public abstract void Render( Game game, double delta, float t,
     VertexP3fT2fC4b[] vertices, ref int index);