Ejemplo n.º 1
0
        public virtual void EvaluateHumanPose(float time, ref HumanPose pose)
        {
            if (_animator.isHuman)
            {
                pose.bodyPosition = GetAnimationCurve(CURVE_BODY_POSITION).EvaluateVector3(time);
                pose.bodyRotation = GetAnimationCurve(CURVE_BODY_ROTATION).EvaluateQuaternion(time);

                List <float> muscles = new List <float>();
                for (int i = 0; i < QuickHumanTrait.GetNumMuscles(); i++)
                {
                    muscles.Add(_curves[QuickHumanTrait.GetMuscleName(i)].Evaluate(time));
                }

                pose.muscles = muscles.ToArray();
            }
        }
Ejemplo n.º 2
0
        public virtual AnimationClip ToAnimationClip()
        {
            AnimationClip anim = new AnimationClip();

            QuickAnimationCurve curvePos = GetAnimationCurve(CURVE_BODY_POSITION);

            anim.SetCurve("", typeof(Animator), "RootT.x", curvePos[0]);
            anim.SetCurve("", typeof(Animator), "RootT.y", curvePos[1]);
            anim.SetCurve("", typeof(Animator), "RootT.z", curvePos[2]);

            QuickAnimationCurve curveRot = GetAnimationCurve(CURVE_BODY_ROTATION);

            anim.SetCurve("", typeof(Animator), "RootQ.x", curveRot[0]);
            anim.SetCurve("", typeof(Animator), "RootQ.y", curveRot[1]);
            anim.SetCurve("", typeof(Animator), "RootQ.z", curveRot[2]);
            anim.SetCurve("", typeof(Animator), "RootQ.w", curveRot[3]);

            curvePos = GetAnimationCurve(CURVE_LEFT_FOOT_IK_GOAL_POSITION);
            anim.SetCurve("", typeof(Animator), "LeftFootT.x", curvePos[0]);
            anim.SetCurve("", typeof(Animator), "LeftFootT.y", curvePos[1]);
            anim.SetCurve("", typeof(Animator), "LeftFootT.z", curvePos[2]);

            curveRot = GetAnimationCurve(CURVE_LEFT_FOOT_IK_GOAL_ROTATION);
            anim.SetCurve("", typeof(Animator), "LeftFootQ.x", curveRot[0]);
            anim.SetCurve("", typeof(Animator), "LeftFootQ.y", curveRot[1]);
            anim.SetCurve("", typeof(Animator), "LeftFootQ.z", curveRot[2]);
            anim.SetCurve("", typeof(Animator), "LeftFootQ.w", curveRot[3]);

            curvePos = GetAnimationCurve(CURVE_RIGHT_FOOT_IK_GOAL_POSITION);
            anim.SetCurve("", typeof(Animator), "RightFootT.x", curvePos[0]);
            anim.SetCurve("", typeof(Animator), "RightFootT.y", curvePos[1]);
            anim.SetCurve("", typeof(Animator), "RightFootT.z", curvePos[2]);

            curveRot = GetAnimationCurve(CURVE_RIGHT_FOOT_IK_GOAL_ROTATION);
            anim.SetCurve("", typeof(Animator), "RightFootQ.x", curveRot[0]);
            anim.SetCurve("", typeof(Animator), "RightFootQ.y", curveRot[1]);
            anim.SetCurve("", typeof(Animator), "RightFootQ.z", curveRot[2]);
            anim.SetCurve("", typeof(Animator), "RightFootQ.w", curveRot[3]);

            for (int i = 0; i < QuickHumanTrait.GetNumMuscles(); i++)
            {
                string muscleName = QuickHumanTrait.GetMuscleName(i);
                anim.SetCurve("", typeof(Animator), muscleName, _curves[muscleName][0]);
            }

            return(anim);
        }
Ejemplo n.º 3
0
        public virtual void AddKey(float time, bool forceAdd = false)
        {
            GetAnimationCurve(CURVE_TRANSFORM_POSITION).AddKey(time, _animator.transform.position, forceAdd);
            GetAnimationCurve(CURVE_TRANSFORM_ROTATION).AddKey(time, _animator.transform.rotation, forceAdd);

            if (_animator.isHuman)
            {
                QuickHumanPoseHandler.GetHumanPose(_animator, ref _pose);
                Vector3    bodyPosition = _pose.bodyPosition;
                Quaternion bodyRotation = _pose.bodyRotation;

                GetAnimationCurve(CURVE_BODY_POSITION).AddKey(time, bodyPosition, forceAdd);
                GetAnimationCurve(CURVE_BODY_ROTATION).AddKey(time, bodyRotation, forceAdd);

                Vector3    ikGoalPos;
                Quaternion ikGoalRot;
                _animator.GetIKGoalFromBodyPose(AvatarIKGoal.LeftFoot, bodyPosition, bodyRotation, out ikGoalPos, out ikGoalRot);
                GetAnimationCurve(CURVE_LEFT_FOOT_IK_GOAL_POSITION).AddKey(time, ikGoalPos, forceAdd);
                GetAnimationCurve(CURVE_LEFT_FOOT_IK_GOAL_ROTATION).AddKey(time, ikGoalRot, forceAdd);

                _animator.GetIKGoalFromBodyPose(AvatarIKGoal.RightFoot, bodyPosition, bodyRotation, out ikGoalPos, out ikGoalRot);
                GetAnimationCurve(CURVE_RIGHT_FOOT_IK_GOAL_POSITION).AddKey(time, ikGoalPos, forceAdd);
                GetAnimationCurve(CURVE_RIGHT_FOOT_IK_GOAL_ROTATION).AddKey(time, ikGoalRot, forceAdd);

                for (int i = 0; i < _pose.muscles.Length; i++)
                {
                    string muscleName = QuickHumanTrait.GetMuscleName(i);
                    GetAnimationCurve(muscleName).AddKey(time, _pose.muscles[i], forceAdd);
                }
            }

            if (time > _timeLength)
            {
                _timeLength = time;
            }
        }