Exemple #1
0
        protected virtual void CopyPoseImp()
        {
            //For some obscure reason, we have to set source and dest to null parent in order to work.
            QuickHumanPoseHandler.GetHumanPose(_source, ref _poseSource);
            QuickHumanPoseHandler.GetHumanPose(_dest, ref _poseDest);

            foreach (QuickHumanBodyBones boneID in _allJoints)
            {
                if (!IsTrackedJoint(boneID))
                {
                    for (int i = 0; i < 3; i++)
                    {
                        int m = QuickHumanTrait.GetMuscleFromBone(boneID, i);
                        if (m != -1)
                        {
                            _poseSource.muscles[m] = _poseDest.muscles[m];
                        }
                    }
                }
            }

            //The hips is a special case, it modifies the bodyPosition and bodyRotation fields
            if (!IsTrackedJointBody(TrackedJointBody.Hips))
            {
                _poseSource.bodyPosition = _poseDest.bodyPosition;
                _poseSource.bodyRotation = _poseDest.bodyRotation;
            }

            QuickHumanPoseHandler.SetHumanPose(_dest, ref _poseSource);
        }
Exemple #2
0
        protected virtual void UpdateStatePlaying(float time)
        {
            transform.position = _playAnimationClip.EvaluateTransformPosition(time);
            transform.rotation = _playAnimationClip.EvaluateTransformRotation(time);

            if (_animator.isHuman)
            {
                _playAnimationClip.EvaluateHumanPose(time, ref _humanPose);
                QuickHumanPoseHandler.SetHumanPose(_animator, ref _humanPose);
            }
        }
Exemple #3
0
        public virtual void SetAnimatorDest(Animator animator)
        {
            //Restore the initial HumanPose that _dest had at the begining
            if (_dest)
            {
                QuickHumanPoseHandler.SetHumanPose(_dest, ref _initialPoseDest);
            }

            _dest = animator;

            //Save the current HumanPose of the new _dest
            if (_dest)
            {
                QuickHumanPoseHandler.GetHumanPose(_dest, ref _initialPoseDest);
            }
        }
Exemple #4
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;
            }
        }