Exemplo n.º 1
0
        void Create_Cube(_3D_Model M, float XLeft, float wWidth, float YBottom, float hHight, float ZS, float Depth, Color vvv)
        {
            float[] vert =
            {
                XLeft + wWidth, YBottom + hHight, ZS,
                XLeft + wWidth, YBottom + hHight, ZS + Depth,
                XLeft,          YBottom + hHight, ZS + Depth,
                XLeft,          YBottom + hHight, ZS,
                XLeft + wWidth, YBottom,          ZS,
                XLeft + wWidth, YBottom,          ZS + Depth,
                XLeft,          YBottom,          ZS + Depth,
                XLeft,          YBottom,          ZS
            };


            _3D_Point pnn;
            int       j = 0;

            for (int i = 0; i < 8; i++)
            {
                pnn = new _3D_Point(vert[j], vert[j + 1], vert[j + 2]);
                j  += 3;
                M.AddPoint(pnn);
            }


            int[] Edges =
            {
                0, 1,
                1, 2,
                2, 3,
                3, 0,
                4, 5,
                5, 6,
                6, 7,
                7, 4,
                0, 4,
                3, 7,
                2, 6,
                1, 5
            };
            j = 0;
            for (int i = 0; i < 12; i++)
            {
                M.AddEdge(Edges[j], Edges[j + 1], vvv);

                j += 2;
            }
        }
Exemplo n.º 2
0
        void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            //Camera Rotation
            //Rotate X
            if (e.KeyCode == Keys.X)
            {
                _3D_Point cpyOfCop = new _3D_Point(cam.cop);
                _3D_Model mdl      = new _3D_Model();
                mdl.AddPoint(cpyOfCop);
                _3D_Point vv1 = new _3D_Point(cam.lookAt);
                _3D_Point vv2 = new _3D_Point(cam.lookAt);
                vv2.X -= 10;

                Transformation.RotateArbitrary(mdl.L_3D_Pts, vv1, vv2, 10);
                cam.cop = new _3D_Point(cpyOfCop);
                cam.BuildNewSystem();
            }
            //Rotate Y
            else if (e.KeyCode == Keys.Y)
            {
                _3D_Point cpyOfCop = new _3D_Point(cam.cop);
                _3D_Model mdl      = new _3D_Model();
                mdl.AddPoint(cpyOfCop);
                _3D_Point vv1 = new _3D_Point(cam.lookAt);
                _3D_Point vv2 = new _3D_Point(cam.lookAt);
                vv2.Y -= 10;

                Transformation.RotateArbitrary(mdl.L_3D_Pts, vv1, vv2, 10);
                cam.cop = new _3D_Point(cpyOfCop);
                cam.BuildNewSystem();
            }
            //Rotate Z
            else if (e.KeyCode == Keys.Z)
            {
                _3D_Point cpyOfCop = new _3D_Point(cam.cop);
                _3D_Model mdl      = new _3D_Model();
                mdl.AddPoint(cpyOfCop);
                _3D_Point vv1 = new _3D_Point(cam.lookAt);
                _3D_Point vv2 = new _3D_Point(cam.lookAt);
                vv2.Z -= 10;

                Transformation.RotateArbitrary(mdl.L_3D_Pts, vv1, vv2, 10);
                cam.cop = new _3D_Point(cpyOfCop);
                cam.BuildNewSystem();
            }
            //===================================================================================================
            else if (e.KeyCode == Keys.H)
            {
                _3D_Point v1 = new _3D_Point(rotatingx.L_3D_Pts[2].X, rotatingx.L_3D_Pts[2].Y, rotatingx.L_3D_Pts[2].Z);
                _3D_Point v2 = new _3D_Point(rotatingx.L_3D_Pts[5].X, rotatingx.L_3D_Pts[5].Y, rotatingx.L_3D_Pts[5].Z);
                Transformation.RotateArbitrary(middlepart.L_3D_Pts, v1, v2, 5f);
                //ransformation.RotateArbitrary(middlepart2.L_3D_Pts, v1, v2, 5f);
            }
            else if (e.KeyCode == Keys.J)
            {
                _3D_Point v1 = new _3D_Point(rotatingy.L_3D_Pts[2].X, rotatingy.L_3D_Pts[2].Y, rotatingy.L_3D_Pts[2].Z);
                _3D_Point v2 = new _3D_Point(rotatingy.L_3D_Pts[5].X, rotatingy.L_3D_Pts[5].Y, rotatingy.L_3D_Pts[5].Z);
                Transformation.RotateArbitrary(middlepart.L_3D_Pts, v1, v2, 5f);
                //Transformation.RotateArbitrary(middlepart2.L_3D_Pts, v1, v2, 5f);
            }
            else if (e.KeyCode == Keys.K)
            {
                _3D_Point v1 = new _3D_Point(rotatingz.L_3D_Pts[0].X, rotatingz.L_3D_Pts[0].Y, rotatingz.L_3D_Pts[0].Z);
                _3D_Point v2 = new _3D_Point(rotatingz.L_3D_Pts[5].X, rotatingz.L_3D_Pts[5].Y, rotatingz.L_3D_Pts[5].Z);
                Transformation.RotateArbitrary(middlepart.L_3D_Pts, v1, v2, 5f);
                //Transformation.RotateArbitrary(middlepart2.L_3D_Pts, v1, v2, 5f);
            }
        }