Jump to content

setVelocityTransform and Manual Ragdoll Construction


Recommended Posts

Hello,

 

I am constructing ragdolls manually, and my approach through much trial and error is to create the following hierarchy:

[type : transform]

 

NodeDummy : mat4_identity

-ObjectDummy : mat4_identity

--Shape : bind_pose_smesh.getBoneTransform(bone) * attachment_T * shape_T

-ObjectDummy

--Shape

 

Where attachment_T is the offset from the bone that the attachment has.

where shape_T is the transform that the shape has when auto-generated (consequently with alignment) to the node used within the attachment. For more explanation on what shape_T is, find it bolded below.

 

This procedure allows me to take an arbitrary attachment, and correctly manually construct a ragdoll such that the shape is aligned with the attachment.

 

Seems great, BUT, when I attempt to use:

Body::setVelocityTransform

 

to have the shapes be physically driven with the animation, I have problems. Because, Body::setVelocityTransform is a method of Body, not the shape.

It seems that ragdoll automatically places the shape to where the bone is. (Not the body, to where the bone is)

So, attempts to set the velocity transform based upon the bone's transform have not worked.

 

From examining the the ragdoll sample:

I should be doing something like:

 

1) setVelocityTransform(ragdoll.getBoneTransform(boneId) * body.getShapeTransform(0));

 

However, this is not working. I end up with something like the picture attached.

 

I have also tried:

 

2) setVelocityTransform(smesh.getWorldBoneTransform(smeshBoneId) * attachment_T);

 

which also does not work.

 

Rendering these respective transforms tells me that case (1) is the transform of the shape's origin.

case (2) is the transform of the attachment item node's origin. (Note the two are not the same... the sword's origin is at the hilt, the shape's origin is at it's center. This difference is where the shape_T is being used).

 

However, I suspect that they are not working because, setting the Body's transform to the correct transform would cause the Shape to have the set transform relative to the body, thus the offset location in the screenshot.

 

What confuses me is why the ragdoll sample works?

 

I'm thinking this could have something to do with the way I set up my ragdoll, setting the shape transform. But, all attempts to move that transform into the body causes the ragdoll to incorrectly align with the skinned mesh once it's attached to the Ragdoll.

 

 

 

Am I misunderstanding something about ragdolls? Ultimately, it just seems very confusing to align the shape to the mesh using the Shape's transform. But then to have to set the target velocity transform using the body's transform, which still retains the shape's offset transform.

 

 

Any guidance would be appreciated.

post-36-0-08188600-1306453433_thumb.png

Link to comment

Frustum will make a sample with an object attached to a rag doll next week.

I believe it is Friday in Russia. I would very much appreciate a solution to this problem before the weekend, as promised.

Link to comment
×
×
  • Create New...