JBullet requires Quaternions?

Well, I decided to give up trying to implement my own physics engine (GEE WHIZ it’s hard to do!). JBullet seems to be the only actively developed 3D physics engine for Java now, so I’m trying to implement it instead.

I’ve gotten it hooked up to my engine, and am able to feed the data into JBullet and get accurate data back, except for one thing: rotational information. It looks like JBullet handles all rotations via quaternions, which although isn’t surprising in the slightest, doesn’t mesh with my non-quaternion engine. So, before I go and rewrite my engine to use quaternions instead of the traditional glRotatef, is there a way to easily convert JBullet rotational information into a 3-function call to glRotatef (one for each axis)?

Create an AxisAngle4f and call its set(Quat4f) method. This should convert to the axis angle, which can then be sent to glRotatef. Keep in mind that the AxisAngle4f’s angle is stored in radians and not degrees (which glRotate requires).

Thanks, but is there a way of breaking the AxisAngle4f down into the three separate axis calls?

For example:
glRotatef(45f, 1f, 0f, 0f);
glRotatef(10f, 0f, 1f, 0f);
glRotatef(0f, 0f, 0f, 1f);

I’m finding it really hard to add/subtract rotation around an axis when it’s all bunched up into one glRotatef call. ::slight_smile:

Edit: I went ahead and made some functions to help myself out… basically converting my rotation calls into AxisAngles, then to Quaternions, multiplying the quaternions together, and then translating back… messy, but it works. Yikes!

NOOOOOOOOOO! There is a risk of gimbal lock when using some “particular” values! Don’t do this!

Yes, yes, I know. :stuck_out_tongue:

With this new method I’m throwing in though, I don’t think it’ll be a problem. I’m basically converting to AxisAngle4f then to Quat4f, multiplying by a rotational Quat4f, then converting back to AxisAngle4f. In the end, I have a single glRotatef call. It was either that, or start using glMultMatrix for all of my rotations (which is considered slower according to my OpenGL Redbook).