# Rotate/Translate ragdoll in PhysX

This topic is 3038 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
Quote:
 Original post by bzroomCompute 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 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 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 on other sites
Quote:
 Original post by bzroomsomeBody.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

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 30
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631741
• Total Posts
3001980
×