From 37014e958ca8992c5ede2a73d24cb9b05bae904b Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 28 Mar 2024 12:55:21 +0100 Subject: [PATCH] [monogame] Adjusted existing monogame code and examples to 4.2 physics. --- .../spine-monogame-example/ExampleGame.cs | 16 +++++++++++----- .../spine-monogame/spine-monogame.csproj | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/spine-monogame/spine-monogame-example/ExampleGame.cs b/spine-monogame/spine-monogame-example/ExampleGame.cs index 8a48428f5..6ad2dae76 100644 --- a/spine-monogame/spine-monogame-example/ExampleGame.cs +++ b/spine-monogame/spine-monogame-example/ExampleGame.cs @@ -90,9 +90,10 @@ namespace Spine { // to the skeleton state.Update(deltaTime); state.Apply(skeleton); + skeleton.Update(deltaTime); // Update the transformations of bones and other parts of the skeleton - skeleton.UpdateWorldTransform(); + skeleton.UpdateWorldTransform(Skeleton.Physics.Update); // Clear the screen and setup the projection matrix of the skeleton renderer game.GraphicsDevice.Clear(Color.Black); @@ -143,8 +144,9 @@ namespace Spine { public override void Render (float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); + skeleton.Update(deltaTime); - skeleton.UpdateWorldTransform(); + skeleton.UpdateWorldTransform(Skeleton.Physics.Update); // Clear the screen and setup the projection matrix of the custom effect through the // "Projection" parameter. @@ -200,7 +202,9 @@ namespace Spine { public override void Render (float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); - skeleton.UpdateWorldTransform(); + skeleton.Update(deltaTime); + + skeleton.UpdateWorldTransform(Skeleton.Physics.Update); game.GraphicsDevice.Clear(Color.Black); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); @@ -229,7 +233,7 @@ namespace Spine { SkeletonJson json = new SkeletonJson(atlas); json.Scale = 0.5f; SkeletonData skeletonData = json.ReadSkeletonData("data/mix-and-match-pro.json"); - + skeleton = new Skeleton(skeletonData); AnimationStateData stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); @@ -259,7 +263,9 @@ namespace Spine { public override void Render (float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); - skeleton.UpdateWorldTransform(); + skeleton.Update(deltaTime); + + skeleton.UpdateWorldTransform(Skeleton.Physics.Pose); game.GraphicsDevice.Clear(Color.Black); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); diff --git a/spine-monogame/spine-monogame/spine-monogame.csproj b/spine-monogame/spine-monogame/spine-monogame.csproj index 6bab1904a..19e940491 100644 --- a/spine-monogame/spine-monogame/spine-monogame.csproj +++ b/spine-monogame/spine-monogame/spine-monogame.csproj @@ -57,6 +57,12 @@ spine-csharp\IkConstraintData.cs + + spine-csharp\PhysicsConstraint.cs + + + spine-csharp\PhysicsConstraintData.cs + spine-csharp\IUpdatable.cs