Beispiel #1
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);
        }
Beispiel #2
0
        private static void DrawCacheInfo(SceneCachePlayer t)
        {
            ISceneCacheInfo scInfo = t.ExtractSceneCacheInfo(forceOpen: false);

            if (null == scInfo)
            {
                return;
            }

            t.ShowInfoInInspector(EditorGUILayout.Foldout(t.IsInfoInInspectorShown(), "Info", true, GetDefaultFoldoutStyle()));
            if (!t.IsInfoInInspectorShown())
            {
                return;
            }

            ++EditorGUI.indentLevel;

            const int leftWidth  = 160;
            int       numFrames  = scInfo.GetNumFrames();
            float     sampleRate = scInfo.GetSampleRate();
            TimeRange timeRange  = scInfo.GetTimeRange();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label($"Num Frames: {numFrames}", GUILayout.MaxWidth(leftWidth));
            GUILayout.Label($"Start Time: {timeRange.start,15:N4}");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label($"Frame Rate: {sampleRate}", GUILayout.MaxWidth(leftWidth));
            GUILayout.Label($"End Time  : {timeRange.end,15:N4}");
            EditorGUILayout.EndHorizontal();

            --EditorGUI.indentLevel;

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }