Rotate/Translate ragdoll in PhysX

Started by
4 comments, last by gabzuka 14 years, 1 month ago
Hi Guys, I've got a ragdoll working using PhysX which I render using a mesh with skin and all. Everything is working but now I need to place my ragdoll somewhere else in my scene and rotate it slightly (it is currently just sitting at the origin). I tried rotating it by changing the global orientation of each actor but although it rotates it deforms the ragdoll (each actor rotates around a different point maybe?). Any ideas on how I could accomplish this?. I would think this is a trivial thing to do but haven't been able to find out how. Thanks a lot! G
Advertisement
Compute the relative transform between the bodies in the original position. Then move them all by your new basis, preserving the relative transform.
void MoveRagdoll( Ragdoll& ragdoll, const Matrix& newTransform ){  Matrix originalTransformInv = someBody.Transform.Inverse( );  foreach( Body b in ragdoll )  {    Matrix relativeTransform = b.Transform * originalTransformInv;    b.Transform = newTransform * relativeTransform;  }  someBody.Transform = newTransform;}


Same with their linear and angular velocities, or just set those to some other new value.
Quote:Original post by bzroom
Compute the relative transform between the bodies in the original position. Then move them all by your new basis, preserving the relative transform.

Same with their linear and angular velocities, or just set those to some other new value.


Thanks bzroom.

I kind of get what you mean but I didn't get what this is supposed to do:

Matrix originalTransformInv = someBody.Transform.Inverse( );


I tried doing only this:
b.Transform = newTransform * relativeTransform;


and it works only that it rotates around the origin instead of around the centre of the object.

I tried moving the object to the origin, rotating, moving back to the original position and then multiplying by the original transformation (transToOrigin * newTransform * transBack * currentTransformation) and although it rotates in-place it messes up the mesh.

Any ideas?

Thanks a lot guys,

G
Looking a bit into the transform created by PhysX to transform each part of the ragdoll I noticed that there are some values in these places of the matrix (marked with an X):
| - - - X || - - - X || - - - X || - - - X |


Shouldn't that matrix only have values for translation and rotation?.
someBody.Transform is the point you want it to pivot around. You can choose any bone in the ragdoll, or you can choose the actor, or you can choose any arbitrary point in the world. By leaving that out you effectively chose the origin.
Quote:Original post by bzroom
someBody.Transform is the point you want it to pivot around. You can choose any bone in the ragdoll, or you can choose the actor, or you can choose any arbitrary point in the world. By leaving that out you effectively chose the origin.


Thanks bzroom, I'll try that when I get home.

G

This topic is closed to new replies.

Advertisement