Modifying the quaternions? (In the context of body rotation for Newton physics)

Started by NoNameHere, November 19, 2019, 12:58:26

Previous topic - Next topic

NoNameHere

Hello everyone.

I've been trying to do some physics in OpenB3D with the use of newton.dynamics module, and it mostly works but has a little problem with rotations. A GIF would do a good job to show: https://imgur.com/a/Tlh3Olo

Notice how the cubes sort of twitch?

My only guess is that it's happening because i'm using pitch, yaw and roll to do the rotation, and it is prone to gimbal locking. I've tried to dig around in the OpenB3D source looking for a way to rotate the object using a quaternion, but didn't come up with anything that works.

Here's my code: https://gist.github.com/AXKuhta/2406f722c7ffb3ca24ce79b4be613fe1

NoNameHere

#1
I wasn't reading the source code well enough!

OpenB3D has a function specifically to get the body coordinates from Newton: MQ_ApplyNewtonTransform_()

I've updated my code on github gist to use it, and it seems to work properly now. EDIT: No, there's still something odd happening; it seems that the cubes have their Z-axis inverted now.

P.S.: said code is under WTFPL, you can take it if you need it :)

Kippykip

woah this is pretty cool, you consider ever putting examples on using physics in OpenB3D?