Converting XNA Matrix to JMatrix for TransformedShape #95
Replies: 6 comments
-
This looks okay. It depends on the definition of your transformations. Did you try to set the transpose, i.e. flipping Mxy to Myx. If this does not resolve the problem you can try to debug the transformation by utilizing |
Beta Was this translation helpful? Give feedback.
-
Okay I had no idea about the debug drawer, very handy thank you. For any XNA/Monogame user which might stumble upon this in the future, here's a rough implementation of the IDebugDrawer I quickly whipped up. It's not terribly efficient and has a lot of room for improvement but it should give you a base.
When drawing a rigid body elsewhere in your code, call PrepareForRigidBody(); then call Body.DebugDraw then finally call DrawRigidBody() At least this way you're doing a little bit of batching |
Beta Was this translation helpful? Give feedback.
-
Very nice. Have you been able to debug/fix the problem with the XNA<->Jitter conversion? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This looks interesting. Is there a reason why you do not just build the (unrotated) house using box shapes and then apply the rotation and position of the house to the body, i.e.
? |
Beta Was this translation helpful? Give feedback.
-
Oh. I had no idea you could do that. Yes that completely solved it lol. Thank you a bunch, also I've made a pull request to add JitterPhysics2 to the official Monogame suggested libraries (there currently are no suggested 3D physics engines!) so hopefully that gets merged soon! Thanks for all your hard work |
Beta Was this translation helpful? Give feedback.
-
It seems my rotated models are appearing different than the collision shapes in Jitter. Here is how I'm converting them:
public static JMatrix ToJMatrix(this Matrix matrix) { return new JMatrix( matrix.M11, matrix.M12, matrix.M13, matrix.M21, matrix.M22, matrix.M23, matrix.M31, matrix.M32, matrix.M33 ); }
Is this correct?
I'm then creating a transformedshape:
TransformedShape tfs1 = new(boxShape, center,rotationMatrix.ToJMatrix());
Beta Was this translation helpful? Give feedback.
All reactions