General 3d Physics Question


dflemstr

It's a ball.
Joined
Jul 31, 2008
Messages
2,514
Location
Stockholm, Sweden
Website
Visit site
So, basically I'm making a game that relies heavily on a 3D physics engine (Bullet, in this case).
Let's not discuss wether or not it will be possible to use Bullet on the Pandora, I'm currently getting 2000 FPS on my main machine so it shouldn't be a problem I hope :p

The problem is the following:
- I use OpenGL for drawing.
- My 'Drawable' class (it's not really called Drawable but instead split up into 8 different classes, I'm simplifying things here) stores it's rotation in a 3D Vector (Vector3f), where each element of the vector represents one axis rotation (so vector.x represents the rotation around the x-axis, etc). This is to enable graphics engine backend modularity; I don't want to use something too engine-specific for the rotation.
- The 'Drawable' class is linked to a RigidBody in Bullet, so when the bullet body moves, the Drawable moves.
- Bullet uses pure matrices internally for dynamics + transformations, but spits out a quarternion (Quat4f) when I ask for the rotation of a physics object.

Now, I need to convert this quaternion into a more 'normal' vector for rotation transformation. How would I go about doing this? I've never worked with quaternions before so I have absolutely no idea on how to handle them.

Any help would be greatly appreciated!
 
Last edited by a moderator:
benjymous said:
A bit of googling finds this, which seems to answer your question

CODE
http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54


Well, I saw that section too during my googling, but the result there is a 4x4 matrix, which only compilcates my problem because I lose direction information :p (Remember: the goal is to have a 3-element vector with euler rotation information)
Thanks anyways.
EDIT: I'm so stupid... I filtered out Wikipedia from my search because I had already searched there before without finding anything. Now I googled again, and what do I find?
CODE
http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

0970efe89653cb470118cc1bcb039bc3.png


So, OK, nevermind everyone, problem [SOLVED].
 
Last edited by a moderator:
Back
Top