private void genericMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { //Debug.WriteLine("Mouse moving on {0}", this.TabIndex); //int delta_x = (int) (Math.Pow(activeCam.fov, 4) * (e.X - mouse_x)); //int delta_y = (int) (Math.Pow(activeCam.fov, 4) * (e.Y - mouse_y)); System.Drawing.Point p = PointToClient(Cursor.Position); mouseState.Delta.X = (p.X - mouseState.Position.X); mouseState.Delta.Y = (p.Y - mouseState.Position.Y); mouseState.Delta.X = Math.Min(Math.Max(mouseState.Delta.X, -10), 10); mouseState.Delta.Y = Math.Min(Math.Max(mouseState.Delta.Y, -10), 10); //Take action switch (mouseMovementStatus) { case MouseMovementStatus.CAMERA_MOVEMENT: { // Debug.WriteLine("Deltas {0} {1} {2}", mouseState.Delta.X, mouseState.Delta.Y, e.Button); engine.targetCameraPos.Rotation.X += mouseState.Delta.X; engine.targetCameraPos.Rotation.Y += mouseState.Delta.Y; break; } case MouseMovementStatus.GIZMO_MOVEMENT: { //Find movement axis GIZMO_PART_TYPE t = activeGizmo.activeType; float movement_step = (float)Math.Sqrt(mouseState.Delta.X * mouseState.Delta.X / (Size.Width * Size.Width) + mouseState.Delta.Y * mouseState.Delta.Y / (Size.Height * Size.Height)); Console.WriteLine("Moving by {0}", movement_step); switch (t) { case GIZMO_PART_TYPE.T_X: activeModel._localPosition.X += movement_step; break; case GIZMO_PART_TYPE.T_Y: activeModel._localPosition.Y += movement_step; break; case GIZMO_PART_TYPE.T_Z: activeModel._localPosition.Z += movement_step; break; } activeModel.update(); //Trigger model update break; } default: break; } mouseState.Position.X = p.X; mouseState.Position.Y = p.Y; }
public GizmoPart(GIZMO_PART_TYPE t, Vector3 col) { type = t; pick_color = col; switch (t) { case GIZMO_PART_TYPE.T_X: meshVao = MVCore.Common.RenderState.activeResMgr.GLPrimitiveMeshVaos["default_translation_gizmo_x_axis"]; break; case GIZMO_PART_TYPE.T_Y: meshVao = MVCore.Common.RenderState.activeResMgr.GLPrimitiveMeshVaos["default_translation_gizmo_y_axis"]; break; case GIZMO_PART_TYPE.T_Z: meshVao = MVCore.Common.RenderState.activeResMgr.GLPrimitiveMeshVaos["default_translation_gizmo_z_axis"]; break; } }