Esempio n. 1
0
        private void RenderPanel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int dx = e.X - old_mouse_x;
            int dy = e.Y - old_mouse_y;

            if (e.Button == MouseButtons.Left)
            {
                MCameraSceneNode camera = MFramework.Instance.SceneManager.GetActiveCamera();

                if (camera.Valid)
                {
                    MPolarCameraSceneNode cam   = (camera as MPolarCameraSceneNode);
                    RSMPolarCoord         coord = cam.Coord;

                    coord.fTheta -= (dx / 100.0f);
                    coord.fPhi   += (dy / 200.0f);
                    cam.Coord     = coord;
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                MCameraSceneNode camera = MFramework.Instance.SceneManager.GetActiveCamera();

                if (camera.Valid)
                {
                    MPolarCameraSceneNode cam = (camera as MPolarCameraSceneNode);
                    Vector3 at = cam.LookAt;
                    Vector3 up = new Vector3(0, 0, 1);

                    Vector3 right = cam.Direction.CrossProduct(up);

                    right.Normalize();
                    right = right * (-dx);

                    at   += right;
                    at.z += dy;

                    cam.LookAt = at;
                }
            }

            old_mouse_x = e.X;
            old_mouse_y = e.Y;
        }
Esempio n. 2
0
        private void RenderPanel_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            float d = e.Delta * 0.2f;

            MCameraSceneNode camera = MFramework.Instance.SceneManager.GetActiveCamera();

            if (camera.Valid)
            {
                MPolarCameraSceneNode cam   = (camera as MPolarCameraSceneNode);
                RSMPolarCoord         coord = cam.Coord;

                coord.fRadius += d;
                if (coord.fRadius < 0.01f)
                {
                    coord.fRadius = 0.01f;
                }

                cam.Coord = coord;
            }
        }
Esempio n. 3
0
        public void ResetCamera()
        {
            MSceneNode cameraNode = new MPolarCameraSceneNode();

            if (cameraNode.Valid)
            {
                MPolarCameraSceneNode cam = (cameraNode as MPolarCameraSceneNode);


                MFramework.Instance.SceneManager.AddChild(cameraNode);
                MFramework.Instance.SceneManager.SetActiveCamera(cameraNode as MCameraSceneNode);

                Vector3 at = new Vector3(0, 0, 100);

                RSMPolarCoord coord = cam.Coord;
                coord.fPhi    = 0.0f;
                coord.fRadius = 200.0f;
                cam.Coord     = coord;

                cam.LookAt = at;

                cam.UpdateCamera();
            }



            //				MCameraSceneNode camera = MFramework.Instance.SceneManager.GetActiveCamera();
            //				if (camera.Valid)
            //				{
            //					Vector3 dir = new Vector3(0, 0, 100);
            //					Vector3 pos = new Vector3(-200,0,100);
            //					dir = dir - pos;
            //					dir.Normalize();
            //
            //					camera.Set(pos, dir, new Vector3(0,0,1));
            //				}
        }