Jump to content
  • Advertisement
Sign in to follow this  
the dodger uk

its rotating the wrong way ?

This topic is 2991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
I'm not sure how D3D does stuff, but I think a normal rotation-around-Y-matrix would have

matrixSin = matrix[2];
matrixSinMinus = matrix[8];

Good Luck,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!