public virtual bool MouseWheel(MouseDescriptor e) { return false; }
public override bool MouseWheel(MouseDescriptor e) { //Console.WriteLine("Mouse wheel delta: " + e.WheelDelta.ToString()); Vector3 eyeVector = Position - Target; float len = eyeVector.Length; len -= ZoomSpeed * e.WheelDelta * 0.001f * len; eyeVector.Normalize(); Position = Target + eyeVector * len; return true; }
public virtual bool MouseMove(MouseDescriptor e) { return false; }
public override bool MouseUp(MouseDescriptor e) { if (e[PanButton]) { //Console.WriteLine("End Panning - X: {0} Y: {1}", e.X, e.Y); return true; } if (e[RotateButton]) { //Console.WriteLine("End Rotating - X: {0} Y: {1}", e.X, e.Y); return true; } return false; }
public override bool MouseMove(MouseDescriptor e) { if (e[PanButton]) { //Console.WriteLine("Panning - X: {0} Y: {1}", e.X, e.Y); Vector2 newPos = new Vector2((float) e.X, (float) e.Y); PanTarget(newPos); panStartPos = newPos; return true; } if (e[RotateButton]) { //Console.WriteLine("Rotating - X: {0} Y: {1}", e.X, e.Y); //RotateWithQuaternion((float)e.X, (float)e.Y); Vector2 newPos = new Vector2((float) e.X, (float) e.Y); RotateAroundUpVector(newPos); startPos = newPos; return true; } return false; }
public override bool MouseDown(MouseDescriptor e) { if (e[PanButton]) { //Console.WriteLine("Start Panning - X: {0} Y: {1}", e.X, e.Y); panStartPos = new Vector2((float) e.X, (float) e.Y); return true; } if (e[RotateButton]) { //Console.WriteLine("Start Rotating - X: {0} Y: {1}", e.X, e.Y); startVector = MapToSphere((float)e.X, (float)e.Y); //startEyeVector = Position - Target; /*lastRot = currentRot; // Calculate the current rotation for the first time if (currentRot == Quaternion.Identity) { Vector3 eyeVector = Position - Target; eyeVector.Normalize(); // Compute the cross product of the default and current eye vectors. Vector3 cross = Vector3.Cross(defaultEyeVector, eyeVector); // Is the perpendicular length essentially non-zero? if (cross.Length > 1.0e-5f) { float angle = (float) Math.Acos(Vector3.Dot(defaultEyeVector, eyeVector)); // Calculate rotation relative to the default eye vector (0,0,1) lastRot = Quaternion.FromAxisAngle(cross, angle); } }*/ startPos = new Vector2((float) e.X, (float) e.Y); return true; } return false; }
public virtual void MouseWheel(object sender, MouseDescriptor e) { // GUI has priority in handling mouse events // WheelDelta is already multiplied by 120 => Gwen expects a 60x multiplier so divide it by 2 if (GUIEnabled == false || Canvas == null || Canvas.Input_MouseWheel(e.WheelDelta / 2) == false) { // Then the camera if (Camera == null || Camera.MouseWheel(e) == false) { if (OnMouseWheel != null) OnMouseWheel(e); } } }
public virtual void MouseMove(object sender, MouseDescriptor e) { int dx = e.X - prevMouseX; int dy = e.Y - prevMouseY; prevMouseX = e.X; prevMouseY = e.Y; // GUI has priority in handling mouse events if (GUIEnabled == false || Canvas == null || Canvas.Input_MouseMoved(e.X, e.Y, dx, dy) == false) { // Then the camera if (Camera == null || Camera.MouseMove(e) == false) { if (OnMouseMove != null) OnMouseMove(e); } } }
public virtual Model MouseUp(object sender, MouseDescriptor e) { // GUI has priority in handling mouse events if (GUIEnabled == false || Canvas == null || Canvas.Input_MouseButton((int) e.Button, false) == false) { //Console.WriteLine("MouseUp unhandled"); // Then the camera if (Camera == null || Camera.MouseUp(e) == false) { if (OnMouseUp != null) OnMouseUp(e); // Selection & Dragbox Selection if (SelectionEnabled && e.Button == SelectButton) { // Do a hit test. ZComponent comp = MousePick(e.X, e.Y); if (comp != null) { Console.WriteLine("MousePick result: {0}", comp.Name); SelectedObject = comp as Model; return SelectedObject; } } } } return null; }
public virtual void MouseDown(object sender, MouseDescriptor e) { // GUI has priority in handling mouse events if (GUIEnabled == false || Canvas == null || Canvas.Input_MouseButton((int) e.Button, true) == false) { //Console.WriteLine("MouseDown unhandled"); // Then the camera if (Camera == null || Camera.MouseDown(e) == false) { if (OnMouseDown != null) OnMouseDown(e); // Selection & Dragbox Selection } } }