public ViewControl() { // this control will be painted using some 3d API // no need for double buffering // also no need for the OS to paint it. this.ResizeRedraw = false; this.DoubleBuffered = false; SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.Opaque, true); AllowDrop = true; m_camera = new Camera(); m_camera.SetPerspective((float)(Math.PI / 4), 1.0f, 0.1f, 2048); m_cameraController = new MayaStyleCameraController(); m_cameraController.Camera = m_camera; Sphere3F sphere = new Sphere3F(new Vec3F(0, 0, 0), 25.0f); float nearZ = m_camera.PerspectiveNearZ; m_camera.ZoomOnSphere(sphere); m_camera.PerspectiveNearZ = nearZ; m_camera.CameraChanged += new EventHandler(CameraChanged); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseWheel"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param> protected override void OnMouseWheel(MouseEventArgs e) { CameraController.MouseWheel(this, e); base.OnMouseWheel(e); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.KeyUp"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.KeyEventArgs"></see> that contains the event data.</param> protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); e.Handled = CameraController.KeyUp(this, e); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.KeyDown"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.KeyEventArgs"></see> that contains the event data.</param> protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); bool handled = CameraController.KeyDown(this, e); }