public void PlayEvent(string eventName) { _actorIds.Clear(); _subtitleData.Clear(); _binarcAreaData.ForEntry(eventName, Bar.EntryType.Event, stream => { _eventPlayer = new EventPlayer(this, Event.Read(stream)); RemoveAllActors(); _eventPlayer.Initialize(); }); }
public void InterpolateCameraSecondTest(float time, float eyey, float centery) { var fakeField = Substitute.For <IField>(); var eventPlayer = new EventPlayer(fakeField, new List <Event.IEventEntry> { new Event.SetEndFrame { EndFrame = 300 }, new Event.SetupEvent(), new Event.SetCameraData { CameraId = 0, PositionX = CameraDataSingleValue(40.186035f), PositionY = CameraDataSingleValue(271.22748f), PositionZ = CameraDataSingleValue(527.7301f), LookAtX = CameraDataSingleValue(-79.38527f), LookAtY = CameraDataSingleValue(90.874115f), LookAtZ = CameraDataSingleValue(-78.414696f), Roll = CameraDataSingleValue(0f), FieldOfView = CameraDataSingleValue(41.092915f), }, new Event.SetCameraData { CameraId = 1, PositionX = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(-317.25266f, Kh2.Motion.Interpolation.Linear, 0, 0f, 0f), CameraDataValue(-317.25266f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(-317.25266f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, PositionY = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(123.61203f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(185.76723f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(185.76723f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, PositionZ = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(-79.360405f, Kh2.Motion.Interpolation.Linear, 0, 0f, 0f), CameraDataValue(-79.360405f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(-79.360405f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, LookAtX = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(-357.23502f, Kh2.Motion.Interpolation.Linear, 0, 0f, 0f), CameraDataValue(-357.23502f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(-357.23502f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, LookAtY = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(122.42929f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(184.58449f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(184.58449f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, LookAtZ = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(-217.77927f, Kh2.Motion.Interpolation.Linear, 0, 0f, 0f), CameraDataValue(-217.77927f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(-217.77927f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, Roll = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 0, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, FieldOfView = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(42.026005f, Kh2.Motion.Interpolation.Linear, 0, 0f, 0f), CameraDataValue(42.026005f, Kh2.Motion.Interpolation.Linear, 3584, 0f, 0f), CameraDataValue(42.026005f, Kh2.Motion.Interpolation.Linear, 3754, 0f, 0f), }, }, new Event.SeqCamera { CameraId = 0, FrameStart = 15, FrameEnd = 75, }, new Event.SeqCamera { CameraId = 1, FrameStart = 76, FrameEnd = 286, }, }); eventPlayer.Initialize(); eventPlayer.Update(1 / 60.0 * (time + 30f)); var setCameraCall = fakeField.ReceivedCalls().FirstOrDefault(); Assert.NotNull(setCameraCall); var actualEye = (System.Numerics.Vector3)setCameraCall.GetArguments()[0]; var actualCenter = (System.Numerics.Vector3)setCameraCall.GetArguments()[1]; var actualFov = (float)setCameraCall.GetArguments()[2]; var actualRoll = (float)setCameraCall.GetArguments()[3]; Assert.Equal(-317.25266f, actualEye.X, 0); Assert.Equal(eyey, -actualEye.Y, 0); Assert.Equal(79.360405f, -actualEye.Z, 0); Assert.Equal(-357.23502f, actualCenter.X, 0); Assert.Equal(centery, -actualCenter.Y, 0); Assert.Equal(217.77927f, -actualCenter.Z, 0); Assert.Equal(0f, actualRoll, 0); Assert.Equal(42.026005f, actualFov, 0); }
public void ActorSceneVisibility(float time, bool expectedActorVisibility) { const int ActorId = 0; const int FrameActorAppear = 50; const string MotionPath = "anm_ex/motion"; var fakeField = Substitute.For <IField>(); var eventPlayer = new EventPlayer(fakeField, new List <Event.IEventEntry> { new Event.SetEndFrame { EndFrame = 1000 }, new Event.ReadAssets { FrameStart = -32767, FrameEnd = 0, Unk06 = 0, Set = new List <Event.IEventEntry> { new Event.ReadActor { ObjectId = 123, ActorId = ActorId, Name = "main_actor" }, new Event.ReadMotion { ObjectId = 123, ActorId = ActorId, Name = MotionPath, UnknownIndex = 1, }, } }, new Event.SetActor { ObjectEntry = 123, ActorId = ActorId, Name = "main_actor" }, new Event.SeqPlayAnimation { FrameStart = FrameActorAppear, FrameEnd = 100, ActorId = ActorId, Path = MotionPath }, new Event.SeqActorLeave { Frame = 150, ActorId = ActorId } }); bool?lastVisibility = null; fakeField.SetActorVisibility(Arg.Is(ActorId), Arg.Do <bool>(x => lastVisibility = x)); eventPlayer.Initialize(); for (var i = 0; i < time; i++) { eventPlayer.Update(1f / 30.0f); } Assert.Equal(expectedActorVisibility, lastVisibility); }
public void InterpolateCameraTest(float time, float eyex, float eyey, float eyez) { var fakeField = Substitute.For <IField>(); var eventPlayer = new EventPlayer(fakeField, new List <Event.IEventEntry> { new Event.SetEndFrame { EndFrame = 100 }, new Event.SetupEvent(), new Event.SetCameraData { CameraId = 0, PositionX = CameraDataSingleValue(-309.26492f), PositionY = CameraDataSingleValue(2446.094f), PositionZ = CameraDataSingleValue(1473.9126f), LookAtX = CameraDataSingleValue(0f), LookAtY = CameraDataSingleValue(113.279144f), LookAtZ = CameraDataSingleValue(20.983765f), Roll = CameraDataSingleValue(0f), FieldOfView = CameraDataSingleValue(48.41243f), }, new Event.SetCameraData { CameraId = 1, PositionX = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(-309.26492f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(411.81467f, Kh2.Motion.Interpolation.Hermite, 341, -0.6224821f, -0.6224821f), CameraDataValue(-298.11935f, Kh2.Motion.Interpolation.Hermite, 648, -0.8131355f, -0.8131355f), CameraDataValue(-106.03006f, Kh2.Motion.Interpolation.Linear, 819, 860.1719f, 860.1719f), CameraDataValue(-106.03006f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, PositionY = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(2446.094f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(515.0501f, Kh2.Motion.Interpolation.Linear, 819, -1865.6649f, -1865.6649f), CameraDataValue(515.0501f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, PositionZ = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(1473.9126f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(288.39706f, Kh2.Motion.Interpolation.Linear, 819, -1165.8065f, -1165.8065f), CameraDataValue(288.39706f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, LookAtX = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(0f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(0f, Kh2.Motion.Interpolation.Hermite, 341, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Hermite, 648, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 819, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, LookAtY = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(113.279144f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(113.279144f, Kh2.Motion.Interpolation.Hermite, 341, 0f, 0f), CameraDataValue(113.279144f, Kh2.Motion.Interpolation.Hermite, 648, 0f, 0f), CameraDataValue(113.279144f, Kh2.Motion.Interpolation.Linear, 819, 0f, 0f), CameraDataValue(113.279144f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, LookAtZ = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(20.983765f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(20.983765f, Kh2.Motion.Interpolation.Hermite, 341, 0f, 0f), CameraDataValue(20.983765f, Kh2.Motion.Interpolation.Hermite, 648, 0f, 0f), CameraDataValue(20.983765f, Kh2.Motion.Interpolation.Linear, 819, 0f, 0f), CameraDataValue(20.983765f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, Roll = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(0f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(0f, Kh2.Motion.Interpolation.Hermite, 341, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Hermite, 648, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 819, 0f, 0f), CameraDataValue(0f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, FieldOfView = new List <Event.SetCameraData.CameraKeys> { CameraDataValue(48.41243f, Kh2.Motion.Interpolation.Hermite, 0, 0, 0), CameraDataValue(48.41243f, Kh2.Motion.Interpolation.Hermite, 341, 0f, 0f), CameraDataValue(48.41243f, Kh2.Motion.Interpolation.Hermite, 648, 0f, 0f), CameraDataValue(48.41243f, Kh2.Motion.Interpolation.Linear, 819, 0f, 0f), CameraDataValue(48.41243f, Kh2.Motion.Interpolation.Linear, 1024, 0f, 0f), }, }, new Event.SeqCamera { CameraId = 0, FrameStart = 0, FrameEnd = 100, }, new Event.SeqCamera { CameraId = 1, FrameStart = 1, FrameEnd = 101, }, }); eventPlayer.Initialize(); eventPlayer.Update(1 / 60.0 * time); var setCameraCall = fakeField.ReceivedCalls().FirstOrDefault(); Assert.NotNull(setCameraCall); var actualEye = (System.Numerics.Vector3)setCameraCall.GetArguments()[0]; var actualCenter = (System.Numerics.Vector3)setCameraCall.GetArguments()[1]; var actualFov = (float)setCameraCall.GetArguments()[2]; var actualRoll = (float)setCameraCall.GetArguments()[3]; Assert.Equal(eyex, actualEye.X, 0); Assert.Equal(eyey, -actualEye.Y, 0); Assert.Equal(eyez, -actualEye.Z, 0); Assert.Equal(0, actualCenter.X, 0); Assert.Equal(-113.28f, -actualCenter.Y, 0); Assert.Equal(-20.98f, -actualCenter.Z, 0); Assert.Equal(0f, actualRoll, 0); Assert.Equal(48.41f, actualFov, 0); }