Beispiel #1
0
        /// <summary>
        /// Applies the rotation options to a passed transform. The rotation should
        /// already be set. This just returns axis to 0 depending on the constraint
        /// OUTPUT_ROT_OPTIONS
        /// </summary>
        /// <param name="xform">The transform to process for</param>
        /// <param name="option">The UnityConstraints.OUTPUT_ROT_OPTIONS to use</param>
        public static void MaskOutputRotations(Transform xform, OUTPUT_ROT_OPTIONS option)
        {
            Vector3 angles;

            switch (option)
            {
            case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldAll:
                // Already done
                break;

            case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldX:
                angles            = xform.eulerAngles;
                angles.y          = 0;
                angles.z          = 0;
                xform.eulerAngles = angles;
                break;

            case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldY:
                angles            = xform.eulerAngles;
                angles.x          = 0;
                angles.z          = 0;
                xform.eulerAngles = angles;
                break;

            case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldZ:
                angles            = xform.eulerAngles;
                angles.x          = 0;
                angles.y          = 0;
                xform.eulerAngles = angles;
                break;

            case UnityConstraints.OUTPUT_ROT_OPTIONS.LocalX:
                angles   = xform.localEulerAngles;
                angles.y = 0;
                angles.z = 0;
                xform.localEulerAngles = angles;
                break;

            case UnityConstraints.OUTPUT_ROT_OPTIONS.LocalY:
                angles   = xform.localEulerAngles;
                angles.x = 0;
                angles.z = 0;
                xform.localEulerAngles = angles;
                break;

            case UnityConstraints.OUTPUT_ROT_OPTIONS.LocalZ:
                angles   = xform.localEulerAngles;
                angles.x = 0;
                angles.y = 0;
                xform.localEulerAngles = angles;
                break;
            }
        }
        /// <summary>
        /// Applies the rotation options to a passed transform. The rotation should
        /// already be set. This just returns axis to 0 depending on the constraint
        /// OUTPUT_ROT_OPTIONS
        /// </summary>
        /// <param name="xform">The transform to process for</param>
        /// <param name="option">The UnityConstraints.OUTPUT_ROT_OPTIONS to use</param>
        public static void MaskOutputRotations(Transform xform, OUTPUT_ROT_OPTIONS option)
        {
            Vector3 angles;
            switch (option)
            {
                case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldAll:
                    // Already done
                    break;

                case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldX:
                    angles = xform.eulerAngles;
                    angles.y = 0;
                    angles.z = 0;
                    xform.eulerAngles = angles;
                    break;

                case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldY:
                    angles = xform.eulerAngles;
                    angles.x = 0;
                    angles.z = 0;
                    xform.eulerAngles = angles;
                    break;

                case UnityConstraints.OUTPUT_ROT_OPTIONS.WorldZ:
                    angles = xform.eulerAngles;
                    angles.x = 0;
                    angles.y = 0;
                    xform.eulerAngles = angles;
                    break;

                case UnityConstraints.OUTPUT_ROT_OPTIONS.LocalX:
                    angles = xform.localEulerAngles;
                    angles.y = 0;
                    angles.z = 0;
                    xform.localEulerAngles = angles;
                    break;

                case UnityConstraints.OUTPUT_ROT_OPTIONS.LocalY:
                    angles = xform.localEulerAngles;
                    angles.x = 0;
                    angles.z = 0;
                    xform.localEulerAngles = angles;
                    break;

                case UnityConstraints.OUTPUT_ROT_OPTIONS.LocalZ:
                    angles = xform.localEulerAngles;
                    angles.x = 0;
                    angles.y = 0;
                    xform.localEulerAngles = angles;
                    break;
            }
        }