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; }
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; } }
// 공개 함수 ------------------------------------ public void Render() { MFramework.Instance.Device.Clear(0); MFramework.Instance.Device.BeginScene(); MCameraSceneNode camera = MFramework.Instance.SceneManager.GetActiveCamera(); MFramework.Instance.SceneManager.Update(); MFramework.Instance.SceneManager.Render(); if (IsDrawGrid) { RenderGrid(); } RenderMesh(); MFramework.Instance.Device.EndScene(); MFramework.Instance.Device.Flip(); }