Exemplo n.º 1
0
            public static bool AutoDetectReferences(Transform root, out VRIK.References references)
            {
                references = new VRIK.References();
                Animator componentInChildren = root.GetComponentInChildren <Animator>();

                if (componentInChildren == null || !componentInChildren.isHuman)
                {
                    Debug.LogWarning("VRIK needs a Humanoid Animator to auto-detect biped references. Please assign references manually.");
                    return(false);
                }
                references.root          = root;
                references.pelvis        = componentInChildren.GetBoneTransform(HumanBodyBones.Hips);
                references.spine         = componentInChildren.GetBoneTransform(HumanBodyBones.Spine);
                references.chest         = componentInChildren.GetBoneTransform(HumanBodyBones.Chest);
                references.neck          = componentInChildren.GetBoneTransform(HumanBodyBones.Neck);
                references.head          = componentInChildren.GetBoneTransform(HumanBodyBones.Head);
                references.leftShoulder  = componentInChildren.GetBoneTransform(HumanBodyBones.LeftShoulder);
                references.leftUpperArm  = componentInChildren.GetBoneTransform(HumanBodyBones.LeftUpperArm);
                references.leftForearm   = componentInChildren.GetBoneTransform(HumanBodyBones.LeftLowerArm);
                references.leftHand      = componentInChildren.GetBoneTransform(HumanBodyBones.LeftHand);
                references.rightShoulder = componentInChildren.GetBoneTransform(HumanBodyBones.RightShoulder);
                references.rightUpperArm = componentInChildren.GetBoneTransform(HumanBodyBones.RightUpperArm);
                references.rightForearm  = componentInChildren.GetBoneTransform(HumanBodyBones.RightLowerArm);
                references.rightHand     = componentInChildren.GetBoneTransform(HumanBodyBones.RightHand);
                references.leftThigh     = componentInChildren.GetBoneTransform(HumanBodyBones.LeftUpperLeg);
                references.leftCalf      = componentInChildren.GetBoneTransform(HumanBodyBones.LeftLowerLeg);
                references.leftFoot      = componentInChildren.GetBoneTransform(HumanBodyBones.LeftFoot);
                references.leftToes      = componentInChildren.GetBoneTransform(HumanBodyBones.LeftToes);
                references.rightThigh    = componentInChildren.GetBoneTransform(HumanBodyBones.RightUpperLeg);
                references.rightCalf     = componentInChildren.GetBoneTransform(HumanBodyBones.RightLowerLeg);
                references.rightFoot     = componentInChildren.GetBoneTransform(HumanBodyBones.RightFoot);
                references.rightToes     = componentInChildren.GetBoneTransform(HumanBodyBones.RightToes);
                return(true);
            }
Exemplo n.º 2
0
        /// <summary>
        /// Guesses the hand bones orientations ('Wrist To Palm Axis' and "Palm To Thumb Axis" of the arms) based on the provided references. if onlyIfZero is true, will only guess an orientation axis if it is Vector3.zero.
        /// </summary>
        public void GuessHandOrientations(VRIK.References references, bool onlyIfZero)
        {
            if (!references.isFilled)
            {
                Debug.LogWarning("VRIK References are not filled in, can not guess hand orientations. Right-click on VRIK header and slect 'Guess Hand Orientations' when you have filled in the References.");
                return;
            }

            if (leftArm.wristToPalmAxis == Vector3.zero || !onlyIfZero)
            {
                leftArm.wristToPalmAxis = GuessWristToPalmAxis(references.leftHand, references.leftForearm);
            }

            if (leftArm.palmToThumbAxis == Vector3.zero || !onlyIfZero)
            {
                leftArm.palmToThumbAxis = GuessPalmToThumbAxis(references.leftHand, references.leftForearm);
            }

            if (rightArm.wristToPalmAxis == Vector3.zero || !onlyIfZero)
            {
                rightArm.wristToPalmAxis = GuessWristToPalmAxis(references.rightHand, references.rightForearm);
            }

            if (rightArm.palmToThumbAxis == Vector3.zero || !onlyIfZero)
            {
                rightArm.palmToThumbAxis = GuessPalmToThumbAxis(references.rightHand, references.rightForearm);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets this VRIK up to the specified bone references.
        /// </summary>
        public void SetToReferences(VRIK.References references)
        {
            if (!references.isFilled)
            {
                Debug.LogError("Invalid references, one or more Transforms are missing.");
                return;
            }

            animator = references.root.GetComponent <Animator>();

            solverTransforms = references.GetTransforms();

            hasChest     = solverTransforms [3] != null;
            hasNeck      = solverTransforms[4] != null;
            hasShoulders = solverTransforms[6] != null && solverTransforms[10] != null;
            hasToes      = solverTransforms[17] != null && solverTransforms[21] != null;
            hasLegs      = solverTransforms[14] != null;
            hasArms      = solverTransforms[7] != null;

            readPositions = new Vector3[solverTransforms.Length];
            readRotations = new Quaternion[solverTransforms.Length];

            DefaultAnimationCurves();
            GuessHandOrientations(references, true);
        }