hi I am busy integrating newton physics into my
project , I know there is an ogrenewt wrapper available but I want to use this project with my
own integration.
so I am stuck at using quaternions , I have never
used them in my life before ogre ,I do not know
how to go from a quaternion to a matrix of 16 floats
and back from a matrix of 16 floats to a quaternion
I can apply to rotate and move my node .
I have looked at how it was done on ogrenewt ,okay
fine ,I used the functions in the source to go from
thr quaternion to a matrix into newton and found
how to go from newton back to an ogre matrix4
but ,how do I use my matrix4 to adjust my node
position and rotation ?
I do not understand how to apply the matrix to the node position and rotation because they are quaternions .
matrix4 to quaternion
- madmarx
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: matrix4 to quaternion
Hi!
If scale is nothing special (scale == 1), then you can create quaternion from this matrix by using :
Quaternion::FromRotationMatrix (const Matrix3 &kRot)
Then you can rotate or setOrientation on your scenenode with the quaternion.
To get the position : take the last column of the 4x4 matrix, and divide it by its 'w'( x/w, y/w, z/w) and you keep only x,y,z to make a position vector.Then use setPosition on the node.
Best regards,
Pierre
From the Matrix4x4 you can extract the top left 3x3 matrix. It contains the rotation and scale informations.how do I use my matrix4 to adjust my node position and rotation ?
If scale is nothing special (scale == 1), then you can create quaternion from this matrix by using :
Quaternion::FromRotationMatrix (const Matrix3 &kRot)
Then you can rotate or setOrientation on your scenenode with the quaternion.
To get the position : take the last column of the 4x4 matrix, and divide it by its 'w'( x/w, y/w, z/w) and you keep only x,y,z to make a position vector.Then use setPosition on the node.
Best regards,
Pierre
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0