how to transform by rotation?

compound

01-10-2007 13:38:01

using ogrenewt i was wondering how it is possible ensure the force applied to the character is in the correct rotation for the character, as i have used newton before with directx and it is possible to get the world matrix applied to the entity, decompose it, in order to obtain a rotation matrice, then transform the force vector by the rotation matrice, how in ogrenewt is it possible to obtain a matrice based on its rotation?

sorry if this is simple, i couldnt find anything in the search

walaber

02-10-2007 02:43:03

you can use addLocalForce() to add a force in the local space of a body.

compound

02-10-2007 23:06:02

adding it locally seems to have some strange affects, i.e when the model is at a different rotation than it is originally set it appears to go round in circles when supposed to be moving forward

any ideas what i have done wrong?

compound

03-10-2007 14:43:54

ok so ive got this far

Quaternion rot = mNode->getWorldOrientation();
Matrix3 mat;
rot.ToRotationMatrix(&mat);


force.x = ( mass * ( ( _cForce.x - velocity.x ) ) );
force.z = ( mass * ( ( _cForce.z - velocity.z ) ) );

now i need to work out how to transform _cForce by mat

any ideas?

edit:

transforming in the same way directx does doesnt actually seem to make a difference

force.x = ((mat[0][0] * force.x)+(mat[0][1] * force.y)+(mat[0][2] * force.z));
force.y = ((mat[1][0] * force.x)+(mat[1][1] * force.y)+(mat[1][2] * force.z));
force.z = ((mat[2][0] * force.x)+(mat[2][1] * force.y)+(mat[2][2] * force.z));

compound

06-10-2007 16:23:23

it seems the simplest solutions are always the best lol

Quaternion rot = me->getOgreNode()->getOrientation();
_cForce = rot * _cForce;

force.x = ( mass * ( ( _cForce.x - velocity.x ) )/deltatime );
force.z = ( mass * ( ( _cForce.z - velocity.z ) )/deltatime );