Hi,
I've been struggling to implement ragdoll physics for my animated (boned) characters for the past week or so. I already have the basics of the physics setup working fine, plus I can import my ragdoll character (with constraints, etc) into the engine and have bullet simulate everything correctly. However, this only works when an object's transform is correctly centered to the object.
My main problem is, I think, due to the fact that the bone objects have their transforms positioned at the end of the objects (i.e roughly where the joints are), while Bullet expects/requires the object's transform to be centered to the object in order for the simulation to work as expected. Initially, I tried manually adjusting the bone object's center-of-mass using a call to its setCenterOfMassTransform, however this seems to have no effect unfortunately (not sure why, I would've expected this to have worked tbh).
After searching these forums, I came across the last post in this which indicated that the way to handle this was to calculate a local transform to translate from the bone's offset to the bone's center, and to pass the resulting transform to Bullet instead. I also ensure that the collisionShapes passed are now in the coordinate space of the actual centre, not the bone's transform position. Then, when later retrieving the updated transform from Bullet, I should multiply by the inverse of the previously-calculated local transform in order to have the correct transform for the graphical representation.
However, I've had no joy with this either unfortunately, as the simulation still doesn't behave as expected. What also doesn't help is that I'm unable to use the debugDrawing methods to help pinpoint the problem, as I'm developing on iPhone without access to Glut (I believe). Regardless, has anyone else experienced this problem and can give some pointers, or possibly point out where I might be going wrong.... really starting to pull my hair out now!
Thanks
animating a ragdoll using existing bones
-
- Posts: 3
- Joined: Sat Jul 11, 2009 8:08 am
Re: animating a ragdoll using existing bones
I can't help with the ragdoll I'm afraid, but you can sort out your debug rendering issue by creating your own class that overrides btIDebugDraw and calling setDebugDrawer on your dynamics world. By overriding a few functions you can render debug info in a way that's friendlier with your 3D engine.
-
- Posts: 10
- Joined: Sun Feb 22, 2009 1:47 pm
Re: animating a ragdoll using existing bones
Hmm interesting, I suppose I might have to do something like that soon then, as I still haven't had any luck with this yet. Thanks for the tip anyway!
If anyone else reading has any thoughts on handling bullet objects which don't have their pivot/transforms centered though, I'd love to hear them... While searching I did turn up this thread in which somebody seems to have 'solved' this prob (8th post down), but I can't quite understand his explanation!
Thanks
If anyone else reading has any thoughts on handling bullet objects which don't have their pivot/transforms centered though, I'd love to hear them... While searching I did turn up this thread in which somebody seems to have 'solved' this prob (8th post down), but I can't quite understand his explanation!
Thanks