Exemple #1
0
        public static Mesh MultiTextureBox(float width, float height, float depth)
        {
            List <FVF_PositionNormalTextured> verts = new List <FVF_PositionNormalTextured>(4 * 6);
            List <short[]> inds = new List <short[]>(6);
            short          off  = 0;
            Matrix         matrix;

            for (int i = 0; i < 0x10000; i += 0x4000)
            {
                matrix = Matrix.Identity;
                MatrixFunctions.RotateY(ref matrix, i);
                MatrixFunctions.Scale(ref matrix, width, height, depth);
                verts.AddRange(boxverts.Select(v => new FVF_PositionNormalTextured(Vector3.TransformCoordinate(v.Position, matrix), Vector3.TransformNormal(v.Normal, matrix), v.UV)));
                inds.Add(boxinds.Select(a => (short)(a + off)).ToArray());
                off += 4;
            }
            matrix = Matrix.Identity;
            MatrixFunctions.RotateX(ref matrix, 0x4000);
            MatrixFunctions.Scale(ref matrix, width, height, depth);
            verts.AddRange(boxverts.Select(v => new FVF_PositionNormalTextured(Vector3.TransformCoordinate(v.Position, matrix), Vector3.TransformNormal(v.Normal, matrix), v.UV)));
            inds.Add(boxinds.Select(a => (short)(a + off)).ToArray());
            off   += 4;
            matrix = Matrix.Identity;
            MatrixFunctions.RotateX(ref matrix, 0xC000);
            MatrixFunctions.Scale(ref matrix, width, height, depth);
            verts.AddRange(boxverts.Select(v => new FVF_PositionNormalTextured(Vector3.TransformCoordinate(v.Position, matrix), Vector3.TransformNormal(v.Normal, matrix), v.UV)));
            inds.Add(boxinds.Select(a => (short)(a + off)).ToArray());
            return(new Mesh <FVF_PositionNormalTextured>(verts.ToArray(), inds.ToArray()));
        }
Exemple #2
0
        public void NJRotateX(int x)
        {
            Matrix m = Top;

            MatrixFunctions.RotateX(ref m, x);
            LoadMatrix(m);
        }
Exemple #3
0
        public static Mesh Box(float width, float height, float depth, params System.Drawing.Color[] colors)
        {
            System.Drawing.Color[] sidecolors = new System.Drawing.Color[6];
            if (colors.Length >= 6)
            {
                Array.Copy(colors, sidecolors, 6);
            }
            else if (colors.Length == 5)
            {
                Array.Copy(colors, sidecolors, 5);
                sidecolors[5] = colors[4];
            }
            else if (colors.Length >= 3)
            {
                sidecolors[0] = sidecolors[2] = colors[0];
                sidecolors[1] = sidecolors[3] = colors[1];
                sidecolors[4] = sidecolors[5] = colors[2];
            }
            else if (colors.Length == 2)
            {
                sidecolors[0] = sidecolors[1] = sidecolors[4] = colors[0];
                sidecolors[2] = sidecolors[3] = sidecolors[5] = colors[1];
            }
            else
            {
                sidecolors[0] = sidecolors[1] = sidecolors[2] = sidecolors[3] = sidecolors[4] = sidecolors[5] = colors[0];
            }
            List <FVF_PositionNormalTexturedColored> verts = new List <FVF_PositionNormalTexturedColored>(4 * 6);
            List <short> inds = new List <short>(6 * 6);
            short        off  = 0;
            Matrix       matrix;

            for (int i = 0; i < 0x10000; i += 0x4000)
            {
                matrix = Matrix.Identity;
                MatrixFunctions.RotateY(ref matrix, i);
                MatrixFunctions.Scale(ref matrix, width, height, depth);
                verts.AddRange(boxverts.Select(v => new FVF_PositionNormalTexturedColored(Vector3.TransformCoordinate(v.Position, matrix), Vector3.TransformNormal(v.Normal, matrix), v.UV, sidecolors[i / 0x4000])));
                inds.AddRange(boxinds.Select(a => (short)(a + off)));
                off += 4;
            }
            matrix = Matrix.Identity;
            MatrixFunctions.RotateX(ref matrix, 0x4000);
            MatrixFunctions.Scale(ref matrix, width, height, depth);
            verts.AddRange(boxverts.Select(v => new FVF_PositionNormalTexturedColored(Vector3.TransformCoordinate(v.Position, matrix), Vector3.TransformNormal(v.Normal, matrix), v.UV, sidecolors[4])));
            inds.AddRange(boxinds.Select(a => (short)(a + off)));
            off   += 4;
            matrix = Matrix.Identity;
            MatrixFunctions.RotateX(ref matrix, 0xC000);
            MatrixFunctions.Scale(ref matrix, width, height, depth);
            verts.AddRange(boxverts.Select(v => new FVF_PositionNormalTexturedColored(Vector3.TransformCoordinate(v.Position, matrix), Vector3.TransformNormal(v.Normal, matrix), v.UV, sidecolors[5])));
            inds.AddRange(boxinds.Select(a => (short)(a + off)));
            return(new Mesh <FVF_PositionNormalTexturedColored>(verts.ToArray(), new short[][] { inds.ToArray() }));
        }