Esempio n. 1
0
        public void NJScale(float x, float y, float z)
        {
            Matrix m = Top;

            MatrixFunctions.Scale(ref m, x, y, z);
            LoadMatrix(m);
        }
Esempio n. 2
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()));
        }
Esempio n. 3
0
        public void NJRotateObject(int x, int y, int z)
        {
            Matrix m = Top;

            MatrixFunctions.RotateObject(ref m, x, y, z);
            LoadMatrix(m);
        }
Esempio n. 4
0
        public void NJRotateZ(int z)
        {
            Matrix m = Top;

            MatrixFunctions.RotateZ(ref m, z);
            LoadMatrix(m);
        }
Esempio n. 5
0
        public void NJRotateY(int y)
        {
            Matrix m = Top;

            MatrixFunctions.RotateY(ref m, y);
            LoadMatrix(m);
        }
Esempio n. 6
0
        public void NJRotateX(int x)
        {
            Matrix m = Top;

            MatrixFunctions.RotateX(ref m, x);
            LoadMatrix(m);
        }
Esempio n. 7
0
        public void NJTranslate(float x, float y, float z)
        {
            Matrix m = Top;

            MatrixFunctions.Translate(ref m, x, y, z);
            LoadMatrix(m);
        }
Esempio n. 8
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() }));
        }