##### Share on other sites
Quote:
Original post by MikeTacular
Quote:
Original post by CodaKiller
Quote:
 Original post by MikeTacularwhy do you have to change the center of rotation?

When rendering, are you translating before rotating, or rotating before translating? In that picture it looks like you're doing the latter when you want the former. It seems like it should be simple (but maybe I'm missing something):

1) Get the world matrix for each bone
2) Translate to the bone's position
3) Rotate according to the bone's angle
4) Render the stuff connected to that bone

However, if you can get some relative matrix (as opposed to a world matrix) you can multiply the current matrix by that relative matrix and get the new matrix.

P.S. Very nice pictures, it's helping clarify things a lot.

Thats just it, it seems simple but when I actually do it nothing happens, I know it's an error in the way I am calculating it but I have no idea whats wrong.

EDIT: Wait no, I believe it is offsetting the center of rotation but it's way off from where it should be.

[Edited by - CodaKiller on January 20, 2009 6:14:26 PM]

##### Share on other sites
"D3DXMatrixTranslation( &pos, mesh->bones.matrix._41, mesh->bones.matrix._42, mesh->bones.matrix._43 );"

This provides a ROW MAJOR matrix. You have taken that into account have you?

Try to transpose it, just for fun.

##### Share on other sites
This may help, it's basically exactly what I do in opengl for rotating around a specified origin:
   glPushMatrix();   if(!translateTo.atOrigin()){      glTranslated(translateTo.x, translateTo.y, translateTo.z);   }   if(!scaleTo.atOrigin()){      glScaled(scaleTo.x, scaleTo.y, scaleTo.z);   }   if(!rotateTo.atOrigin()){      glTranslated(rotateOrigin.x, rotateOrigin.y, rotateOrigin.z);      glRotated(rotateTo.x, 1.0, 0.0, 0.0);      glRotated(rotateTo.y, 0.0, 1.0, 0.0);      glRotated(rotateTo.z, 0.0, 0.0, 1.0);      glTranslated(-rotateOrigin.x, -rotateOrigin.y, -rotateOrigin.z);   }   drawthebone   glPopMatrix()

NOTE: atOrigin() is a function that basically checks to see if the vector is 0, 0, 0

See the rotate part? That's where you can specify to rotate around a specified origin.

However you do that in directx would be it.

Not sure if this is helpful. I store objects with a local translation and scale value and then also a rotation value and a rotation origin. That is what all these points relate to... It sounds like you're already doing this though and the problem lies with your shader (which I am not familiar with), so this is more an explanation to the people asking you why you're doing what you are.

1. 1
2. 2
Rutin
23
3. 3
4. 4
frob
16
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632579
• Total Posts
3007174

×