Sign in to follow this  
gabzuka

Rotate/Translate ragdoll in PhysX

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this