CalculateDirectionAxis() private static method

private static CalculateDirectionAxis ( Vector3 point ) : Vector3
point UnityEngine.Vector3
return UnityEngine.Vector3
Beispiel #1
0
 private void BuildJoints()
 {
     foreach (RagdollBuilder.BoneInfo boneInfo in this.bones)
     {
         if (boneInfo.parent != null)
         {
             CharacterJoint characterJoint = boneInfo.anchor.gameObject.AddComponent <CharacterJoint>();
             boneInfo.joint                     = characterJoint;
             characterJoint.axis                = RagdollBuilder.CalculateDirectionAxis(boneInfo.anchor.InverseTransformDirection(boneInfo.axis));
             characterJoint.swingAxis           = RagdollBuilder.CalculateDirectionAxis(boneInfo.anchor.InverseTransformDirection(boneInfo.normalAxis));
             characterJoint.anchor              = Vector3.zero;
             characterJoint.connectedBody       = boneInfo.parent.anchor.GetComponent <Rigidbody>();
             characterJoint.enablePreprocessing = false;
             SoftJointLimit softJointLimit = default(SoftJointLimit);
             softJointLimit.contactDistance = 0f;
             softJointLimit.limit           = boneInfo.minLimit;
             characterJoint.lowTwistLimit   = softJointLimit;
             softJointLimit.limit           = boneInfo.maxLimit;
             characterJoint.highTwistLimit  = softJointLimit;
             softJointLimit.limit           = boneInfo.swingLimit;
             characterJoint.swing1Limit     = softJointLimit;
             softJointLimit.limit           = 0f;
             characterJoint.swing2Limit     = softJointLimit;
         }
     }
 }
Beispiel #2
0
 private void CalculateAxes()
 {
     if (this.head != null && this.pelvis != null)
     {
         this.up = RagdollBuilder.CalculateDirectionAxis(this.pelvis.InverseTransformPoint(this.head.position));
     }
     if (this.rightElbow != null && this.pelvis != null)
     {
         Vector3 vector;
         Vector3 point;
         this.DecomposeVector(out vector, out point, this.pelvis.InverseTransformPoint(this.rightElbow.position), this.up);
         this.right = RagdollBuilder.CalculateDirectionAxis(point);
     }
     this.forward = Vector3.Cross(this.right, this.up);
     if (this.flipForward)
     {
         this.forward = -this.forward;
     }
 }
 private void CalculateAxes()
 {
     if ((UnityEngine.Object) this.head != (UnityEngine.Object)null && (UnityEngine.Object) this.pelvis != (UnityEngine.Object)null)
     {
         this.up = RagdollBuilder.CalculateDirectionAxis(this.pelvis.InverseTransformPoint(this.head.position));
     }
     if ((UnityEngine.Object) this.rightElbow != (UnityEngine.Object)null && (UnityEngine.Object) this.pelvis != (UnityEngine.Object)null)
     {
         Vector3 normalCompo;
         Vector3 tangentCompo;
         this.DecomposeVector(out normalCompo, out tangentCompo, this.pelvis.InverseTransformPoint(this.rightElbow.position), this.up);
         this.right = RagdollBuilder.CalculateDirectionAxis(tangentCompo);
     }
     this.forward = Vector3.Cross(this.right, this.up);
     if (!this.flipForward)
     {
         return;
     }
     this.forward = -this.forward;
 }
        private void BuildJoints()
        {
            IEnumerator enumerator = this.bones.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    RagdollBuilder.BoneInfo boneInfo = (RagdollBuilder.BoneInfo)enumerator.Current;
                    if (boneInfo.parent != null)
                    {
                        CharacterJoint characterJoint = boneInfo.anchor.gameObject.AddComponent <CharacterJoint>();
                        boneInfo.joint                     = characterJoint;
                        characterJoint.axis                = RagdollBuilder.CalculateDirectionAxis(boneInfo.anchor.InverseTransformDirection(boneInfo.axis));
                        characterJoint.swingAxis           = RagdollBuilder.CalculateDirectionAxis(boneInfo.anchor.InverseTransformDirection(boneInfo.normalAxis));
                        characterJoint.anchor              = Vector3.zero;
                        characterJoint.connectedBody       = boneInfo.parent.anchor.GetComponent <Rigidbody>();
                        characterJoint.enablePreprocessing = false;
                        SoftJointLimit softJointLimit = default(SoftJointLimit);
                        softJointLimit.contactDistance = 0f;
                        softJointLimit.limit           = boneInfo.minLimit;
                        characterJoint.lowTwistLimit   = softJointLimit;
                        softJointLimit.limit           = boneInfo.maxLimit;
                        characterJoint.highTwistLimit  = softJointLimit;
                        softJointLimit.limit           = boneInfo.swingLimit;
                        characterJoint.swing1Limit     = softJointLimit;
                        softJointLimit.limit           = 0f;
                        characterJoint.swing2Limit     = softJointLimit;
                    }
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }