Esempio n. 1
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();
    }
Esempio n. 2
0
        private static AnimationCurve ExtractNormalizedTimeCurve(SceneCachePlayer scPlayer, out float duration)
        {
            ISceneCacheInfo sceneCacheInfo = scPlayer.ExtractSceneCacheInfo(forceOpen: true);

            if (null == sceneCacheInfo)
            {
                duration = 0;
                return(null);
            }

            TimeRange timeRange = sceneCacheInfo.GetTimeRange();

            duration = timeRange.GetDuration();
            if (duration <= 0f)
            {
                duration = Mathf.Epsilon;
            }

            Keyframe[] keyframes    = sceneCacheInfo.GetTimeCurve().keys;
            int        numKeyframes = keyframes.Length;

            for (int i = 0; i < numKeyframes; ++i)
            {
                keyframes[i].value /= timeRange.end;
            }

            //outTangent
            for (int i = 0; i < numKeyframes - 1; ++i)
            {
                keyframes[i].outTangent = CalculateLinearTangent(keyframes, i, i + 1);
            }

            //inTangent
            for (int i = 1; i < numKeyframes; ++i)
            {
                keyframes[i].inTangent = CalculateLinearTangent(keyframes, i - 1, i);
            }

            AnimationCurve curve = new AnimationCurve(keyframes);

            return(curve);
        }