unsafe void RenderStars(ref VertexP3fT2fC4b *vertices)
        {
            VertexP3fT2fC4b v;

            v.Colour = starColour.Pack();

            for (int i = 0; i < 500; i++)
            {
                float pitch = (float)(Utils.Lerp(0.025f, 0.975f, rand.NextFloat()) * 2 * Math.PI);
                float yaw   = (float)(Utils.Lerp(0.025f, 0.975f, rand.NextFloat()) * 2 * Math.PI);

                const float size = 0.001f;
                Vector3     p00  = new Vector3(-size, -size, 0.2f);
                Vector3     p10  = new Vector3(+size, -size, 0.2f);
                Vector3     p11  = new Vector3(+size, +size, 0.2f);
                Vector3     p01  = new Vector3(-size, +size, 0.2f);

                p00 = Utils.RotateY(p00, yaw);
                p10 = Utils.RotateY(p10, yaw);
                p11 = Utils.RotateY(p11, yaw);
                p01 = Utils.RotateY(p01, yaw);

                p00 = Utils.RotateZ(p00, pitch);
                p10 = Utils.RotateZ(p10, pitch);
                p11 = Utils.RotateZ(p11, pitch);
                p01 = Utils.RotateZ(p01, pitch);

                v.X = p00.X; v.Y = p00.Y; v.Z = p00.Z; v.U = 0.00f; v.V = 0.00f; *vertices = v; vertices++;
                v.X = p10.X; v.Y = p10.Y; v.Z = p10.Z; v.U = 1.00f; *vertices = v; vertices++;
                v.X = p11.X; v.Y = p11.Y; v.Z = p11.Z;              v.V = 1.00f; *vertices = v; vertices++;
                v.X = p01.X; v.Y = p01.Y; v.Z = p01.Z; v.U = 0.00f; *vertices = v; vertices++;
            }
        }
Example #2
0
 unsafe void DrawDynamicTriangles(int verticesCount, int startVertex)
 {
     GL.Begin(BeginMode.Triangles);
     if (batchFormat == VertexFormat.P3fT2fC4b)
     {
         VertexP3fT2fC4b *ptr = (VertexP3fT2fC4b *)dynamicListData;
         for (int i = startVertex; i < startVertex + verticesCount; i += 4)
         {
             V(ptr[i + 0]); V(ptr[i + 1]); V(ptr[i + 2]);
             V(ptr[i + 2]); V(ptr[i + 3]); V(ptr[i + 0]);
         }
     }
     else if (batchFormat == VertexFormat.P3fT2fC4bN1v)
     {
         VertexP3fT2fC4bN1v *ptr = (VertexP3fT2fC4bN1v *)dynamicListData;
         for (int i = startVertex; i < startVertex + verticesCount; i += 4)
         {
             V(ptr[i + 0]); V(ptr[i + 1]); V(ptr[i + 2]);
             V(ptr[i + 2]); V(ptr[i + 3]); V(ptr[i + 0]);
         }
     }
     else
     {
         VertexP3fC4b *ptr = (VertexP3fC4b *)dynamicListData;
         for (int i = startVertex; i < startVertex + verticesCount; i += 4)
         {
             V(ptr[i + 0]); V(ptr[i + 1]); V(ptr[i + 2]);
             V(ptr[i + 2]); V(ptr[i + 3]); V(ptr[i + 0]);
         }
     }
     GL.End();
 }
Example #3
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 #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 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 #6
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   = stackalloc VertexP3fT2fC4b[edgesVertices];
            IntPtr           ptr = (IntPtr)v;

            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), ref v);
            }
            edgesVb = gfx.CreateVb(ptr, VertexFormat.P3fT2fC4b, edgesVertices);
        }
Example #7
0
        void RebuildEdges(int y, int axisSize)
        {
            float yOffset = -0.1f / 16;
            byte  block   = game.World.Env.EdgeBlock;

            if (game.BlockInfo.IsLiquid[block])
            {
                yOffset = -1.5f / 16;
            }

            edgesVertices = 0;
            foreach (Rectangle r in rects)
            {
                edgesVertices += Utils.CountVertices(r.Width, r.Height, axisSize);                   // YPlanes outside
            }
            VertexP3fT2fC4b *v   = stackalloc VertexP3fT2fC4b[edgesVertices];
            IntPtr           ptr = (IntPtr)v;

            fullColEdge = game.BlockInfo.FullBright[block];
            FastColour col = fullColEdge ? FastColour.White : map.Env.Sunlight;

            foreach (Rectangle r in rects)
            {
                DrawY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, y, axisSize, col, -0.1f / 16, yOffset, ref v);
            }
            edgesVb = graphics.CreateVb(ptr, VertexFormat.P3fT2fC4b, edgesVertices);
        }
Example #8
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         = 1.0f;
            VertexP3fT2fC4b v; v.Colour = game.World.Env.CloudsCol.Pack();

            // Render the front quad
            v.Z = -pos;
            v.X = pos; v.Y = -pos;             v.U = 0.25f; v.V = 1.00f; *vertices = v; vertices++;
            v.X = -pos;                         v.U = 0.50f; *            vertices = v; vertices++;
            v.Y = pos;                          v.V = 0.50f; *            vertices = v; vertices++;
            v.X = pos;                         v.U = 0.25f; *vertices = v; vertices++;

            // Render the left quad
            v.X = pos;
            v.Y = -pos; v.Z = pos; v.U = 0.00f; v.V = 1.00f; *vertices = v; vertices++;
            v.Z = -pos; v.U = 0.25f; *vertices = v; vertices++;
            v.Y = pos;                          v.V = 0.50f; *vertices = v; vertices++;
            v.Z = pos; v.U = 0.00f; *vertices = v; vertices++;

            // Render the back quad
            v.Z = pos;
            v.X = -pos; v.Y = -pos;             v.U = 0.75f; v.V = 1.00f; *vertices = v; vertices++;
            v.X = pos;                         v.U = 1.00f; * vertices = v; vertices++;
            v.Y = pos;                          v.V = 0.50f; *vertices = v; vertices++;
            v.X = -pos;                         v.U = 0.75f; *vertices = v; vertices++;

            // Render the right quad
            v.X = -pos;
            v.Y = -pos; v.Z = -pos; v.U = 0.50f; v.V = 1.00f; *vertices = v; vertices++;
            v.Z = pos; v.U = 0.75f; *vertices = v; vertices++;
            v.Y = pos;                          v.V = 0.50f; *vertices = v; vertices++;
            v.Z = -pos; v.U = 0.50f; *vertices = v; vertices++;

            // Render the top quad
            v.Y = pos;
            v.X = -pos;             v.Z = -pos; *            vertices = v; vertices++;
            v.Z = pos;              v.V = 0.00f; *           vertices = v; vertices++;
            v.X = pos;                         v.U = 0.25f; *vertices = v; vertices++;
            v.Z = -pos;              v.V = 0.50f; *          vertices = v; vertices++;

            // Render the bottom quad
            v.Y = -pos;
            v.X = -pos;             v.Z = -pos; v.U = 0.75f; *vertices = v; vertices++;
            v.Z = pos;              v.V = 0.00f; *            vertices = v; vertices++;
            v.X = pos;                         v.U = 0.50f; * vertices = v; vertices++;
            v.Z = -pos;              v.V = 0.50f; *           vertices = v; vertices++;

            vb = game.Graphics.CreateVb(start, VertexFormat.P3fT2fC4b, count);
        }
Example #9
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 #10
0
        void RebuildSides(int y, int axisSize)
        {
            BlockID block = game.World.Env.SidesBlock;

            sidesVertices = 0;
            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   = stackalloc VertexP3fT2fC4b[sidesVertices];
            IntPtr           ptr = (IntPtr)v;

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

            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, 0, YOffset(block), ref v);
            }

            // 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, ref v);
            DrawZ(0, 0, map.Width, y1, y2, axisSize, col, ref v);
            DrawZ(map.Length, 0, map.Width, y1, y2, axisSize, col, ref v);
            DrawX(0, 0, map.Length, y1, y2, axisSize, col, ref v);
            DrawX(map.Width, 0, map.Length, y1, y2, axisSize, col, ref v);
            sidesVb = gfx.CreateVb(ptr, VertexFormat.P3fT2fC4b, sidesVertices);
        }
Example #11
0
        void RebuildSides(int y, int axisSize)
        {
            float yOffset = 0;
            byte  block   = game.World.Env.EdgeBlock;

            if (game.BlockInfo.IsLiquid[block])
            {
                yOffset = -1.5f / 16;
            }

            sidesVertices = 0;
            foreach (Rectangle r in rects)
            {
                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   = stackalloc VertexP3fT2fC4b[sidesVertices];
            IntPtr           ptr = (IntPtr)v;

            fullColSides = game.BlockInfo.FullBright[block];
            FastColour col = fullColSides ? FastColour.White : map.Env.Shadowlight;

            foreach (Rectangle r in rects)
            {
                DrawY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, y, axisSize, col, 0, yOffset, ref v);
            }

            // 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, ref v);
            DrawZ(0, 0, map.Width, y1, y2, axisSize, col, ref v);
            DrawZ(map.Length, 0, map.Width, y1, y2, axisSize, col, ref v);
            DrawX(0, 0, map.Length, y1, y2, axisSize, col, ref v);
            DrawX(map.Width, 0, map.Length, y1, y2, axisSize, col, ref v);
            sidesVb = graphics.CreateVb(ptr, VertexFormat.P3fT2fC4b, sidesVertices);
        }
Example #12
0
        void SetPartInfo(DrawInfo part, ref int offset, int i, ref ChunkPartInfo[] parts)
        {
            int vertCount = part.VerticesCount();

            if (vertCount == 0)
            {
                return;
            }

            ChunkPartInfo info;

            info.Offset = offset;
            offset     += vertCount;

                        #if GL11
            fixed(VertexP3fT2fC4b *ptr = vertices)
            {
                VertexP3fT2fC4b *ptr2 = ptr + info.Offset;

                info.Vb = game.Graphics.CreateVb((IntPtr)ptr, VertexFormat.P3fT2fC4b, vertCount);
            }
                        #endif

            info.LeftCount   = (ushort)part.vCount[Side.Left];
            info.RightCount  = (ushort)part.vCount[Side.Right];
            info.FrontCount  = (ushort)part.vCount[Side.Front];
            info.BackCount   = (ushort)part.vCount[Side.Back];
            info.BottomCount = (ushort)part.vCount[Side.Bottom];
            info.TopCount    = (ushort)part.vCount[Side.Top];
            info.SpriteCount = part.spriteCount;

            // Lazy initalize part arrays so we can save time in MapRenderer for chunks that only contain 1 or 2 part types.
            if (parts == null)
            {
                parts = new ChunkPartInfo[arraysCount];
                for (int j = 0; j < parts.Length; j++)
                {
                    parts[j].Offset = -1;
                }
            }
            parts[i] = info;
        }
Example #13
0
 unsafe void DrawDynamicLines(int verticesCount)
 {
     GL.Begin(BeginMode.Lines);
     if (batchFormat == VertexFormat.P3fT2fC4b)
     {
         VertexP3fT2fC4b *ptr = (VertexP3fT2fC4b *)dynamicListData;
         for (int i = 0; i < verticesCount; i += 2)
         {
             V(ptr[i + 0]); V(ptr[i + 1]);
         }
     }
     else
     {
         VertexP3fC4b *ptr = (VertexP3fC4b *)dynamicListData;
         for (int i = 0; i < verticesCount; i += 2)
         {
             V(ptr[i + 0]); V(ptr[i + 1]);
         }
     }
     GL.End();
 }
        unsafe void MakeVb()
        {
            if (game.Graphics.LostContext)
            {
                return;
            }
            game.Graphics.DeleteVb(ref vb);
            VertexP3fT2fC4b *vertices = stackalloc VertexP3fT2fC4b[count];
            IntPtr           start    = (IntPtr)vertices;

            const float     posX        = 0.06f;
            const float     posY        = 0.06f;
            const float     posZ        = 0.2f;
            const float     posAdd      = 0.0f;
            VertexP3fT2fC4b v; v.Colour = FastColour.WhitePacked;

            // Render the front quad
            v.X = posX; v.Y = -posY + posAdd; v.Z = -posZ; v.U = 0.00f; v.V = 0.00f; *vertices = v; vertices++;
            v.X = -posX;                         v.U = 1.00f; *         vertices = v; vertices++;
            v.Y = posY + posAdd;                          v.V = 1.00f; *vertices = v; vertices++;
            v.X = posX;                         v.U = 0.00f; *          vertices = v; vertices++;

            const float posX2 = 0.04f;
            const float posY2 = 0.04f;

            // Render the front quad
            v.X = -posX2; v.Y = -posY2 + posAdd; v.Z = posZ; v.U = 0.00f; v.V = 0.00f; *vertices = v; vertices++;
            v.X = posX2;                         v.U = 1.00f; *          vertices = v; vertices++;
            v.Y = posY2 + posAdd;                          v.V = 1.00f; *vertices = v; vertices++;
            v.X = -posX2;                         v.U = 0.00f; *         vertices = v; vertices++;

            RenderStars(ref vertices);

            // Render the left quad

            /*v.X =  pos; v.Y = -pos; v.Z =  pos; v.U = 0.00f; v.V = 1.00f; *vertices = v; vertices++;
             *                      v.Z = -pos; v.U = 0.25f;              *vertices = v; vertices++;
             *          v.Y =  pos;                          v.V = 0.50f; *vertices = v; vertices++;
             *                      v.Z =  pos; v.U = 0.00f;              *vertices = v; vertices++;*/

            /*for (int i = 0; i < 100; i++) {
             *      //float randAdd = (float)rand.NextFloat();
             *      //float randAdd2 = (float)rand.NextFloat();
             *      //randAdd = Utils.Lerp(-4, 4, randAdd);
             *      //float posX3 = 0.0025f * (float)(Math.Cos(randAdd) * (100 * randAdd2));
             *      //float posY3 = 0.0025f * (float)(Math.Sin(randAdd) * (100 * randAdd2));
             *      float xSize = 0.002f;
             *      float ySize = 0.002f;
             *      //float posZ2 = (0.02f * randAdd2);
             *      float randAdd = (float)rand.NextFloat();
             *      randAdd = Utils.Lerp(-1, 1, randAdd);
             *      float rxy = (float)Math.Sqrt(1f - (randAdd * randAdd));
             *      float phi = (float)rand.NextFloat();
             *      phi = Utils.Lerp(0, (float)(2 * Math.PI), phi);
             *      float posX3 = (rxy * (float)Math.Cos(phi)) * 0.2f;
             *      float posY3 = (rxy * (float)Math.Sin(phi)) * 0.2f;
             *      float posZ2 = 0.2f * randAdd;
             *      v.Colour = starColour.Pack();
             *      v.X = -xSize + posX3;  v.Y = -ySize + posY3;  v.Z = posZ2; v.U = 0.00f; v.V = 0.00f; *vertices = v; vertices++;
             *      v.X =  xSize+ posX3;                                       v.U = 1.00f;              *vertices = v; vertices++;
             *                             v.Y =  ySize + posY3;                            v.V = 1.00f; *vertices = v; vertices++;
             *      v.X = -xSize+ posX3;                                       v.U = 0.00f;              *vertices = v; vertices++;
             * }*/

            vb = game.Graphics.CreateVb(start, VertexFormat.P3fT2fC4b, count);
        }