Replies: 3 comments 2 replies
-
Can I ask you the purpose of using I usually just have some utility function which can build a model matrix out from JPH:Body, say a glm::mat4: JPH::Body* body = getEntityBody();
glm::mat4 modelMatrix = Utilities::buildModelMatrixForRigidbody(joltBody);
Renderer::draw(someMeshOrModel, modelMatrix); As far as I understand from the code ( JoltPhysics/Jolt/Math/Matrix.h Line 228 in e8a99bf |
Beta Was this translation helpful? Give feedback.
-
Jolt matrices are column major, I don't know what yours are. So you have Doing |
Beta Was this translation helpful? Give feedback.
-
I think I've got this figured out -- the proper order for a float[4][4] should be:
Thank you for your input on .GetRotation().GetQuaternion(). I am not strong on quaternions, but I understand their usefulness. Also, the anomalies I was experiencing (which I haven't mentioned yet) were due to convex hulls having a different center of mass than static triangle meshes. |
Beta Was this translation helpful? Give feedback.
-
I'm coming from Bullet, where I could call .setFromOpenGLMatrix() and .getFromOpenGLMatrix() and receive/pass a float[4][4] and be on my way. This doesn't seem to be as straightforward, or at least, I'm getting inconsistent results and want to ensure I'm properly passing my matrices to Jolt before I ask more questions.
When creating a body, would this be correct?
`
JPH::Mat44 mat = JPH::Mat44(JPH::Vec4(object->transform.m[0][0], object->transform.m[1][0], object->transform.m[2][0], object->transform.m[3][0]),
JPH::Vec4(object->transform.m[0][1], object->transform.m[1][1], object->transform.m[2][1], object->transform.m[3][1]),
JPH::Vec4(object->transform.m[0][2], object->transform.m[1][2], object->transform.m[2][2], object->transform.m[3][2]),
JPH::Vec4(object->transform.m[0][3], object->transform.m[1][3], object->transform.m[2][3], object->transform.m[3][3]))
JPH::BodyCreationSettings bcs(new JPH::ConvexHullShapeSettings(vertexList), mat.GetTranslation(), mat.GetQuaternion(), JPH::EMotionType::Kinematic, Layers::MOVING);
`
If I don't .Transposed(), I get wildly incorrect results, and if I Transposed() without changing .GetQuaternion() to .GetRotation().GetQuaternion(), I get an assert failure.
But let's start with the correct way to load a [4][4] matrix. Here's what one might look like:
`
`
Beta Was this translation helpful? Give feedback.
All reactions