public ReplayRecordedFrame(ReplayRecordedFrame a, ReplayRecordedFrame b, float time) { float t = (time - a.time) / (b.time - a.time); this.time = time; this.transformInfos = new TransformInfo[a.transformInfos.Length]; for (int i = 0; i < a.transformInfos.Length; i++) { this.transformInfos[i] = TransformInfo.Lerp(a.transformInfos[i], b.transformInfos[i], t); } }
public static ReplayRecordedFrame Lerp(ReplayRecordedFrame a, ReplayRecordedFrame b, float time) { if (time <= a.time) { return(a); } if (time >= b.time) { return(b); } return(new ReplayRecordedFrame(a, b, time)); }
public void ApplyRecordedTime(int frameIndex, float time) { if (this.ClipFrames.Count != 0) { if (this.ClipFrames.Count == 1) { this.ClipFrames[0].ApplyTo(this.transformsToBeRecorded); return; } if (frameIndex > 0 && frameIndex + 1 < this.ClipFrames.Count) { var currentframe = ReplayRecordedFrame.Lerp(ClipFrames[frameIndex], ClipFrames[frameIndex + 1], time); currentframe.ApplyTo(transformsToBeRecorded); } } }
private void RecordFrame() { var transformInfos = new TransformInfo[transformsToBeRecorded.Count]; for (int i = 0; i < transformsToBeRecorded.Count; i++) { Transform t = transformsToBeRecorded[i]; transformInfos[i] = new TransformInfo(t); if (!PlayerController.Instance.respawn.bail.bailed && t == PlayerHeadIK.head) { transformInfos[i].rotation = Quaternion.Inverse(t.parent.rotation) * PlayerHeadIK.currentRot.rotation; //Fixes Head jitter } } ReplayRecordedFrame newFrame = new ReplayRecordedFrame() { time = this.endTime, transformInfos = transformInfos }; this.RecordedFrames.Add(newFrame); }
public void SaveLastFrame() { lastFrame = this.RecordedFrames[RecordedFrames.Count - 1]; }