public static TQ GetWorldSpaceIKGoal(BakerHumanoidQT ikQT, BakerHumanoidQT rootQT, float time, float humanScale) { var tq = ikQT.Evaluate(time); var rTQ = rootQT.Evaluate(time); tq.q = rTQ.q * tq.q; tq.t = rTQ.t + rTQ.q * tq.t; tq.t *= humanScale; return(tq); }
void Awake() { animator = GetComponent <Animator>(); director = GetComponent <PlayableDirector>(); if (mode == Mode.AnimationStates || mode == Mode.AnimationClips) { if (animator == null || !animator.isHuman) { Debug.LogError("HumanoidBaker GameObject does not have a Humanoid Animator component, can not bake."); enabled = false; return; } animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } else if (mode == Mode.PlayableDirector) { if (director == null) { Debug.LogError("HumanoidBaker GameObject does not have a PlayableDirector component, can not bake."); } } muscles = new float[HumanTrait.MuscleCount]; bakerMuscles = new BakerMuscle[HumanTrait.MuscleCount]; for (int i = 0; i < bakerMuscles.Length; i++) { bakerMuscles[i] = new BakerMuscle(i); } rootQT = new BakerHumanoidQT("Root"); leftFootQT = new BakerHumanoidQT(animator.GetBoneTransform(HumanBodyBones.LeftFoot), AvatarIKGoal.LeftFoot, "LeftFoot"); rightFootQT = new BakerHumanoidQT(animator.GetBoneTransform(HumanBodyBones.RightFoot), AvatarIKGoal.RightFoot, "RightFoot"); leftHandQT = new BakerHumanoidQT(animator.GetBoneTransform(HumanBodyBones.LeftHand), AvatarIKGoal.LeftHand, "LeftHand"); rightHandQT = new BakerHumanoidQT(animator.GetBoneTransform(HumanBodyBones.RightHand), AvatarIKGoal.RightHand, "RightHand"); handler = new HumanPoseHandler(animator.avatar, animator.transform); }