public Quaternion InterpolateQuaternion(float time) { if (_points == null || _points.Count == 0) { return(_quaternionIdentity); } if (_points.First().Point.w >= time) { return(Quaternion.Euler(_points.First().Point)); } if (_points.Last().Point.w <= time) { return(Quaternion.Euler(_points.Last().Point)); } SearchIndex(time, PropertyType.Quaternion, out int l, out int r); Quaternion quaternionOne = Quaternion.Euler(_points[l].Point); Quaternion quaternionTwo = Quaternion.Euler(_points[r].Point); float normalTime = (time - _points[l].Point.w) / (_points[r].Point.w - _points[l].Point.w); normalTime = Easings.Interpolate(normalTime, _points[r].Easing); return(Quaternion.SlerpUnclamped(quaternionOne, quaternionTwo, normalTime)); }
public Vector3 Interpolate(float time) { if (_points == null || _points.Count == 0) { return(_vectorZero); } if (_points.First().Point.w >= time) { return(_points.First().Point); } if (_points.Last().Point.w <= time) { return(_points.Last().Point); } SearchIndex(time, PropertyType.Vector3, out int l, out int r); float normalTime = (time - _points[l].Point.w) / (_points[r].Point.w - _points[l].Point.w); normalTime = Easings.Interpolate(normalTime, _points[r].Easing); if (_points[r].Smooth) { return(SmoothVectorLerp(_points, l, r, normalTime)); } else { return(Vector3.LerpUnclamped(_points[l].Point, _points[r].Point, normalTime)); } }
internal static IEnumerator AnimateTrackCoroutine(PointDefinition points, Property property, float duration, float startTime, Functions easing) { while (true) { float elapsedTime = Instance.CustomEventCallbackController._audioTimeSource.songTime - startTime; float time = Easings.Interpolate(Mathf.Min(elapsedTime / duration, 1f), easing); switch (property.PropertyType) { case PropertyType.Linear: property.Value = points.InterpolateLinear(time); break; case PropertyType.Vector3: property.Value = points.Interpolate(time); break; case PropertyType.Vector4: property.Value = points.InterpolateVector4(time); break; case PropertyType.Quaternion: property.Value = points.InterpolateQuaternion(time); break; } if (elapsedTime < duration) { yield return(null); } else { break; } } }
public Vector3 Interpolate(float time) { if (_points == null || _points.Count == 0) { return(_vectorZero); } if (_points.First().Point.w >= time) { return(_points.First().Point); } if (_points.Last().Point.w <= time) { return(_points.Last().Point); } SearchIndex(time, PropertyType.Vector3, out int l, out int r); Vector4 pointL = _points[l].Point; Vector4 pointR = _points[r].Point; float normalTime; float divisor = pointR.w - pointL.w; if (divisor != 0) { normalTime = (time - pointL.w) / divisor; } else { normalTime = 0; } normalTime = Easings.Interpolate(normalTime, _points[r].Easing); if (_points[r].Smooth) { return(SmoothVectorLerp(_points, l, r, normalTime)); } else { return(Vector3.LerpUnclamped(pointL, pointR, normalTime)); } }
internal static IEnumerator AssignPathAnimationCoroutine(Property property, float duration, float startTime, Functions easing) { PointDefinitionInterpolation pointDataInterpolation = property.Value as PointDefinitionInterpolation; while (true) { float elapsedTime = Instance.CustomEventCallbackController._audioTimeSource.songTime - startTime; pointDataInterpolation.Time = Easings.Interpolate(Mathf.Min(elapsedTime / duration, 1f), easing); if (elapsedTime < duration) { yield return(null); } else { break; } } pointDataInterpolation.Finish(); }
public Vector3 Interpolate(float time) { if (_points == null || _points.Count == 0) { return(_vectorZero); } if (time <= 0) { return(_points.First().Point); } int pointsCount = _points.Count; for (int i = 0; i < pointsCount; i++) { if (_points[i].Point.w > time) { if (i == 0) { return(_points.First().Point); } float normalTime = (time - _points[i - 1].Point.w) / (_points[i].Point.w - _points[i - 1].Point.w); normalTime = Easings.Interpolate(normalTime, _points[i].Easing); if (_points[i].Smooth) { return(SmoothVectorLerp(_points, i - 1, i, normalTime)); } else { return(Vector3.LerpUnclamped(_points[i - 1].Point, _points[i].Point, normalTime)); } } } return(_points.Last().Point); }
public Quaternion InterpolateQuaternion(float time) { if (_points == null || _points.Count == 0) { return(_quaternionIdentity); } if (_points.First().Point.w >= time) { return(Quaternion.Euler(_points.First().Point)); } if (_points.Last().Point.w <= time) { return(Quaternion.Euler(_points.Last().Point)); } SearchIndex(time, PropertyType.Quaternion, out int l, out int r); Vector4 pointL = _points[l].Point; Vector4 pointR = _points[r].Point; Quaternion quaternionOne = Quaternion.Euler(pointL); Quaternion quaternionTwo = Quaternion.Euler(pointR); float normalTime; float divisor = pointR.w - pointL.w; if (divisor != 0) { normalTime = (time - pointL.w) / divisor; } else { normalTime = 0; } normalTime = Easings.Interpolate(normalTime, _points[r].Easing); return(Quaternion.SlerpUnclamped(quaternionOne, quaternionTwo, normalTime)); }
public Vector4 InterpolateVector4(float time) { if (_points == null || _points.Count == 0) { return(Vector4.zero); } if (_points.First().Vector4Point.v >= time) { return(_points.First().Vector4Point); } if (_points.Last().Vector4Point.v <= time) { return(_points.Last().Vector4Point); } SearchIndex(time, PropertyType.Vector4, out int l, out int r); float normalTime = (time - _points[l].Vector4Point.v) / (_points[r].Vector4Point.v - _points[l].Vector4Point.v); normalTime = Easings.Interpolate(normalTime, _points[r].Easing); return(Vector4.LerpUnclamped(_points[l].Vector4Point, _points[r].Vector4Point, normalTime)); }
// Kind of a sloppy way of implementing this, but hell if it works public float InterpolateLinear(float time) { if (_points == null || _points.Count == 0) { return(0); } if (_points.First().LinearPoint.y >= time) { return(_points.First().LinearPoint.x); } if (_points.Last().LinearPoint.y <= time) { return(_points.Last().LinearPoint.x); } SearchIndex(time, PropertyType.Linear, out int l, out int r); float normalTime = (time - _points[l].LinearPoint.y) / (_points[r].LinearPoint.y - _points[l].LinearPoint.y); normalTime = Easings.Interpolate(normalTime, _points[r].Easing); return(Mathf.LerpUnclamped(_points[l].LinearPoint.x, _points[r].LinearPoint.x, normalTime)); }
public Vector4 InterpolateVector4(float time) { if (_points == null || _points.Count == 0) { return(Vector4.zero); } if (_points.First().Vector4Point.v >= time) { return(_points.First().Vector4Point); } if (_points.Last().Vector4Point.v <= time) { return(_points.Last().Vector4Point); } SearchIndex(time, PropertyType.Vector4, out int l, out int r); Vector5 pointL = _points[l].Vector4Point; Vector5 pointR = _points[r].Vector4Point; float normalTime; float divisor = pointR.v - pointL.v; if (divisor != 0) { normalTime = (time - pointL.v) / divisor; } else { normalTime = 0; } normalTime = Easings.Interpolate(normalTime, _points[r].Easing); return(Vector4.LerpUnclamped(pointL, pointR, normalTime)); }
// Kind of a sloppy way of implementing this, but hell if it works public float InterpolateLinear(float time) { if (_points == null || _points.Count == 0) { return(0); } if (_points.First().LinearPoint.y >= time) { return(_points.First().LinearPoint.x); } if (_points.Last().LinearPoint.y <= time) { return(_points.Last().LinearPoint.x); } SearchIndex(time, PropertyType.Linear, out int l, out int r); Vector4 pointL = _points[l].LinearPoint; Vector4 pointR = _points[r].LinearPoint; float normalTime; float divisor = pointR.y - pointL.y; if (divisor != 0) { normalTime = (time - pointL.y) / divisor; } else { normalTime = 0; } normalTime = Easings.Interpolate(normalTime, _points[r].Easing); return(Mathf.LerpUnclamped(pointL.x, pointR.x, normalTime)); }