Esempio n. 1
0
        /// <summary>
        /// This function is called to change the type of work gizmo. This is
        /// used in the 'Update' function in response to the user pressing the
        /// W,E,R,T keys to switch between different gizmo types.
        /// </summary>
        private void SetWorkGizmoId(GizmoId gizmoId)
        {
            // If the specified gizmo id is the same as the current id, there is nothing left to do
            if (gizmoId == _workGizmoId)
            {
                return;
            }

            // Start with a clean slate and disable all gizmos
            _objectMoveGizmo.Gizmo.SetEnabled(false);
            _objectRotationGizmo.Gizmo.SetEnabled(false);
            _objectScaleGizmo.Gizmo.SetEnabled(false);
            _objectUniversalGizmo.Gizmo.SetEnabled(false);

            // At this point all gizmos are disabled. Now we need to check the gizmo id
            // and adjust the '_workGizmo' variable.
            _workGizmoId = gizmoId;
            if (gizmoId == GizmoId.Move)
            {
                _workGizmo = _objectMoveGizmo;
            }
            else if (gizmoId == GizmoId.Rotate)
            {
                _workGizmo = _objectRotationGizmo;
            }
            else if (gizmoId == GizmoId.Scale)
            {
                _workGizmo = _objectScaleGizmo;
            }
            else if (gizmoId == GizmoId.Universal)
            {
                _workGizmo = _objectUniversalGizmo;
            }

            // If we have any selected objects, we need to make sure the work gizmo is enabled
            if (_selectedObjects.Count != 0)
            {
                // Make sure the work gizmo is enabled. There is no need to check if the gizmo is already
                // enabled. The 'SetEnabled' call will simply be ignored if that is the case.
                _workGizmo.Gizmo.SetEnabled(true);

                // When working with transform spaces and pivots, the gizmos need to know about the pivot object.
                // This piece of information is necessary when the transform space is set to local because in that
                // case the gizmo will have its rotation synchronized with the target objects rotation. But because
                // there is more than one target object, we need to tell the gizmo which object to use. This is the
                // role if the pivot object in this case. This pivot object is also useful when the transform pivot
                // is set to 'ObjectMeshPivot' because it will be used to adjust the position of the gizmo.
                _workGizmo.SetTargetPivotObject(_selectedObjects[_selectedObjects.Count - 1]);
            }
        }
Esempio n. 2
0
 void OnSelectionChanged()
 {
     if (_selectObjects.Count != 0)
     {
         _workGizmo.Gizmo.SetEnabled(true);
         _workGizmo.SetTargetPivotObject(_selectObjects[_selectObjects.Count - 1]);
         //_workGizmo.RefreshPositionAndRotation();
     }
     else
     {
         _objectMoveGizmo.Gizmo.SetEnabled(false);
         _objectRotateionGizmo.Gizmo.SetEnabled(false);
         _objectScaleGizmo.Gizmo.SetEnabled(false);
         _objectUniversalGizmo.Gizmo.SetEnabled(false);
     }
 }