Esempio n. 1
0
        private void Update()
        {
            // Sanity-check.
            if (m_AnimTrack == null)
            {
                return;
            }
            if (m_PoseHandler == null)
            {
                return;
            }

            // Compute the animation time.
            float runtime = m_AnimTrack.Duration;
            int   n       = (int)(Time.time / runtime);
            float time;

            if (useScrub)
            {
                // Time determined by scrubber.
                time = runtime * scrub;
            }
            else
            {
                // Time determined by game time, loops over [0,runtime]
                time  = Time.time - (n * runtime);
                scrub = time / runtime;
            }

            // Fetch pose.
            var pose = m_AnimTrack.GetPose(time);

            // Apply to avatar.
            m_PoseHandler.SetHumanPose(ref pose);
        }
Esempio n. 2
0
        private UnityEngine.HumanPose GetPoseInSubTrackSpace(float time)
        {
            // Compute the clapped, padded, search time.
            float clampTime  = Mathf.Clamp(time, 0, Duration);
            float paddedTime = PaddedClipStartTime + clampTime;
            float searchTime = paddedTime;

            // Search through tracks to find subtrack corresponding to current time.
            AnimTrackBase track = null;

            for (int i = 0; i < m_SubTracks.Count; i++)
            {
                track = m_SubTracks[i];
                if (searchTime - track.Duration <= 0)
                {
                    break;
                }
                searchTime -= track.Duration;
            }
            // searchTime should be in [0,track.Duration]

            // Return the pose sampled from the chosen subtrack.
            return((track != null) ? track.GetPose(searchTime) : new UnityEngine.HumanPose()); // safeguard against null
        }