public void UpdateGizmo() { if (this.gizmoNode == null) { return; } if (Selected != null && Selected.UsesGizmos && Selected != ActiveViewport.CameraEditor) { Mogre.Vector3 position = Selected.DerivedPosition; Mogre.Vector4 rect = new Vector4(); ActiveViewport.GetRect(ref rect); float minSize = System.Math.Min(rect.z, rect.w); float distance = (position - ActiveViewport.CameraEditor.DerivedPosition).Length; distance /= (minSize / 20.0f); this.gizmoNode.SetPosition(position.x, position.y, position.z); this.gizmoNode.SetOrientation(Selected.DerivedOrientation.w, Selected.DerivedOrientation.x, Selected.DerivedOrientation.y, Selected.DerivedOrientation.z); this.gizmoNode.SetScale(distance, distance, distance); this.gizmoNode.SetVisible(true); } else { this.gizmoNode.SetVisible(false); } }
public void OnMouseMiddleDown(Mogre.Vector2 point, MouseDevice mouseDevice) { ViewportEditor vp = GetViewportEditorFromPoint(point); if (vp != null) { ActiveViewport = vp; Mogre.Vector4 rect = new Mogre.Vector4(); ActiveViewport.GetRect(ref rect); ActiveViewport.OnMouseMiddleDown(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice); } }
public void OnMouseMiddleUp(Mogre.Vector2 point, MouseDevice mouseDevice) { if (ActiveViewport == null) { return; } Mogre.Vector4 rect = new Mogre.Vector4(); ActiveViewport.GetRect(ref rect); if (PointIsInRect(point, rect)) { ActiveViewport.OnMouseMiddleUp(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice); } }
public void OnDragDrop(IDataObject data, Point pt) { Mogre.Vector4 drect = new Mogre.Vector4(); ActiveViewport.GetRect(ref drect); Mogre.Vector2 dropPos = new Mogre.Vector2((float)(pt.X - drect.x) / drect.z, (float)(pt.Y - drect.y) / drect.w); DragData dragData = data.GetData(typeof(DragData)) as DragData; foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers) { if (handler.Key == dragData.Source) { handler.Value.OnDragDrop(dragData, ActiveViewport.Handle as Mogre.Viewport, dropPos); break; } } this.activeDragData = null; }
public bool OnDragOver(IDataObject data, Point pt) { Mogre.Vector4 rect = new Mogre.Vector4(); ViewportEditor vp = null; int ZOrder = -1000; foreach (KeyValuePair <string, BaseEditor> it in GetObjectsByType(EditorType.Viewport)) { int order = ((it.Value) as ViewportEditor).GetRect(ref rect); if ((rect.x <= pt.X) && (rect.y <= pt.Y) && ((rect.y + rect.w) >= pt.Y) && (order > ZOrder)) { ZOrder = order; vp = (it.Value) as ViewportEditor; } } if (vp != null) { ActiveViewport = vp; ActiveViewport.GetRect(ref rect); DragData dragData = data.GetData(typeof(DragData)) as DragData; foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers) { if (handler.Key == dragData.Source) { Mogre.Vector2 point = new Mogre.Vector2((float)(pt.X - rect.x) / rect.z, (float)(pt.Y - rect.y) / rect.w); return(handler.Value.OnDragOver(dragData, ActiveViewport.Handle as Mogre.Viewport, point)); } } return(true); } return(false); }
public void OnMouseWheel(Mogre.Vector2 point, float delta, MouseDevice mouseDevice) { if (ActiveViewport == null) { return; } Mogre.Vector4 rect = new Mogre.Vector4(); ActiveViewport.GetRect(ref rect); if (this.activeDragData != null) { foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers) { if (handler.Key == this.activeDragData.Source) { handler.Value.OnDragWheel(this.activeDragData, ActiveViewport.Handle as Mogre.Viewport, delta); return; } } } ActiveViewport.OnMouseWheel(point - new Mogre.Vector2(rect.x, rect.y), delta, mouseDevice); }