public void OnDrawGizmos()
 {
     if (ObjectSpline == null)
     {
         return;
     }
     ObjectSpline.OnDrawGizmos();
 }
        private void OnDrawGizmos()
        {
            if (!ShouldRenderGizmos)
            {
                return;
            }

            if (ObjectSpline == null)
            {
                return;
            }

            ObjectSpline.OnDrawGizmos();
        }
        public void SetStartingOrientation()
        {
            switch (SplineOrientationMode)
            {
            case SplineOrientationMode.LookAtTransform:
                AffectedObject.position = FirstNode.Position;
                AffectedObject.LookAt(LookAtTarget, Vector3.up);
                break;

            case SplineOrientationMode.LookAhead:
                var nextNodePosition = ObjectSpline.GetPositionOnPath(Sequence.PlaybackRate > 0.0f ? USSequencer.SequenceUpdateRate : -USSequencer.SequenceUpdateRate);
                AffectedObject.position = FirstNode.Position;
                AffectedObject.LookAt(nextNodePosition, Vector3.up);
                break;

            case SplineOrientationMode.ManualOrientation:
                AffectedObject.position = FirstNode.Position;
                break;
            }
        }
        public override void Process(float sequencerTime, float playbackRate)
        {
            if (!AffectedObject)
            {
                return;
            }

            if (sequencerTime < StartTime || sequencerTime > EndTime)
            {
                return;
            }

            if (SplineOrientationMode == SplineOrientationMode.LookAtTransform && LookAtTarget == null)
            {
                throw new Exception("Spline Orientation Mode is look at object, but there is no LookAtTarget");
            }

            var sampleTime = (sequencerTime - StartTime) / ((EndTime - StartTime));

            var easingFunction = Shared.DoubleEasing.GetEasingFunctionFor(easingType);

            sampleTime = (float)easingFunction(sampleTime, 0.0, 1.0, 1.0);

            var modifiedRotation = sourceRotation;

            switch (SplineOrientationMode)
            {
            case SplineOrientationMode.LookAtTransform:
                AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);
                AffectedObject.LookAt(LookAtTarget, Vector3.up);
                modifiedRotation = AffectedObject.rotation;
                break;

            case SplineOrientationMode.LookAhead:
            {
                var nextNodePosition = ObjectSpline.GetPositionOnPath(Sequence.PlaybackRate > 0.0f ? sampleTime + USSequencer.SequenceUpdateRate : sampleTime - USSequencer.SequenceUpdateRate);
                var prevNodePosition = ObjectSpline.GetPositionOnPath(Sequence.PlaybackRate > 0.0f ? sampleTime - USSequencer.SequenceUpdateRate : sampleTime + USSequencer.SequenceUpdateRate);

                var prev = nextNodePosition.Equals(prevNodePosition);
                SmoothedQuaternion.SmoothValue = prev ? Quaternion.identity : Quaternion.LookRotation((nextNodePosition - prevNodePosition).normalized);

                AffectedObject.rotation = SmoothedQuaternion.SmoothValue;
                AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);

                modifiedRotation = AffectedObject.rotation;
                break;
            }

            case SplineOrientationMode.ManualOrientation:
                AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);
                break;
            }

            Shake.ShakeType          = shakeType;
            Shake.ShakeSpeedPosition = shakeSpeedPosition;
            Shake.ShakeRangePosition = shakeRangePosition;
            Shake.ShakeSpeedRotation = shakeSpeedRotation;
            Shake.ShakeRangeRotation = shakeRangeRotation;
            Shake.Process(sequencerTime, Sequence.Duration);

            // Must append the shake quat, so we maintain our look forward or look at object
            var shakeQuat = Quaternion.Euler(modifiedRotation.eulerAngles + Shake.EulerRotation);

            var min = 0.0f;
            var max = (Sequence.Duration * 0.1f);

            max = Mathf.Clamp(max, 0.1f, 1.0f);
            var shakeRatio = Mathf.Clamp(sequencerTime, min, max) / max;

            var shakePos = Vector3.Slerp(Vector3.zero, Shake.Position, shakeRatio);

            shakeQuat = Quaternion.Slerp(AffectedObject.localRotation, shakeQuat, shakeRatio);

            AffectedObject.localPosition += shakePos;

            // Just make sure we don't set this.
            if (SplineOrientationMode != SplineOrientationMode.ManualOrientation)
            {
                AffectedObject.localRotation = shakeQuat;
            }
        }
 /// <summary>
 /// Call this method if you'd like to force updating a curve after modifying the keyframes.
 /// </summary>
 public void BuildCurveFromKeyframes()
 {
     ObjectSpline.BuildFromKeyframes(Keyframes);
 }
        public void Process(float sequencerTime, float playbackRate)
        {
            if (!TimeLine.AffectedObject)
            {
                return;
            }

            if (sequencerTime < StartTime || sequencerTime > EndTime)
            {
                return;
            }


            var sampleTime = (sequencerTime - StartTime) / ((EndTime - StartTime));

            //var easingFunction = Easing.GetEasingFunctionFor(easingType);
            sampleTime = Curve.Evaluate(sampleTime);
            //sampleTime = (float)easingFunction(sampleTime, 0.0, 1.0, 1.0);

            var modifiedRotation = sourceRotation;

            switch (SplineOrientationMode)
            {
            case SplineOrientationMode.LookAtTransform:
                TimeLine.AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);
                TimeLine.AffectedObject.LookAt(LookAtTarget, Vector3.up);
                modifiedRotation = TimeLine.AffectedObject.rotation;
                break;

            case SplineOrientationMode.LookAhead:
            {
                Vector3 nextNodePosition = ObjectSpline.GetPositionOnPath(sampleTime);
                Vector3 prevNodePosition = TimeLine.AffectedObject.position;        // ObjectSpline.GetPositionOnPath(sampleTime + JSequencer.SequenceUpdateRate);


                Quaternion target = TimeLine.AffectedObject.rotation;
                if ((nextNodePosition - prevNodePosition) != Vector3.zero)
                {
                    target = Quaternion.LookRotation((nextNodePosition - prevNodePosition).normalized, Vector3.up);
                }


                TimeLine.AffectedObject.rotation = target;
                TimeLine.AffectedObject.position = nextNodePosition;        //ObjectSpline.GetPositionOnPath(sampleTime);

                modifiedRotation = TimeLine.AffectedObject.rotation;
                break;
            }

            case SplineOrientationMode.ManualOrientation:
                TimeLine.AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);
                TimeLine.AffectedObject.rotation = ObjectSpline.GetRotation(sampleTime);
                break;

            case SplineOrientationMode.None:
                TimeLine.AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);
                break;
            }


            // TimeLine.AffectedObject.position = ObjectSpline.GetPositionOnPath(sampleTime);
        }