Ejemplo n.º 1
0
 public static TextureCoordinates FromString(string str)
 {
     TextureCoordinates tc = new TextureCoordinates();
     string[] data = str.SplitFast('/');
     tc.xscale = (float)Utilities.StringToFloat(data[0]);
     tc.yscale = (float)Utilities.StringToFloat(data[1]);
     tc.xshift = (float)Utilities.StringToFloat(data[2]);
     tc.yshift = (float)Utilities.StringToFloat(data[3]);
     tc.xflip = data[4] == "t";
     tc.yflip = data[5] == "t";
     return tc;
 }
Ejemplo n.º 2
0
        public static TextureCoordinates FromString(string str)
        {
            TextureCoordinates tc = new TextureCoordinates();

            string[] data = str.SplitFast('/');
            tc.xscale = (float)Utilities.StringToFloat(data[0]);
            tc.yscale = (float)Utilities.StringToFloat(data[1]);
            tc.xshift = (float)Utilities.StringToFloat(data[2]);
            tc.yshift = (float)Utilities.StringToFloat(data[3]);
            tc.xflip  = data[4] == "t";
            tc.yflip  = data[5] == "t";
            return(tc);
        }
Ejemplo n.º 3
0
 public void AddSide(Location normal, TextureCoordinates tc, bool offs = false, float texf = 0)
 {
     // TODO: IMPROVE!
     for (int i = 0; i < 6; i++)
     {
         Normals.Add(ClientUtilities.Convert(normal));
         Colors.Add(new Vector4(1f, 1f, 1f, 1f));
         Indices.Add((uint)Indices.Count);
         BoneIDs.Add(new Vector4(0, 0, 0, 0));
         BoneWeights.Add(new Vector4(0f, 0f, 0f, 0f));
         BoneIDs2.Add(new Vector4(0, 0, 0, 0));
         BoneWeights2.Add(new Vector4(0f, 0f, 0f, 0f));
     }
     float aX = (tc.xflip ? 1 : 0) + tc.xshift;
     float aY = (tc.yflip ? 1 : 0) + tc.yshift;
     float bX = (tc.xflip ? 0 : 1) * tc.xscale + tc.xshift;
     float bY = (tc.yflip ? 1 : 0) + tc.yshift;
     float cX = (tc.xflip ? 0 : 1) * tc.xscale + tc.xshift;
     float cY = (tc.yflip ? 0 : 1) * tc.yscale + tc.yshift;
     float dX = (tc.xflip ? 1 : 0) + tc.xshift;
     float dY = (tc.yflip ? 0 : 1) * tc.yscale + tc.yshift;
     float zero = offs ? -0.5f: -1; // Sssh
     float one = offs ? 0.5f : 1;
     if (normal.Z == 1)
     {
         // T1
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(zero, zero, one));
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(zero, one, one));
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(one, one, one));
         // T2
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(zero, zero, one));
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(one, one, one));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(one, zero, one));
     }
     else if (normal.Z == -1)
     {
         // T1
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(one, one, zero));
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(zero, one, zero));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(zero, zero, zero));
         // T2
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(one, zero, zero));
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(one, one, zero));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(zero, zero, zero));
     }
     else if (normal.X == 1)
     {
         // T1
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(one, one, one));
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(one, one, zero));
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(one, zero, zero));
         // T2
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(one, zero, one));
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(one, one, one));
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(one, zero, zero));
     }
     else if (normal.X == -1)
     {
         // T1
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(zero, zero, zero));
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(zero, one, zero));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(zero, one, one));
         // T2
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(zero, zero, zero));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(zero, one, one));
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(zero, zero, one));
     }
     else if (normal.Y == 1)
     {
         // T1
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(one, one, one));
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(zero, one, one));
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(zero, one, zero));
         // T2
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(one, one, zero));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(one, one, one));
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(zero, one, zero));
     }
     else if (normal.Y == -1)
     {
         // T1
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(zero, zero, zero));
         TexCoords.Add(new Vector3(aX, aY, texf));
         Vertices.Add(new Vector3(zero, zero, one));
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(one, zero, one));
         // T2
         TexCoords.Add(new Vector3(dX, dY, texf));
         Vertices.Add(new Vector3(zero, zero, zero));
         TexCoords.Add(new Vector3(bX, bY, texf));
         Vertices.Add(new Vector3(one, zero, one));
         TexCoords.Add(new Vector3(cX, cY, texf));
         Vertices.Add(new Vector3(one, zero, zero));
     }
     else
     {
         throw new Exception("Lazy code can't handle unique normals! Only axis-aligned, normalized normals!");
     }
 }
Ejemplo n.º 4
0
        public void AddSide(Location normal, TextureCoordinates tc, bool offs = false, float texf = 0)
        {
            // TODO: IMPROVE!
            for (int i = 0; i < 6; i++)
            {
                Normals.Add(ClientUtilities.Convert(normal));
                Colors.Add(new Vector4(1f, 1f, 1f, 1f));
                Indices.Add((uint)Indices.Count);
                BoneIDs.Add(new Vector4(0, 0, 0, 0));
                BoneWeights.Add(new Vector4(0f, 0f, 0f, 0f));
                BoneIDs2.Add(new Vector4(0, 0, 0, 0));
                BoneWeights2.Add(new Vector4(0f, 0f, 0f, 0f));
            }
            float aX   = (tc.xflip ? 1 : 0) + tc.xshift;
            float aY   = (tc.yflip ? 1 : 0) + tc.yshift;
            float bX   = (tc.xflip ? 0 : 1) * tc.xscale + tc.xshift;
            float bY   = (tc.yflip ? 1 : 0) + tc.yshift;
            float cX   = (tc.xflip ? 0 : 1) * tc.xscale + tc.xshift;
            float cY   = (tc.yflip ? 0 : 1) * tc.yscale + tc.yshift;
            float dX   = (tc.xflip ? 1 : 0) + tc.xshift;
            float dY   = (tc.yflip ? 0 : 1) * tc.yscale + tc.yshift;
            float zero = offs ? -0.5f: -1; // Sssh
            float one  = offs ? 0.5f : 1;

            if (normal.Z == 1)
            {
                // T1
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(zero, zero, one));
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(zero, one, one));
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(one, one, one));
                // T2
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(zero, zero, one));
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(one, one, one));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(one, zero, one));
            }
            else if (normal.Z == -1)
            {
                // T1
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(one, one, zero));
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(zero, one, zero));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(zero, zero, zero));
                // T2
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(one, zero, zero));
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(one, one, zero));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(zero, zero, zero));
            }
            else if (normal.X == 1)
            {
                // T1
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(one, one, one));
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(one, one, zero));
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(one, zero, zero));
                // T2
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(one, zero, one));
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(one, one, one));
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(one, zero, zero));
            }
            else if (normal.X == -1)
            {
                // T1
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(zero, zero, zero));
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(zero, one, zero));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(zero, one, one));
                // T2
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(zero, zero, zero));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(zero, one, one));
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(zero, zero, one));
            }
            else if (normal.Y == 1)
            {
                // T1
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(one, one, one));
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(zero, one, one));
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(zero, one, zero));
                // T2
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(one, one, zero));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(one, one, one));
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(zero, one, zero));
            }
            else if (normal.Y == -1)
            {
                // T1
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(zero, zero, zero));
                TexCoords.Add(new Vector3(aX, aY, texf));
                Vertices.Add(new Vector3(zero, zero, one));
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(one, zero, one));
                // T2
                TexCoords.Add(new Vector3(dX, dY, texf));
                Vertices.Add(new Vector3(zero, zero, zero));
                TexCoords.Add(new Vector3(bX, bY, texf));
                Vertices.Add(new Vector3(one, zero, one));
                TexCoords.Add(new Vector3(cX, cY, texf));
                Vertices.Add(new Vector3(one, zero, zero));
            }
            else
            {
                throw new Exception("Lazy code can't handle unique normals! Only axis-aligned, normalized normals!");
            }
        }