Example #1
0
        public static Quaternion CalculateNeckRotation(Quaternion hipRotation, Quaternion headRotation)
        {
            Vector3    headAnglesCharacterSpace = (Quaternion.Inverse(hipRotation) * headRotation).eulerAngles;
            float      neckYRotation            = UnityAngles.Normalize(headAnglesCharacterSpace.y) * 0.6F;
            Quaternion neckRotation             = hipRotation * Quaternion.Euler(headAnglesCharacterSpace.x, neckYRotation, headAnglesCharacterSpace.z);

            return(neckRotation);
        }
Example #2
0
        public static Quaternion CalculateChestRotation(Quaternion chestRotation, Quaternion hipRotation, Quaternion headRotation)
        {
            Vector3    chestAngles = chestRotation.eulerAngles;
            Vector3    headAnglesCharacterSpace = (Quaternion.Inverse(hipRotation) * headRotation).eulerAngles;
            float      chestYRotation           = UnityAngles.Normalize(headAnglesCharacterSpace.y) * 0.3F;
            Quaternion newChestRotation         = hipRotation * Quaternion.Euler(chestAngles.x, chestYRotation, chestAngles.z);

            return(newChestRotation);
        }
Example #3
0
            protected float CalculateFingerCurl()
            {
                Quaternion rotation = proximal.target.transform.localRotation * Quaternion.Inverse(proximal.target.baseRotation);
                float      angle    = fingers.handTarget.isLeft ? rotation.eulerAngles.z : -rotation.eulerAngles.z;

                angle = UnityAngles.Normalize(angle);
                _curl = angle / 70;

                _curl = Mathf.Clamp(_curl, -0.1F, 1);
                return(_curl);
            }
Example #4
0
        protected Vector3 CalculateTorque()
        {
            Quaternion sollRotation = handTarget.hand.target.transform.rotation * handTarget.hand.target.toBoneRotation;
            Quaternion istRotation  = handTarget.hand.bone.transform.rotation;
            Quaternion dRot         = sollRotation * Quaternion.Inverse(istRotation);

            float   angle;
            Vector3 axis;

            dRot.ToAngleAxis(out angle, out axis);
            angle = UnityAngles.Normalize(angle);

            Vector3 angleDifference = axis.normalized * (angle * Mathf.Deg2Rad);
            Vector3 torque          = angleDifference * handTarget.strength * 0.1F;

            return(torque);
        }
Example #5
0
 public float GetSwing()
 {
     if (fingers == null || proximal.target.transform == null)
     {
         _swing = 0;
     }
     else if (this == fingers.thumb)
     {
         float angle = proximal.target.transform.localEulerAngles.z;
         _swing = UnityAngles.Normalize(angle) / 90;
     }
     else
     {
         float angle = proximal.target.transform.localEulerAngles.y;
         _swing = UnityAngles.Normalize(angle) / 90;
     }
     return(_swing);
 }
Example #6
0
            protected float CalculateThumbCurl()
            {
                Quaternion rotation = Quaternion.Inverse(proximal.target.transform.rotation) * distal.target.transform.rotation;
                float      angle    = fingers.handTarget.isLeft ? rotation.eulerAngles.z : -rotation.eulerAngles.z;

                angle = UnityAngles.Normalize(angle);
                angle = angle - 15;
                if (angle < 0)
                {
                    _curl = angle / 80;
                }
                else
                {
                    _curl = angle / 80;
                }

                _curl = Mathf.Clamp(_curl, -0.5F, 1);

                return(_curl);
            }