Exemple #1
0
        private void Init()
        {
            if (Chain.Joints == null || Chain.Joints.Count != 3)
            {
                Debug.LogError("Fetal !: the chain joints are undefined");
                return;
            }

            Chain.InitiateJoints();
            Chain.Weight = 1;

            _EEAnimRot = Chain.GetEndEffector().rotation;
            EE         = Chain.GetEndEffector();

            _init = true;
        }
Exemple #2
0
 // Token: 0x06002772 RID: 10098 RVA: 0x000B70C0 File Offset: 0x000B52C0
 public Core.Chain LeftLegChain()
 {
     if (!this.IsReady())
     {
         return(null);
     }
     if (this.rigType != RigReader.RigType.Humanoid)
     {
         return(null);
     }
     Core.Chain chain = new Core.Chain();
     chain.joints.Add(this.l_lowerbody.upperLeg);
     chain.joints.Add(this.l_lowerbody.lowerLeg);
     chain.joints.Add(this.l_lowerbody.foot);
     chain.InitiateJoints();
     return(chain);
 }
        /// <summary>
        /// Process a 2 bones chain with a specific "epsilon" value
        /// </summary>
        /// <param name="chain"></param>
        /// <param name="eps">a specific value, not bounded to the global Epsilon</param>
        public static void Process(Core.Chain chain, float eps)
        {
            if (chain.Initiated == false)
            {
                chain.InitiateJoints();
            }

            if (chain.Joints.Count != 3)
            {
                Debug.LogError("The Analytical Solver only works with 3-joints(2 bones) chain configurations");
                return;
            }

            Core.Joint A = chain.Joints[0];
            Core.Joint B = chain.Joints[1];
            Core.Joint C = chain.Joints[2];
            Vector3    T = chain.GetIKTarget();

            Vector3 AB = Vector3.Normalize(B.joint.position - A.joint.position);
            Vector3 AC = Vector3.Normalize(C.joint.position - A.joint.position);
            Vector3 CB = Vector3.Normalize(B.joint.position - C.joint.position);
            Vector3 TA = A.joint.position - T;

            float l_ab = A.length;
            float l_cb = B.length;
            float l_at = GenericMath.Clamp(TA.magnitude, eps, l_ab + l_cb - eps);

            float kneeCurrent = GenericMath.VectorsAngle(AB, CB);
            float kneeTarget  = GenericMath.CosineRule(A.length, B.length, l_at);
            float kneeDelta   = kneeTarget - kneeCurrent;

            Vector3 axis = GenericMath.TransformVector(Vector3.Normalize(Vector3.Cross(AC, AB)),
                                                       Quaternion.Inverse(B.joint.rotation));
            Quaternion q1 = Quaternion.AngleAxis(kneeDelta, axis);

            Quaternion knee = Quaternion.Lerp(B.joint.rotation, GenericMath.ApplyQuaternion(B.joint.rotation, q1),
                                              chain.Weight);

            B.joint.rotation = knee;

            Quaternion q2    = Quaternion.FromToRotation(A.joint.position - C.joint.position, TA);
            Quaternion thigh = Quaternion.Lerp(A.joint.rotation, GenericMath.ApplyQuaternion(q2, A.joint.rotation),
                                               chain.Weight);

            A.joint.rotation = thigh;
        }
Exemple #4
0
 // Token: 0x06002770 RID: 10096 RVA: 0x000B6FC8 File Offset: 0x000B51C8
 public Core.Chain LeftArmChain()
 {
     if (!this.IsReady())
     {
         return(null);
     }
     if (this.rigType != RigReader.RigType.Humanoid)
     {
         return(null);
     }
     Core.Chain chain = new Core.Chain();
     chain.joints.Add(this.l_upperbody.shoulder);
     chain.joints.Add(this.l_upperbody.upperArm);
     chain.joints.Add(this.l_upperbody.lowerArm);
     chain.joints.Add(this.l_upperbody.hand);
     chain.InitiateJoints();
     return(chain);
 }
Exemple #5
0
 // Token: 0x0600274F RID: 10063 RVA: 0x000B62EC File Offset: 0x000B44EC
 public static bool Process(Core.Chain chain)
 {
     if (chain.joints.Count <= 0)
     {
         return(false);
     }
     if (!chain.initiated)
     {
         chain.InitiateJoints();
     }
     chain.MapVirtualJoints();
     for (int i = 0; i < chain.iterations; i++)
     {
         FastReachSolver.SolveInward(chain);
         FastReachSolver.SolveOutward(chain);
     }
     FastReachSolver.MapSolverOutput(chain);
     return(true);
 }
Exemple #6
0
        /// <summary>
        /// Build the right leg chain
        /// </summary>
        /// <returns></returns>
        private Core.Chain LeftLegChain()
        {
            if (!IsReady())
            {
                return(null);
            }
            if (rigType != RigType.Humanoid)
            {
                return(null);
            }
            Core.Chain chain = new Core.Chain();

            chain.Joints.Add(l_lowerbody.upperLeg);
            chain.Joints.Add(l_lowerbody.lowerLeg);
            chain.Joints.Add(l_lowerbody.foot);

            chain.InitiateJoints();

            return(chain);
        }
Exemple #7
0
        /// <summary>
        /// Build the left arm IK chain
        /// </summary>
        /// <returns></returns>
        private Core.Chain LeftArmChain()
        {
            if (!IsReady())
            {
                return(null);
            }
            if (rigType != RigType.Humanoid)
            {
                return(null);
            }
            Core.Chain chain = new Core.Chain();

            chain.Joints.Add(l_upperbody.shoulder);
            chain.Joints.Add(l_upperbody.upperArm);
            chain.Joints.Add(l_upperbody.lowerArm);
            chain.Joints.Add(l_upperbody.hand);

            chain.InitiateJoints();

            return(chain);
        }