コード例 #1
0
        private static int CalculateFrameByRound(float time, SceneCacheInfo scInfo, LimitedAnimationController controller)
        {
            int frame = Mathf.RoundToInt(time * scInfo.sampleRate);

            frame = controller.Apply(frame);
            frame = Mathf.Clamp(frame, 0, scInfo.numFrames - 1);
            return(frame);
        }
コード例 #2
0
//----------------------------------------------------------------------------------------------------------------------        

    private static double CalculateTimeForLimitedAnimation(SceneCachePlayer scPlayer, 
        LimitedAnimationController overrideLimitedAnimationController, double time)  
    {
        LimitedAnimationController origLimitedAnimationController = scPlayer.GetLimitedAnimationController();
        if (origLimitedAnimationController.IsEnabled()) //do nothing if LA is set on the target SceneCache
            return time;
        
        if (!overrideLimitedAnimationController.IsEnabled())
            return time;

        ISceneCacheInfo scInfo = scPlayer.ExtractSceneCacheInfo(forceOpen: true);
        if (null == scInfo)
            return time;
            
        int frame = scPlayer.CalculateFrame((float)time,overrideLimitedAnimationController);
        return frame / scInfo.GetSampleRate();
    }
コード例 #3
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData) {
        if (null == m_sceneCachePlayer) {
            return;
        }
        
        LimitedAnimationController limitedAnimationController = m_sceneCachePlayableAsset.GetOverrideLimitedAnimationController(); 
        
        double localTime = playable.GetTime();
        double t         = CalculateTimeForLimitedAnimation(m_sceneCachePlayer,limitedAnimationController, localTime);
        
        AnimationCurve curve          = m_sceneCachePlayableAsset.GetAnimationCurve();
        float          normalizedTime = curve.Evaluate((float)t);
              
        m_sceneCachePlayer.SetAutoplay(false);
        m_sceneCachePlayer.SetTimeByNormalizedTime(normalizedTime);

    }
コード例 #4
0
//----------------------------------------------------------------------------------------------------------------------

        //[TODO-sin:2022-3-24] remove this in 0.13.x
        internal void CopyLegacyClipDataToAsset(SceneCachePlayableAsset sceneCachePlayableAsset)
        {
            if (m_copyLimitedAnimationControllerToAsset)
            {
                LimitedAnimationController assetController = sceneCachePlayableAsset.GetOverrideLimitedAnimationController();
                assetController.SetEnabled(m_overrideLimitedAnimationController.IsEnabled());
                assetController.SetFrameOffset(m_overrideLimitedAnimationController.GetFrameOffset());
                assetController.SetNumFramesToHold(m_overrideLimitedAnimationController.GetNumFramesToHold());
                m_copyLimitedAnimationControllerToAsset = false;
            }


            if (m_copyAnimationCurveToAsset)
            {
                sceneCachePlayableAsset.SetAnimationCurve(m_animationCurve);
                sceneCachePlayableAsset.SetIsSceneCacheCurveExtracted(m_initialized);
                m_copyAnimationCurveToAsset = false;
            }
        }
コード例 #5
0
        internal int CalculateFrame(float time, LimitedAnimationController limitedAnimationController)
        {
            int frame = 0;

            switch (m_playbackMode)
            {
            case SceneCachePlaybackMode.SnapToPreviousFrame: {
                frame = CalculateFrameByFloor(time, m_sceneCacheInfo, limitedAnimationController);
                break;
            }

            case SceneCachePlaybackMode.SnapToNearestFrame: {
                frame = CalculateFrameByRound(time, m_sceneCacheInfo, limitedAnimationController);
                break;
            }

            default: {
                Assert.IsTrue(false); //invalid call
                break;
            }
            }

            return(frame);
        }
コード例 #6
0
 internal LimitedAnimationController(LimitedAnimationController otherController) {
     m_enabled         = otherController.IsEnabled();
     m_frameOffset     = otherController.GetFrameOffset();
     m_numFramesToHold = otherController.GetNumFramesToHold();
 }