Exemplo n.º 1
0
        public void RotateUsingKeyboardSettings(TransformAxis rotationAxis)
        {
            if (IsAnyMouseSessionActive)
            {
                return;
            }

            ObjectKeyboardRotationSettings keyboardRotationSettings = ObjectPlacementGuideSettings.Get().KeyboardRotationSettings;

            UndoEx.RecordForToolAction(_transform);

            AxisKeyboardRotationSettings axisKeyboardRotationSettings = keyboardRotationSettings.XAxisRotationSettings;

            if (rotationAxis == TransformAxis.Y)
            {
                axisKeyboardRotationSettings = keyboardRotationSettings.YAxisRotationSettings;
            }
            else if (rotationAxis == TransformAxis.Z)
            {
                axisKeyboardRotationSettings = keyboardRotationSettings.XAxisRotationSettings;
            }

            gameObject.RotateHierarchyBoxAroundPoint(axisKeyboardRotationSettings.RotationAmountInDegrees,
                                                     TransformAxes.GetVector(rotationAxis, TransformSpace.Global, _transform),
                                                     gameObject.GetHierarchyWorldOrientedBox().Center);

            UndoEx.RecordForToolAction(_sourcePrefab.ActivationSettings);
            _sourcePrefab.ActivationSettings.WorldRotation = _transform.rotation;
        }
Exemplo n.º 2
0
        private void RotateObjectAroundAxis()
        {
            AxisMouseRotationSettings axisMouseRotationSettings = _mouseRotationSettings.XAxisRotationSettings;

            if (_rotationAxis == TransformAxis.Y)
            {
                axisMouseRotationSettings = _mouseRotationSettings.YAxisRotationSettings;
            }
            else if (_rotationAxis == TransformAxis.Z)
            {
                axisMouseRotationSettings = _mouseRotationSettings.ZAxisRotationSettings;
            }

            float   rotationAmountInDegrees = MouseCursor.Instance.OffsetSinceLastMouseMove.x * axisMouseRotationSettings.MouseSensitivity;
            Vector3 rotationAxis            = TransformAxes.GetVector(_rotationAxis, TransformSpace.Global, _gameObjectTransform);

            RotateObjectAroundAxis(rotationAxis, rotationAmountInDegrees);
        }
        private static void RandomizeRotationForAxis(Transform objectTransform, TransformAxis axis, AxisRotationRandomizationModeSettings rotationRandomizationModeSettings)
        {
            Vector3 axisVector = TransformAxes.GetVector(axis, TransformSpace.Global, objectTransform);

            RandomizeRotationForAxis(objectTransform, axisVector, rotationRandomizationModeSettings);
        }