Advertisement

Rotation problems....

Started by May 23, 2003 04:59 PM
4 comments, last by NeXius 21 years, 8 months ago
Hi Lately I''ve been messing around with ragdoll physics (a la UT2k3) and have a working demo with cylinders... But I suck with rotations (the ragdoll physics are done using a particle system) so I can''t figure out how to draw the model correctly given the orientation of the ragdoll! I''m using ms3d models (milkshape) and base the original ragdoll on the position of the joints. So, if I update the joints with their new positions each frame, then I suppose I would want to rotate all the vertices based on the new position of the bone... but I can''t figure it out. Help?
MSN: stupidbackup@hotmail.com (not actual e-mail)ICQ: 26469254(my site)
Wouldn''t the vertices be translated uniformly with the bones already?
Advertisement
No, they never rotate

So the head will always be pointing up, even when the bone that connects the neck to the head is parallel to the ground
MSN: stupidbackup@hotmail.com (not actual e-mail)ICQ: 26469254(my site)
If the head is still up even if the neckbone is paralel to the ground you have to calculate the angel between a vector with the direction from the neck to the head and the normal-vector of the ground and add the pan tilt roll are what you want, so that you can nodd with the head or what else.
basicly done like this.
v1, v2 = Vectors
v2 = the normal of the ground
a = the angel
cos(a) = (v1.x*v2.x + v1.y*v2.y)/(|v1|*|v2|)
|v1| is the length of the vector,
so
a = arccos(v1.x*v2.x + v1.y*v2.y)/(|v1|*|v2|)
for 3D you need to set v1.x = 0 to get the angel of rotaion around the x-axis and when you set v1.y = 0 then you get the angel around the y-axis.
I hope it helped, and my english isn''t to bad.
the way i solved this problem was to find coefficients for points in the physical model that correspond to bone up/right/forward/trans vectors (rotation matrix) and then extract the transformation after every physics update and apply it to the skinned mesh. it means you need to have at least four points for each rigid body, and they can''t deform (ie. use tetrahedrons)

hope this helps,
james
Thanks zerotacg and AP for your replies

I think I know how to do it now

At the moment (with just cylinders) it''s pretty fun. Once I fix the problem with the mesh I''ll try to post a demo (assuming I can fix it)
MSN: stupidbackup@hotmail.com (not actual e-mail)ICQ: 26469254(my site)

This topic is closed to new replies.

Advertisement