Exemplo n.º 1
0
 /// <summary>
 /// Stop and reset all the curve data.
 /// </summary>
 public override void Stop()
 {
     foreach (TimelineItem item in GetTimelineItems())
     {
         CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
         if (actorClipCurve != null)
         {
             actorClipCurve.Reset();
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Set the track to an arbitrary time.
 /// </summary>
 /// <param name="time">The new running time.</param>
 public override void SetTime(float time)
 {
     base.elapsedTime = time;
     foreach (TimelineItem item in GetTimelineItems())
     {
         CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
         if (actorClipCurve != null)
         {
             actorClipCurve.SampleTime(time);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Stop and reset all the curve data.
 /// </summary>
 public override void Stop()
 {
     TimelineItem[] items = GetTimelineItems();
     for (int i = 0; i < items.Length; i++)
     {
         CinemaActorClipCurve actorClipCurve = items[i] as CinemaActorClipCurve;
         if (actorClipCurve != null)
         {
             actorClipCurve.Reset();
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Update all curve items.
        /// </summary>
        /// <param name="time">The new running time.</param>
        /// <param name="deltaTime">The deltaTime since last update.</param>
        public override void UpdateTrack(float time, float deltaTime)
        {
            elapsedTime = time;

            foreach (TimelineItem item in GetTimelineItems())
            {
                CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
                if (actorClipCurve != null)
                {
                    actorClipCurve.SampleTime(time);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stop and reset all the curve data.
        /// </summary>
        public override void Stop()
        {
            var items = GetAllTimelineItems();

            for (int i = 0; i < items.Count; i++)
            {
                CinemaActorClipCurve actorClipCurve = items[i] as CinemaActorClipCurve;
                if (actorClipCurve != null)
                {
                    actorClipCurve.Reset();
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Set the track to an arbitrary time.
 /// </summary>
 /// <param name="time">The new running time.</param>
 public override void SetTime(float time)
 {
     base.elapsedTime = time;
     TimelineItem[] items = GetTimelineItems();
     for (int i = 0; i < items.Length; i++)
     {
         CinemaActorClipCurve actorClipCurve = items[i] as CinemaActorClipCurve;
         if (actorClipCurve != null)
         {
             actorClipCurve.SampleTime(time);
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Update all curve items.
        /// </summary>
        /// <param name="time">The new running time.</param>
        /// <param name="deltaTime">The deltaTime since last update.</param>
        public override void UpdateTrack(float time, float deltaTime)
        {
            base.elapsedTime = time;

            List <TimelineItem> items = GetAllTimelineItems();

            for (int i = 0; i < items.Count; i++)
            {
                CinemaActorClipCurve actorClipCurve = items[i] as CinemaActorClipCurve;
                if (actorClipCurve != null)
                {
                    actorClipCurve.SampleTime(time);
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Stop and reset all the curve data.
 /// </summary>
 public override void Stop()
 {
     {
         var __array3       = GetTimelineItems();
         var __arrayLength3 = __array3.Length;
         for (int __i3 = 0; __i3 < __arrayLength3; ++__i3)
         {
             var item = (TimelineItem)__array3[__i3];
             {
                 CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
                 if (actorClipCurve != null)
                 {
                     actorClipCurve.Reset();
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Update all curve items.
        /// </summary>
        /// <param name="time">The new running time.</param>
        /// <param name="deltaTime">The deltaTime since last update.</param>
        public override void UpdateTrack(float time, float deltaTime)
        {
            if (mute)
            {
                return;
            }
            base.elapsedTime = time;

            TimelineItem[] items = GetTimelineItems();
            for (int i = 0; i < items.Length; i++)
            {
                CinemaActorClipCurve actorClipCurve = items[i] as CinemaActorClipCurve;
                if (actorClipCurve != null)
                {
                    actorClipCurve.SampleTime(time);
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Set the track to an arbitrary time.
 /// </summary>
 /// <param name="time">The new running time.</param>
 public override void SetTime(float time)
 {
     base.elapsedTime = time;
     {
         var __array2       = GetTimelineItems();
         var __arrayLength2 = __array2.Length;
         for (int __i2 = 0; __i2 < __arrayLength2; ++__i2)
         {
             var item = (TimelineItem)__array2[__i2];
             {
                 CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
                 if (actorClipCurve != null)
                 {
                     actorClipCurve.SampleTime(time);
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Update all curve items.
 /// </summary>
 /// <param name="time">The new running time.</param>
 /// <param name="deltaTime">The deltaTime since last update.</param>
 public override void UpdateTrack(float time, float deltaTime)
 {
     base.elapsedTime = time;
     {
         var __array1       = GetTimelineItems();
         var __arrayLength1 = __array1.Length;
         for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
         {
             var item = (TimelineItem)__array1[__i1];
             {
                 CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
                 if (actorClipCurve != null)
                 {
                     actorClipCurve.SampleTime(time);
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Stop and reset all the curve data.
        /// </summary>
        public override void Stop()
        {
#if PROFILE_FILE
            Profiler.BeginSample("CurveTrack.Stop");
#endif // PROFILE_FILE

            var list   = GetTimelineItems();
            var length = list.Length;
            for (var i = 0; i < length; i++)
            {
                var item = list[i];
                CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
                if (actorClipCurve != null)
                {
                    actorClipCurve.Reset();
                }
            }
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE
        }
Exemplo n.º 13
0
        /// <summary>
        /// Set the track to an arbitrary time.
        /// </summary>
        /// <param name="time">The new running time.</param>
        public override void SetTime(float time)
        {
#if PROFILE_FILE
            Profiler.BeginSample("CurveTrack.SetTime");
#endif // PROFILE_FILE
            base.elapsedTime = time;

            var list   = GetTimelineItems();
            var length = list.Length;
            for (var i = 0; i < length; i++)
            {
                var item = list[i];
                CinemaActorClipCurve actorClipCurve = item as CinemaActorClipCurve;
                if (actorClipCurve != null)
                {
                    actorClipCurve.SampleTime(time);
                }
            }
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE
        }
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing && GUIUtility.hotControl == 0 && 
            (clipCurve.Firetime <= state.ScrubberPosition && 
            state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration) && clipCurve.Actor != null)
        {
            Undo.RecordObject(clipCurve, "Auto Key Created");
            bool hasDifferenceBeenFound = false;
            foreach (MemberClipCurveData data in clipCurve.CurveData)
            {
                if (data.Type == string.Empty || data.PropertyName == string.Empty) continue;

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object value = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);

                PropertyTypeInfo typeInfo = data.PropertyType;
                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float ||
                typeInfo == PropertyTypeInfo.Double)
                {
                    float x = (float)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(x, curve1Value, data.Curve1, state.ScrubberPosition);

                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2 = (Vector2)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    Vector3 vec3 = (Vector3)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4 = (Vector4)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);

                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion = (Quaternion)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve1, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve2, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve3, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve4, j, newKeyframe);
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float angle = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
                EditorUtility.SetDirty(clipCurve);
            }
        }
    }