Archived

This topic is now archived and is closed to further replies.

Funkodysse

What is wrong?

Recommended Posts

hi. if(raknare>30)raknare=0; raknare=raknare+0.04; HDC hdc=GetDC(hWnd); SetTextColor(hdc,RGB(0,0,0)); float sinusen=sin(raknare); float cosinusen=cos(raknare; sprintf(texten,"raknare=%f", raknare); TextOut(hdc,100,100,texten,strlen(texten)); sprintf(texten,"sin-raknare=%f", sinusen); TextOut(hdc,100,120,texten,strlen(texten)); sprintf(texten,"cos-raknare=%f", cosinusen); TextOut(hdc,100,140,texten,strlen(texten)); D3DXMATRIX Worldrotate D3DXMATRIX Worldtranslate; D3DXMATRIX matWorld; D3DXMatrixTranslation(&Worldtranslate, sinusen*2, cosinusen*2, 0); D3DXMatrixRotationYawPitchRoll(&Worldrotate, raknare, raknare, raknare); D3DXMatrixMultiply(&matWorld, &Worldrotate, &Worldtranslate); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); this is so strange. if i change the rotation scheme by adding e.x a variabel to the D3DXMatrixRotationYawPitchRoll (like the counting variable "raknare"), the translation changes??, why is that?. have i done some wrong with the Matrixmultiply so that the the 2 D3DXMatrixTranslation and D3DXMatrixRotationYawPitchRoll are affecting each other?. Edited by - Funkodysse on November 16, 2001 5:26:13 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Translate, THEN rotate.
The order of your matrix calculations DOES matter

Share this post


Link to post
Share on other sites
so instead of this:
D3DXMatrixMultiply(&matWorld, &Worldrotate, &Worldtranslate);

this:
D3DXMatrixMultiply(&matWorld, &Worldtranslate, &Worldrotate);

?


i tried that but it didn't help, the object is like a drunk dude now . rolling around on the screen . but is it possible to make a straight y,x,z translation and still rotate the object, or is the rotation affecting the translation so the rotation distorts the y,x,z translation?



Edited by - Funkodysse on November 15, 2001 12:24:50 PM

Edited by - Funkodysse on November 19, 2001 3:56:13 AM

Share this post


Link to post
Share on other sites
I tried to swap the order of translate and rotate on my laptop, and there it worked but not on my stationery?. how come?.

thanks in advance

Edited by - Funkodysse on November 16, 2001 5:27:09 AM

Share this post


Link to post
Share on other sites