コード例 #1
0
        public override void UpdateTracking()
        {
            if (_animator.runtimeAnimatorController == null)
            {
                for (IKBone ikBone = 0; ikBone < IKBone.LastBone; ikBone++)
                {
                    GetIKSolver(ikBone).ResetIKChain();
                }
            }

            QuickIKSolver ikSolverHips = GetIKSolver(IKBone.Hips);
            QuickIKSolver ikSolverHead = GetIKSolver(IKBone.Head);

            //float chainLength = Vector3.Distance(_animator.GetBoneTransform(HumanBodyBones.Hips).position, _animator.GetBoneTransform(HumanBodyBones.Head).position);
            //Vector3 v = (ikSolverHips._targetLimb.position - ikSolverHead._targetLimb.position).normalized;
            //ikSolverHips._targetLimb.position = ikSolverHead._targetLimb.position + v * chainLength;

            //Update the IK for the body controllers
            ikSolverHips.UpdateIK();
            ikSolverHead.UpdateIK();

            GetIKSolver(IKBone.LeftHand).UpdateIK();
            GetIKSolver(IKBone.RightHand).UpdateIK();
            GetIKSolver(IKBone.LeftFoot).UpdateIK();
            GetIKSolver(IKBone.RightFoot).UpdateIK();

            //Update the IK for the fingers controllers
            UpdateIKFingers();

            //Update the IK for the face controllers
            for (IKBone ikBone = IKBone.LeftEye; ikBone <= IKBone.RightEye; ikBone++)
            {
                GetIKSolver(ikBone).UpdateIK();
            }
        }
コード例 #2
0
        protected virtual void MirrorPose(QuickIKSolver srcIKSolver, QuickIKSolver dstIKSolver)
        {
            Transform srcParent = srcIKSolver._targetLimb.parent;
            Transform dstParent = dstIKSolver._targetLimb.parent;

            srcIKSolver._targetLimb.parent = dstIKSolver._targetLimb.parent = transform;

            Transform srcHintParent = null;
            Transform dstHintParent = null;

            if (srcIKSolver._targetHint && dstIKSolver._targetHint)
            {
                srcHintParent = srcIKSolver._targetHint.parent;
                dstHintParent = dstIKSolver._targetHint.parent;
                srcIKSolver._targetHint.parent = dstIKSolver._targetHint.parent = transform;
            }

            MirrorIKTarget(srcIKSolver._targetLimb, dstIKSolver._targetLimb);
            MirrorIKTarget(srcIKSolver._targetHint, dstIKSolver._targetHint);

            srcIKSolver.UpdateIK();
            dstIKSolver.UpdateIK();

            //Restore the parent for the IKTargetLimbs
            srcIKSolver._targetLimb.parent     = srcParent;
            dstIKSolver._targetLimb.parent     = dstParent;
            srcIKSolver._targetLimb.localScale = dstIKSolver._targetLimb.localScale = Vector3.one;

            //Restore the parent for the IKTargetHints
            if (srcIKSolver._targetHint && dstIKSolver._targetHint)
            {
                srcIKSolver._targetHint.parent     = srcHintParent;
                dstIKSolver._targetHint.parent     = dstHintParent;
                srcIKSolver._targetHint.localScale = dstIKSolver._targetHint.localScale = Vector3.one;
            }
        }