Beispiel #1
0
        void DrawBackground()
        {
            VertexP3fT2fC4b[] vertices = game.ModelCache.vertices;
            int       index = 0, atlasIndex = 0;
            int       drawnY = 0, height = game.Height;
            PackedCol col = new PackedCol(64, 64, 64);

            int     texLoc = BlockInfo.GetTextureLoc(Block.Dirt, Side.Top);
            Texture tex   = new Texture(0, 0, 0, game.Width, 64,
                                        Atlas1D.GetTexRec(texLoc, 1, out atlasIndex));

            tex.U2 = (float)game.Width / 64;
            bool bound = false;

            while (drawnY < height)
            {
                tex.Y1 = drawnY;
                IGraphicsApi.Make2DQuad(ref tex, col, vertices, ref index);
                if (index >= vertices.Length)
                {
                    DrawBackgroundVertices(ref index, atlasIndex, ref bound);
                }
                drawnY += 64;
            }
            DrawBackgroundVertices(ref index, atlasIndex, ref bound);
        }
Beispiel #2
0
        public static void Vertical(FastBitmap bmp, Rectangle rect,
                                    PackedCol a, PackedCol b)
        {
            int x, y, width, height;

            if (!Drawer2DExt.ClampCoords(bmp, rect, out x, out y,
                                         out width, out height))
            {
                return;
            }
            PackedCol c = a;

            for (int yy = 0; yy < height; yy++)
            {
                int * row = bmp.GetRowPtr(y + yy);
                float t   = (float)yy / (height - 1);               // so last row has b as its colour

                c.R = (byte)Utils.Lerp(a.R, b.R, t);
                c.G = (byte)Utils.Lerp(a.G, b.G, t);
                c.B = (byte)Utils.Lerp(a.B, b.B, t);
                int pixel = c.ToArgb();

                for (int xx = 0; xx < width; xx++)
                {
                    row[x + xx] = pixel;
                }
            }
        }
Beispiel #3
0
        public void Render(double delta, VertexP3fC4b[] vertices, VertexP3fC4b[] lineVertices,
                           ref int index, ref int lineIndex)
        {
            float     offset = MinDist < 32 * 32 ? 1 / 32f : 1 / 16f;
            Vector3   offsetV = new Vector3(offset, offset, offset);
            Vector3   p1 = Min - offsetV, p2 = Max + offsetV;
            PackedCol col = Colour;

            HorQuad(vertices, ref index, col, p1.X, p1.Z, p2.X, p2.Z, p1.Y);             // bottom
            HorQuad(vertices, ref index, col, p1.X, p1.Z, p2.X, p2.Z, p2.Y);             // top
            VerQuad(vertices, ref index, col, p1.X, p1.Y, p1.Z, p2.X, p2.Y, p1.Z);       // sides
            VerQuad(vertices, ref index, col, p1.X, p1.Y, p2.Z, p2.X, p2.Y, p2.Z);
            VerQuad(vertices, ref index, col, p1.X, p1.Y, p1.Z, p1.X, p2.Y, p2.Z);
            VerQuad(vertices, ref index, col, p2.X, p1.Y, p1.Z, p2.X, p2.Y, p2.Z);

            col = new PackedCol((byte)~Colour.R, (byte)~Colour.G, (byte)~Colour.B);
            // bottom face
            Line(lineVertices, ref lineIndex, p1.X, p1.Y, p1.Z, p2.X, p1.Y, p1.Z, col);
            Line(lineVertices, ref lineIndex, p2.X, p1.Y, p1.Z, p2.X, p1.Y, p2.Z, col);
            Line(lineVertices, ref lineIndex, p2.X, p1.Y, p2.Z, p1.X, p1.Y, p2.Z, col);
            Line(lineVertices, ref lineIndex, p1.X, p1.Y, p2.Z, p1.X, p1.Y, p1.Z, col);
            // top face
            Line(lineVertices, ref lineIndex, p1.X, p2.Y, p1.Z, p2.X, p2.Y, p1.Z, col);
            Line(lineVertices, ref lineIndex, p2.X, p2.Y, p1.Z, p2.X, p2.Y, p2.Z, col);
            Line(lineVertices, ref lineIndex, p2.X, p2.Y, p2.Z, p1.X, p2.Y, p2.Z, col);
            Line(lineVertices, ref lineIndex, p1.X, p2.Y, p2.Z, p1.X, p2.Y, p1.Z, col);
            // side faces
            Line(lineVertices, ref lineIndex, p1.X, p1.Y, p1.Z, p1.X, p2.Y, p1.Z, col);
            Line(lineVertices, ref lineIndex, p2.X, p1.Y, p1.Z, p2.X, p2.Y, p1.Z, col);
            Line(lineVertices, ref lineIndex, p2.X, p1.Y, p2.Z, p2.X, p2.Y, p2.Z, col);
            Line(lineVertices, ref lineIndex, p1.X, p1.Y, p2.Z, p1.X, p2.Y, p2.Z, col);
        }
Beispiel #4
0
        void HandleEnvColours()
        {
            byte      variable = reader.ReadUInt8();
            ushort    r        = reader.ReadUInt16();
            ushort    g        = reader.ReadUInt16();
            ushort    b        = reader.ReadUInt16();
            bool      invalid  = r > 255 || g > 255 || b > 255;
            PackedCol col      = new PackedCol(r, g, b);

            if (variable == 0)
            {
                game.World.Env.SetSkyCol(invalid ? WorldEnv.DefaultSkyCol : col);
            }
            else if (variable == 1)
            {
                game.World.Env.SetCloudsCol(invalid ? WorldEnv.DefaultCloudsCol : col);
            }
            else if (variable == 2)
            {
                game.World.Env.SetFogCol(invalid ? WorldEnv.DefaultFogCol : col);
            }
            else if (variable == 3)
            {
                game.World.Env.SetShadowCol(invalid ? WorldEnv.DefaultShadowlight : col);
            }
            else if (variable == 4)
            {
                game.World.Env.SetSunCol(invalid ? WorldEnv.DefaultSunlight : col);
            }
        }
        void DrawZ(int z, int x1, int x2, int y1, int y2, int axisSize,
                   PackedCol col, VertexP3fT2fC4b[] vertices, ref int i)
        {
            int             endX = x2, endY = y2, startY = y1;
            VertexP3fT2fC4b v;

            v.Z = z; v.Col = col;

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

                    float u2 = x2 - x1, v2 = y2 - y1;
                    v.X = x1; v.Y = y1; v.U = 0f; v.V = v2; vertices[i++] = v;
                    v.Y = y2;           v.V = 0f; vertices[i++] = v;
                    v.X = x2;           v.U = u2;           vertices[i++] = v;
                    v.Y = y1;           v.V = v2; vertices[i++] = v;
                }
            }
        }
Beispiel #6
0
        static 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) * uvScale + 0.5f;
            float v1 = (z1 - cen.Z) * uvScale + 0.5f;
            float u2 = (x2 - cen.X) * uvScale + 0.5f;
            float v2 = (z2 - cen.Z) * uvScale + 0.5f;

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

            x1 = Math.Max(x1, cen.X - radius); u1 = u1 >= 0 ? u1 : 0;
            z1 = Math.Max(z1, cen.Z - radius); v1 = v1 >= 0 ? v1 : 0;
            x2 = Math.Min(x2, cen.X + radius); u2 = u2 <= 1 ? u2 : 1;
            z2 = Math.Min(z2, cen.Z + radius); v2 = v2 <= 1 ? v2 : 1;

            PackedCol       col    = new PackedCol(c, c, c, data.A);
            VertexP3fT2fC4b v; v.Y = data.Y; v.Col = col;

            v.X = x1; v.Z = z1; v.U = u1; v.V = v1; verts[index++] = v;
            v.X = x2;           v.U = u2;           verts[index++] = v;
            v.Z = z2;           v.V = v2; verts[index++] = v;
            v.X = x1;           v.U = u1;           verts[index++] = v;
        }
Beispiel #7
0
        void DrawSkyY(int x1, int z1, int x2, int z2, int y, int axisSize,
                      PackedCol col, VertexP3fC4b[] vertices)
        {
            int          endX = x2, endZ = z2, startZ = z1;
            int          i = 0;
            VertexP3fC4b v;

            v.Y = y; v.Col = col;

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

                    v.X = x1; v.Z = z1; vertices[i++] = v;
                    v.Z = z2; vertices[i++] = v;
                    v.X = x2;           vertices[i++] = v;
                    v.Z = z1; vertices[i++] = v;
                }
            }
        }
        unsafe void WriteBlockDefinitionCompound(byte id)
        {
            nbt.Write(NbtTagType.Compound, "Block" + id);
            bool sprite = BlockInfo.Draw[id] == DrawType.Sprite;

            nbt.Write(NbtTagType.Int8, "ID");
            nbt.WriteUInt8(id);
            nbt.Write(NbtTagType.String, "Name");
            nbt.Write(BlockInfo.Name[id]);
            nbt.Write(NbtTagType.Int8, "CollideType");
            nbt.WriteUInt8((byte)BlockInfo.Collide[id]);
            float speed = BlockInfo.SpeedMultiplier[id];

            nbt.Write(NbtTagType.Real32, "Speed");
            nbt.WriteInt32(*((int *)&speed));

            nbt.Write(NbtTagType.Int8Array, "Textures");
            nbt.WriteInt32(6);
            nbt.WriteUInt8(BlockInfo.GetTextureLoc(id, Side.Top));
            nbt.WriteUInt8(BlockInfo.GetTextureLoc(id, Side.Bottom));
            nbt.WriteUInt8(BlockInfo.GetTextureLoc(id, Side.Left));
            nbt.WriteUInt8(BlockInfo.GetTextureLoc(id, Side.Right));
            nbt.WriteUInt8(BlockInfo.GetTextureLoc(id, Side.Front));
            nbt.WriteUInt8(BlockInfo.GetTextureLoc(id, Side.Back));

            nbt.Write(NbtTagType.Int8, "TransmitsLight");
            nbt.WriteUInt8(BlockInfo.BlocksLight[id] ? 0 : 1);
            nbt.Write(NbtTagType.Int8, "WalkSound");
            nbt.WriteUInt8(BlockInfo.DigSounds[id]);
            nbt.Write(NbtTagType.Int8, "FullBright");
            nbt.WriteUInt8(BlockInfo.FullBright[id] ? 1 : 0);

            nbt.Write(NbtTagType.Int8, "Shape");
            int shape = sprite ? 0 : (int)(BlockInfo.MaxBB[id].Y * 16);

            nbt.WriteUInt8(shape);
            nbt.Write(NbtTagType.Int8, "BlockDraw");
            byte draw = sprite ? BlockInfo.SpriteOffset[id] : BlockInfo.Draw[id];

            nbt.WriteUInt8(draw);

            PackedCol col = BlockInfo.FogCol[id];

            nbt.Write(NbtTagType.Int8Array, "Fog");
            nbt.WriteInt32(4);
            byte fog = (byte)(128 * BlockInfo.FogDensity[id] - 1);

            nbt.WriteUInt8(BlockInfo.FogDensity[id] == 0 ? (byte)0 : fog);
            nbt.WriteUInt8(col.R); nbt.WriteUInt8(col.G); nbt.WriteUInt8(col.B);

            Vector3 min = BlockInfo.MinBB[id], max = BlockInfo.MaxBB[id];

            nbt.Write(NbtTagType.Int8Array, "Coords");
            nbt.WriteInt32(6);
            nbt.WriteUInt8((byte)(min.X * 16)); nbt.WriteUInt8((byte)(min.Y * 16));
            nbt.WriteUInt8((byte)(min.Z * 16)); nbt.WriteUInt8((byte)(max.X * 16));
            nbt.WriteUInt8((byte)(max.Y * 16)); nbt.WriteUInt8((byte)(max.Z * 16));

            nbt.Write(NbtTagType.End);
        }
        void DrawY(int x1, int z1, int x2, int z2, float y, int axisSize,
                   PackedCol col, float offset, float yOffset, VertexP3fT2fC4b[] vertices, ref int i)
        {
            int             endX = x2, endZ = z2, startZ = z1;
            VertexP3fT2fC4b v;

            v.Y = y + yOffset; v.Col = col;

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

                    float u2 = x2 - x1, v2 = z2 - z1;
                    v.X = x1 + offset; v.Z = z1 + offset; v.U = 0f; v.V = 0f; vertices[i++] = v;
                    v.Z = z2 + offset;           v.V = v2; vertices[i++] = v;
                    v.X = x2 + offset;                    v.U = u2;           vertices[i++] = v;
                    v.Z = z1 + offset;           v.V = 0f; vertices[i++] = v;
                }
            }
        }
Beispiel #10
0
        void UpdateFogNormal(float fogDensity, PackedCol fogCol)
        {
            IGraphicsApi gfx = game.Graphics;

            if (fogDensity != 0)
            {
                gfx.SetFogMode(Fog.Exp);
                gfx.SetFogDensity(fogDensity);
            }
            else if (game.World.Env.ExpFog)
            {
                gfx.SetFogMode(Fog.Exp);
                // f = 1-z/end   f = e^(-dz)
                //   solve for f = 0.01 gives:
                // e^(-dz)=0.01 --> -dz=ln(0.01)
                // 0.99=z/end   --> z=end*0.99
                //   therefore
                // d = -ln(0.01)/(end*0.99)

                const double log001  = -4.60517018598809;
                double       density = -log001 / (game.ViewDistance * 0.99);
                gfx.SetFogDensity((float)density);
            }
            else
            {
                gfx.SetFogMode(Fog.Linear);
                gfx.SetFogEnd(game.ViewDistance);
            }
            gfx.SetFogCol(fogCol);
        }
Beispiel #11
0
        public override void Render(double delta)
        {
            IGraphicsApi gfx = game.Graphics;
            int          x = X, width = Width;

            gfx.Draw2DQuad(x, Y, width, Height, scrollBackCol);

            int y, height;

            GetScrollbarCoords(out y, out height);
            x += scrollBorder; width -= scrollBorder * 2; y += Y;

            bool hovered = Mouse.Y >= y && Mouse.Y < (y + height) &&
                           Mouse.X >= x && Mouse.X < (x + width);
            PackedCol barCol = hovered ? scrollHoverCol : scrollBarCol;

            gfx.Draw2DQuad(x, y, width, height, barCol);

            if (height < 20)
            {
                return;
            }
            x += nubsWidth; width -= nubsWidth * 2; y += (height / 2);

            gfx.Draw2DQuad(x, y - 1 - 4, width, scrollBorder, scrollBackCol);
            gfx.Draw2DQuad(x, y - 1, width, scrollBorder, scrollBackCol);
            gfx.Draw2DQuad(x, y - 1 + 4, width, scrollBorder, scrollBackCol);
        }
Beispiel #12
0
        void DrawClassic(IDrawer2D drawer)
        {
            PackedCol highlightCol = Active ? new PackedCol(189, 198, 255) : new PackedCol(168, 168, 168);

            drawer.Clear(highlightCol, X + border * 2, Y + border, Width - border * 4, border);
            drawer.Clear(highlightCol, X + border, Y + border * 2, border, Height - border * 4);
        }
Beispiel #13
0
        void HandleMakeSelection()
        {
            byte   selectionId = reader.ReadUInt8();
            string label       = reader.ReadString();

            Vector3I p1;

            p1.X = reader.ReadInt16();
            p1.Y = reader.ReadInt16();
            p1.Z = reader.ReadInt16();

            Vector3I p2;

            p2.X = reader.ReadInt16();
            p2.Y = reader.ReadInt16();
            p2.Z = reader.ReadInt16();

            byte r = (byte)reader.ReadUInt16();
            byte g = (byte)reader.ReadUInt16();
            byte b = (byte)reader.ReadUInt16();
            byte a = (byte)reader.ReadUInt16();

            PackedCol col = new PackedCol(r, g, b, a);

            game.SelectionManager.AddSelection(selectionId, p1, p2, col);
        }
        void DrawX(int x, int z1, int z2, int y1, int y2, int axisSize,
                   PackedCol col, VertexP3fT2fC4b[] vertices, ref int i)
        {
            int             endZ = z2, endY = y2, startY = y1;
            VertexP3fT2fC4b v;

            v.X = x; v.Col = col;

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

                    float u2 = z2 - z1, v2 = y2 - y1;
                    v.Y = y1; v.Z = z1; v.U = 0f; v.V = v2; vertices[i++] = v;
                    v.Y = y2;                     v.V = 0f; vertices[i++] = v;
                    v.Z = z2; v.U = u2;           vertices[i++] = v;
                    v.Y = y1;                     v.V = v2; vertices[i++] = v;
                }
            }
        }
Beispiel #15
0
        static void CheckShadowTexture(IGraphicsApi gfx)
        {
            if (shadowTex != 0)
            {
                return;
            }
            const int size = 128, half = size / 2;

            using (Bitmap bmp = Platform.CreateBmp(size, size))
                using (FastBitmap fastBmp = new FastBitmap(bmp, true, false))
                {
                    int inPix  = new PackedCol(0, 0, 0, 200).ToArgb();
                    int outPix = new PackedCol(0, 0, 0, 0).ToArgb();
                    for (int y = 0; y < fastBmp.Height; y++)
                    {
                        int *row = fastBmp.GetRowPtr(y);
                        for (int x = 0; x < fastBmp.Width; x++)
                        {
                            double dist = (half - (x + 0.5)) * (half - (x + 0.5)) +
                                          (half - (y + 0.5)) * (half - (y + 0.5));
                            row[x] = dist < half * half ? inPix : outPix;
                        }
                    }
                    shadowTex = gfx.CreateTexture(fastBmp, false, false);
                }
        }
Beispiel #16
0
        public static void Noise(FastBitmap bmp, Rectangle rect,
                                 PackedCol col, int variation)
        {
            int x, y, width, height;

            if (!Drawer2DExt.ClampCoords(bmp, rect, out x, out y,
                                         out width, out height))
            {
                return;
            }

            const int alpha = 255 << 24;

            for (int yy = 0; yy < height; yy++)
            {
                int *row = bmp.GetRowPtr(y + yy);
                for (int xx = 0; xx < width; xx++)
                {
                    int n = (x + xx) + (y + yy) * 57;
                    n = (n << 13) ^ n;
                    float noise = 1f - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824f;

                    int r = col.R + (int)(noise * variation);
                    r = r < 0 ? 0 : (r > 255 ? 255 : r);
                    int g = col.G + (int)(noise * variation);
                    g = g < 0 ? 0 : (g > 255 ? 255 : g);
                    int b = col.B + (int)(noise * variation);
                    b           = b < 0 ? 0 : (b > 255 ? 255 : b);
                    row[x + xx] = alpha | (r << 16) | (g << 8) | b;
                }
            }
        }
Beispiel #17
0
        public void AddSelection(byte id, Vector3I p1, Vector3I p2, PackedCol col)
        {
            RemoveSelection(id);
            SelectionBox selection = new SelectionBox(p1, p2, col);

            selection.ID = id;
            selections.Add(selection);
        }
Beispiel #18
0
 public static void ResetToDefault()
 {
     BackgroundCol       = new PackedCol(153, 127, 172);
     ButtonBorderCol     = new PackedCol(97, 81, 110);
     ButtonForeActiveCol = new PackedCol(189, 168, 206);
     ButtonForeCol       = new PackedCol(141, 114, 165);
     ButtonHighlightCol  = new PackedCol(162, 131, 186);
 }
Beispiel #19
0
        public virtual void Draw2DTexture(ref Texture tex, PackedCol col)
        {
            int index = 0;

            Make2DQuad(ref tex, col, texVerts, ref index);
            SetBatchFormat(VertexFormat.P3fT2fC4b);
            UpdateDynamicVb_IndexedTris(texVb, texVerts, 4);
        }
 public override void ClearCol(PackedCol col)
 {
     if (col != lastClearCol)
     {
         GL.ClearColor(col.R / 255f, col.G / 255f, col.B / 255f, col.A / 255f);
         lastClearCol = col;
     }
 }
Beispiel #21
0
        static PackedCol Expand(PackedCol a, int amount)
        {
            int r = a.R + amount; Utils.Clamp(ref r, 0, 255);
            int g = a.G + amount; Utils.Clamp(ref g, 0, 255);
            int b = a.B + amount; Utils.Clamp(ref b, 0, 255);

            return(new PackedCol(r, g, b));
        }
Beispiel #22
0
        static void Line(VertexP3fC4b[] vertices, ref int index, float x1, float y1, float z1,
                         float x2, float y2, float z2, PackedCol col)
        {
            VertexP3fC4b v; v.Col = col;

            v.X = x1; v.Y = y1; v.Z = z1; vertices[index++] = v;
            v.X = x2; v.Y = y2; v.Z = z2; vertices[index++] = v;
        }
Beispiel #23
0
        void DrawTopFace(int count)
        {
            int   texId   = BlockInfo.textures[curBlock * Side.Sides + Side.Top];
            int   i       = texId >> Atlas1D.Shift;
            float vOrigin = (texId & Atlas1D.Mask) * Atlas1D.invTileSize;
            int   offset  = (lightFlags >> Side.Top) & 1;

            float     u1 = minBB.X, u2 = (count - 1) + maxBB.X * 15.99f / 16f;
            float     v1   = vOrigin + maxBB.Y * Atlas1D.invTileSize;
            float     v2   = vOrigin + minBB.Y * Atlas1D.invTileSize * 15.99f / 16f;
            DrawInfo  part = isTranslucent ? translucentParts[i] : normalParts[i];
            PackedCol col  = fullBright ? PackedCol.White : light.LightCol_YTop_Fast(X, (Y + 1) - offset, Z);

            if (tinted)
            {
                col *= BlockInfo.FogCol[curBlock];
            }

            float y2_x1z1 = y2, y2_x1z2 = y2, y2_x2z1 = y2, y2_x2z2 = y2;

            if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownXMax)
            {
                y2_x2z1 = y1; y2_x2z2 = y1;
                if (!fullBright)
                {
                    col = PackedCol.Scale(col, 0.8f);
                }
            }
            else if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownXMin)
            {
                y2_x1z1 = y1; y2_x1z2 = y1;
                if (!fullBright)
                {
                    col = PackedCol.Scale(col, 0.8f);
                }
            }
            else if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownZMin)
            {
                y2_x1z1 = y1; y2_x2z1 = y1;
                if (!fullBright)
                {
                    col = PackedCol.Scale(col, 0.9f);
                }
            }
            else if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownZMax)
            {
                y2_x1z2 = y1; y2_x2z2 = y1;
                if (!fullBright)
                {
                    col = PackedCol.Scale(col, 0.9f);
                }
            }

            vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x2 + (count - 1), y2_x2z1, z1, u2, v1, col);
            vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x1, y2_x1z1, z1, u1, v1, col);
            vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x1, y2_x1z2, z2, u1, v2, col);
            vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x2 + (count - 1), y2_x2z2, z2, u2, v2, col);
        }
Beispiel #24
0
 void ResetLight()
 {
     Shadow = DefaultShadowlight;
     PackedCol.GetShaded(Shadow, out ShadowXSide,
                         out ShadowZSide, out ShadowYBottom);
     Sun = DefaultSunlight;
     PackedCol.GetShaded(Sun, out SunXSide,
                         out SunZSide, out SunYBottom);
 }
Beispiel #25
0
        void DrawBorder(IDrawer2D drawer)
        {
            PackedCol backCol = Window.ClassicBackground ? PackedCol.Black : LauncherSkin.ButtonBorderCol;

            drawer.Clear(backCol, X + border, Y, Width - border * 2, border);
            drawer.Clear(backCol, X + border, Y + Height - border, Width - border * 2, border);
            drawer.Clear(backCol, X, Y + border, border, Height - border * 2);
            drawer.Clear(backCol, X + Width - border, Y + border, border, Height - border * 2);
        }
Beispiel #26
0
        void IGameComponent.Init(Game game)
        {
            this.game = game;
            col       = new PackedCol(0, 0, 0, 102);

            ContextRecreated();
            game.Graphics.ContextLost      += ContextLost;
            game.Graphics.ContextRecreated += ContextRecreated;
        }
Beispiel #27
0
 void MakeRGBTriplet(PackedCol defCol, bool force, int y)
 {
     MakeInput(GetCol(defCol.R, force), 55, false, 3, null)
     .SetLocation(Anchor.Centre, Anchor.Centre, 30, y);
     MakeInput(GetCol(defCol.G, force), 55, false, 3, null)
     .SetLocation(Anchor.Centre, Anchor.Centre, 95, y);
     MakeInput(GetCol(defCol.B, force), 55, false, 3, null)
     .SetLocation(Anchor.Centre, Anchor.Centre, 160, y);
 }
Beispiel #28
0
 public override void SetFogCol(PackedCol col)
 {
     if (col != lastFogCol)
     {
         Vector4 colRGBA = new Vector4(col.R / 255f, col.G / 255f, col.B / 255f, col.A / 255f);
         GL.Fog(All.FogColor, &colRGBA.X);
         lastFogCol = col;
     }
 }
Beispiel #29
0
        public void Render(Game game, float t, VertexP3fT2fC4b[] vertices, ref int index)
        {
            Vector3 pos          = Vector3.Lerp(lastPos, nextPos, t);
            Vector2 size; size.X = Size * 0.015625f; size.Y = size.X;

            int       x = Utils.Floor(pos.X), y = Utils.Floor(pos.Y), z = Utils.Floor(pos.Z);
            PackedCol col = game.World.IsValidPos(x, y, z) ? game.Lighting.LightCol(x, y, z) : game.Lighting.Outside;

            DoRender(ref game.Graphics.View, ref size, ref pos, ref rec, col, vertices, ref index);
        }
Beispiel #30
0
        void DrawNormal(IDrawer2D drawer)
        {
            if (Active)
            {
                return;
            }
            PackedCol lineCol = LauncherSkin.ButtonHighlightCol;

            drawer.Clear(lineCol, X + border * 2, Y + border, Width - border * 4, border);
        }