From f67731ddd4232b5c40f1a3e0f6461a55643aefae Mon Sep 17 00:00:00 2001 From: dexy Date: Tue, 26 Nov 2019 02:50:30 +1100 Subject: [PATCH] Cutscene viewer playback improvements --- World/CutsceneForm.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/World/CutsceneForm.cs b/World/CutsceneForm.cs index 6ae3358..ee06cdb 100644 --- a/World/CutsceneForm.cs +++ b/World/CutsceneForm.cs @@ -58,8 +58,10 @@ namespace CodeWalker.World { var cori = Quaternion.RotationAxis(Vector3.UnitX, -1.57079632679f) * Quaternion.RotationAxis(Vector3.UnitZ, 3.141592653f); - var pos = Cutscene.Position + Cutscene.CameraObject.Position; - var rot = Cutscene.Rotation * Cutscene.CameraObject.Rotation * cori; + var pos = Cutscene.Position; + var rot = Cutscene.Rotation; + pos = pos + rot.Multiply(Cutscene.CameraObject.Position); + rot = rot * Cutscene.CameraObject.Rotation * cori; WorldForm.SetCameraTransform(pos, rot); @@ -304,10 +306,12 @@ namespace CodeWalker.World public Dictionary SceneObjects { get; set; } = null; public CutEvent[] LoadEvents { get; set; } = null; public CutEvent[] PlayEvents { get; set; } = null; + public CutConcatData[] ConcatDatas { get; set; } = null; public int NextLoadEvent { get; set; } = 0; public int NextPlayEvent { get; set; } = 0; public int NextCameraCut { get; set; } = 0; + public int NextConcatData { get; set; } = 0; public Gxt2File Gxt2File { get; set; } = null; @@ -338,6 +342,7 @@ namespace CodeWalker.World Objects = csf.ObjectsDict; LoadEvents = RecastArray(csf.pCutsceneLoadEventList); PlayEvents = RecastArray(csf.pCutsceneEventList); + ConcatDatas = csf.concatDataList; LoadYcds(); @@ -391,6 +396,7 @@ namespace CodeWalker.World NextLoadEvent = 0; NextPlayEvent = 0; NextCameraCut = 0; + NextConcatData = 0; RaiseEvents(newTime); } @@ -473,7 +479,7 @@ namespace CodeWalker.World updateObjectTransform(obj, cme, 0, 5, 6); - pos = pos + obj.Position; + pos = pos + rot.Multiply(obj.Position); rot = rot * obj.Rotation; } obj.Ped.Position = pos; @@ -545,6 +551,18 @@ namespace CodeWalker.World } NextCameraCut = i; + for (i = NextConcatData; i < ConcatDatas?.Length; i++) + { + var c = ConcatDatas[i]; + if (c.fStartTime > upToTime) break; + if (c.cSceneName == 0) break; + + Position = c.vOffset; + Rotation = Quaternion.RotationAxis(Vector3.UnitZ, c.fRotation * 0.0174532925f); //is this right? + } + NextConcatData = i; + + } private void RaiseEvent(CutEvent e) {