Sign in to follow this  
the dodger uk

its rotating the wrong way ?

Recommended Posts

trying to rotate an object in conjution with a main object so , in stays local to it. via maths float x = -2; float y = 5; float matrix[16]; player->GetMatrix( matrix ); float matrixSinMinus = matrix[2]; float matrixSin = matrix[8]; float matrixCos = matrix[10]; // rotate local corners to there real world position float tx,tz; tx = (matrixCos * x) + (matrixSinMinus * z); // dim3d is all correct tz = (matrixSin * x) + (matrixCos * z); Model->SetX(tx+player->GetX()); Model->SetZ(tz+player->GetZ()); if i rotate the player , the player rotates, but the Model that i want to keep local to it rotates in the oposite direction . can you tell me what i got wrong

Share this post

Link to post
Share on other sites
Why doing things so complicated? If you want to apply parenting to an object, then multiply its (local) transformation matrix with the world matrix of the parent and you're done. E.g. so:

float matrix1[16];
float matrix2[16];
float matrix3[16];
player->GetWorldMatrix( matrix1 );
model->GetLocalMatrix( matrix2 );
matrix3 = matrix2 * matrix1;
model->SetWorldMatrix( matrix3 );
(where matrix3 is calculated assuming you use row vectors; re-order the multiplicants if you use column vectors).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this