public ObjectSelectionGizmo(int id, Gizmo gizmo) { _id = id; _gizmo = gizmo; _boxScaleGizmo = gizmo.GetFirstBehaviourOfType <BoxGizmo>(); _transformGizmo = gizmo.GetFirstBehaviourOfType <ObjectTransformGizmo>(); _extrudeGizmo = gizmo.GetFirstBehaviourOfType <ObjectExtrudeGizmo>(); }
public bool AddBehaviour(IGizmoBehaviour behaviour) { if (behaviour == null || behaviour.Gizmo != null) { return(false); } GizmoBehaviorInitParams initParams = new GizmoBehaviorInitParams(); initParams.Gizmo = this; behaviour.Init_SystemCall(initParams); if (!_behaviours.Add(behaviour)) { return(false); } Type behaviourType = behaviour.GetType(); if (behaviourType == typeof(MoveGizmo)) { _moveGizmo = behaviour as MoveGizmo; } else if (behaviourType == typeof(RotationGizmo)) { _rotationGizmo = behaviour as RotationGizmo; } else if (behaviourType == typeof(ScaleGizmo)) { _scaleGizmo = behaviour as ScaleGizmo; } else if (behaviourType == typeof(UniversalGizmo)) { _universalGizmo = behaviour as UniversalGizmo; } else if (behaviourType == typeof(SceneGizmo)) { _sceneGizmo = behaviour as SceneGizmo; } else if (behaviourType == typeof(BoxGizmo)) { _boxGizmo = behaviour as BoxGizmo; } else if (behaviourType == typeof(ObjectTransformGizmo)) { _objectTransformGizmo = behaviour as ObjectTransformGizmo; } else if (behaviourType == typeof(ObjectExtrudeGizmo)) { _objectExtrudeGizmo = behaviour as ObjectExtrudeGizmo; } behaviour.OnAttached(); behaviour.OnEnabled(); return(true); }
public ObjectTransformGizmo CreateObjectUniversalGizmo() { UniversalGizmo universalGizmo = CreateUniversalGizmo(); ObjectTransformGizmo transformGizmo = universalGizmo.Gizmo.AddBehaviour <ObjectTransformGizmo>(); transformGizmo.SetTransformChannelFlags(ObjectTransformGizmo.Channels.Position | ObjectTransformGizmo.Channels.Rotation | ObjectTransformGizmo.Channels.Scale); return(transformGizmo); }
public ObjectTransformGizmo CreateObjectRotationGizmo() { RotationGizmo rotationGizmo = CreateRotationGizmo(); ObjectTransformGizmo transformGizmo = rotationGizmo.Gizmo.AddBehaviour <ObjectTransformGizmo>(); transformGizmo.SetTransformChannelFlags(ObjectTransformGizmo.Channels.Rotation); return(transformGizmo); }
public ObjectTransformGizmo CreateObjectMoveGizmo() { MoveGizmo moveGizmo = CreateMoveGizmo(); ObjectTransformGizmo transformGizmo = moveGizmo.Gizmo.AddBehaviour <ObjectTransformGizmo>(); transformGizmo.SetTransformChannelFlags(ObjectTransformGizmo.Channels.Position); return(transformGizmo); }
public ObjectTransformGizmo CreateObjectScaleGizmo() { ScaleGizmo scaleGizmo = CreateScaleGizmo(); ObjectTransformGizmo transformGizmo = scaleGizmo.Gizmo.AddBehaviour <ObjectTransformGizmo>(); transformGizmo.SetTransformChannelFlags(ObjectTransformGizmo.Channels.Scale); transformGizmo.SetTransformSpace(GizmoSpace.Local); transformGizmo.MakeTransformSpacePermanent(); return(transformGizmo); }
public void Initialize_SystemCall() { ObjectTransformGizmo objectMoveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo(); RegisterGizmo(ObjectSelectionGizmoId.MoveGizmo, objectMoveGizmo.Gizmo); _workGizmo = GetObjectSelectionGizmo(objectMoveGizmo.Gizmo); _workGizmo.Gizmo.SetEnabled(false); _workGizmoId = ObjectSelectionGizmoId.MoveGizmo; ObjectTransformGizmo objectRotationGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo(); RegisterGizmo(ObjectSelectionGizmoId.RotationGizmo, objectRotationGizmo.Gizmo); objectRotationGizmo.Gizmo.SetEnabled(false); ObjectTransformGizmo objectScaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo(); RegisterGizmo(ObjectSelectionGizmoId.ScaleGizmo, objectScaleGizmo.Gizmo); objectScaleGizmo.Gizmo.SetEnabled(false); BoxGizmo objectBoxScaleGizmo = RTGizmosEngine.Get.CreateObjectBoxScaleGizmo(); RegisterGizmo(ObjectSelectionGizmoId.BoxScaleGizmo, objectBoxScaleGizmo.Gizmo); objectBoxScaleGizmo.Gizmo.SetEnabled(false); ObjectTransformGizmo objectUniversalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo(); RegisterGizmo(ObjectSelectionGizmoId.UniversalGizmo, objectUniversalGizmo.Gizmo); objectUniversalGizmo.Gizmo.SetEnabled(false); ObjectExtrudeGizmo objectExtrudeGizmo = RTGizmosEngine.Get.CreateObjectExtrudeGizmo(); RegisterGizmo(ObjectSelectionGizmoId.ExtrudeGizmo, objectExtrudeGizmo.Gizmo); objectExtrudeGizmo.Gizmo.SetEnabled(false); RTUndoRedo.Get.UndoEnd += OnUndoRedo; RTUndoRedo.Get.RedoEnd += OnUndoRedo; RTObjectSelection.Get.Changed += OnObjectSelectionChanged; RTObjectSelection.Get.Rotated += OnObjectSelectionRotated; RTObjectSelection.Get.Enabled += OnObjectSelectionEnabled; RTObjectSelection.Get.Disabled += OnObjectSelectionDisabled; RTObjectSelection.Get.ManipSessionBegin += OnObjectSelectionManipSessionBegin; RTObjectSelection.Get.ManipSessionEnd += OnObjectSelectionManipSessionEnd; SetTransformSpace(GizmoSpace.Local); SetTransformPivot(GizmoObjectTransformPivot.ObjectGroupCenter); }
public bool RemoveBehaviour(IGizmoBehaviour behaviour) { if (behaviour == null) { return(false); } if (behaviour == _moveGizmo) { _moveGizmo = null; } else if (behaviour == _rotationGizmo) { _rotationGizmo = null; } else if (behaviour == _scaleGizmo) { _scaleGizmo = null; } else if (behaviour == _universalGizmo) { _universalGizmo = null; } else if (behaviour == _sceneGizmo) { _sceneGizmo = null; } else if (behaviour == _boxGizmo) { _boxGizmo = null; } else if (behaviour == _objectTransformGizmo) { _objectTransformGizmo = null; } else if (behaviour == _objectExtrudeGizmo) { _objectExtrudeGizmo = null; } return(_behaviours.Remove(behaviour)); }
private bool RegisterGizmo(int gizmoId, Gizmo gizmo) { if (IsGizmoRegistered(gizmoId) || IsGizmoRegistered(gizmo)) { return(false); } _allGizmos.Add(new ObjectSelectionGizmo(gizmoId, gizmo)); ObjectTransformGizmo transformGizmo = gizmo.GetFirstBehaviourOfType <ObjectTransformGizmo>(); if (transformGizmo != null) { _objectTransformGizmos.Add(transformGizmo); transformGizmo.SetTargetObjects(_targetObjectCollection); } var moveGizmo = gizmo.GetFirstBehaviourOfType <MoveGizmo>(); if (moveGizmo != null) { moveGizmo.SharedSettings2D = MoveGizmoSettings2D; moveGizmo.SharedSettings3D = MoveGizmoSettings3D; moveGizmo.SharedLookAndFeel2D = MoveGizmoLookAndFeel2D; moveGizmo.SharedLookAndFeel3D = MoveGizmoLookAndFeel3D; moveGizmo.SharedHotkeys = MoveGizmoHotkeys; moveGizmo.SetVertexSnapTargetObjects(_targetObjectCollection); if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectMoveGizmoSettings; } } var rotationGizmo = gizmo.GetFirstBehaviourOfType <RotationGizmo>(); if (rotationGizmo != null) { rotationGizmo.SharedSettings3D = RotationGizmoSettings3D; rotationGizmo.SharedLookAndFeel3D = RotationGizmoLookAndFeel3D; rotationGizmo.SharedHotkeys = RotationGizmoHotkeys; if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectRotationGizmoSettings; } } var scaleGizmo = gizmo.GetFirstBehaviourOfType <ScaleGizmo>(); if (scaleGizmo != null) { scaleGizmo.SharedSettings3D = ScaleGizmoSettings3D; scaleGizmo.SharedLookAndFeel3D = ScaleGizmoLookAndFeel3D; scaleGizmo.SharedHotkeys = ScaleGizmoHotkeys; scaleGizmo.SetScaleGuideTargetObjects(_targetObjectCollection); if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectScaleGizmoSettings; } } var boxScaleGizmo = gizmo.GetFirstBehaviourOfType <BoxGizmo>(); if (boxScaleGizmo != null) { boxScaleGizmo.SharedSettings3D = BoxScaleGizmoSettings3D; boxScaleGizmo.SharedLookAndFeel3D = BoxScaleGizmoLookAndFeel3D; boxScaleGizmo.SharedHotkeys = BoxScaleGizmoHotkeys; } var universalGizmo = gizmo.GetFirstBehaviourOfType <UniversalGizmo>(); if (universalGizmo != null) { universalGizmo.SharedSettings2D = UniversalGizmoSettings2D; universalGizmo.SharedSettings3D = UniversalGizmoSettings3D; universalGizmo.SharedLookAndFeel2D = UniversalGizmoLookAndFeel2D; universalGizmo.SharedLookAndFeel3D = UniversalGizmoLookAndFeel3D; universalGizmo.SharedHotkeys = UniversalGizmoHotkeys; universalGizmo.SetMvVertexSnapTargetObjects(_targetObjectCollection); universalGizmo.SetScaleGuideTargetObjects(_targetObjectCollection); if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectUniversalGizmoSettings; } } var extrudeGizmo = gizmo.GetFirstBehaviourOfType <ObjectExtrudeGizmo>(); if (extrudeGizmo != null) { extrudeGizmo.SharedLookAndFeel3D = ExtrudeGizmoLookAndFeel3D; extrudeGizmo.SharedHotkeys = ExtrudeGozmoHotkeys; extrudeGizmo.SetExtrudeTargets(_targetObjectCollection); } gizmo.PostEnabled += OnGizmoPostEnabled; return(true); }