Ragdoll Physics progress

Published March 12, 2006
Advertisement
*NOTE all the stuff in this entry is a work in progress :-) I'm going to post Part 2 in a day or two once I finish the ragdolls up.*

Over the last few days I've been working on getting ragdolls into the game. Some of you might remember my previous attempt at this :-) I think I posted some videos/screenshots of it about 5-6 months ago.

Aaaanyways my initial attempt turned out to be somewhat unsuccesfull, though I did learn a lot, and I've been waiting for a good time for another attempt. I did manage to get the ragdolls working previously, but I didn't design the system correctly to deal with dynamic positioning of the ragdoll...it would always start in the same pose since I loaded it from a model file. This time around it's all totally dynamic, and will support any character model in the game.

Plus since my last attempt at ragdolls, I've rewritten the entire game engine (essentially)...using D3DX for animation now, and doing the character skinning in hardware via vertex shaders, so it's hella faster now.

The major issues with implementing ragdolls (Since I'm using a 3rd party library to handle the rigid bodies/constraints) are as follows:
- Converting the existing 32 bone animation skeleton to a 11-12 bone ragdoll skeleton, on the fly, once the character dies, gets hit by a car, etc.
- Determine size of the rigid bodies that will make up each of the bones on the ragdoll, and come up with an algorithm to spawn them in the position of the actor's current animation frame.
- I've got to do this on the fly, which is really easier said than done.
- Spend countless hours tweaking masses, max cone angles, bone positions, forces, etc. to get good/stable results.
- There are a few more that escape me at the moment so I'll just keep going....[grin]

I've been taking regular screenshots of my progress (Good AND bad) over the last few days...and I will now use them to chronicle my ragdoll progress over the last 48 hours....

1. So the first step was to work on converting between the two skeletons. I started by extending the debug output of the game to include the animation skeleton of each of the actors currently visible....just so I could make sure everything is working as expected.



2. I then began to work on the actual conversion process for going between the two skeletons. When you hilight a actor and press 'R' they will turn into a ragdoll, that's the end goal at least.

At first, I just worked on saving the bone transforms and building a simple (and inactive) ragdoll skeleton using Newton. This is very early on, using the 30+ bone skeleton, with rigid bodies centered on the bone positions. Also, once I change a actor into a ragdoll, their skeleton is no longer animated.

The important thing in these screenshots is that the locations are being setup correctly, and can be read back from the physics engine.





3. The next step was to tie the new ragdoll skeleton BACK to the actor it was spawned by....this was a pain in the ass. You should be able to tell from these screenshots that it didn't go that well at first :-)





Throughout this whole process, the physics engine is very touchey. If anything interacts with the ragdolls while they're in this unstable state....things go wrong. The ragdoll blows up basicly destroying any physics object in the world *sigh*

...This guy is as confused as I was [grin]


A few more bloopers from this whole time period:




Finallllyy I start to make some progress and resolved the rotation matrix issues (Again...this was a pain the ass to do)...





4. Now it's time to start working on the actual RAGDOLL skeleton, which will have 11-12 bones, verses the 30+ bones of the animated skeleton...I won't need to simulate the physics of the characters fingers, so I'm going to stick to the major limbs/parts when designing the new skeleton.

As you can see it clearly worked on the first try....[grin]


Here's how it looked at the beginning of the skeleton conversion process...this happens in realtime, once I click on a actor to convert into a ragdoll, though damn it's still not working right.








5. The issues turned out to be with the mesh hierarchy not being built correctly because of the missing bones. The solution was to just plug in the last known local transformation matrix for each bone that doesn't have a associated ragdoll bone. Sounds simple enough, but maaaan....each of these 'revelations' called for a partial rewrite of the ragdoll infrastructure.

So I started to work on sizing the bones correctly, and getting everything positioned correctly. These are being output directly from the physics engine. Once I resolve all placement issues I can essentially 'turn on' the physics and the character will fall to the ground realisticly.

If the bone placement issues aren't resolved and I try to enable physics, everything will blow up...so I've got to be careful.

Here's some images of how the skeleton started to come together....




6. You can see in these images that the bones aren't touching, and there is some space between them....this was yet another issue I had to overcome. This is because all the actors have different sized skeletons/bones....so I've extended the bone placement algorithm to determine the exact size of the bone....and yes...it works....(the body mass is still offset though).



And that's where I end with Part 1 of my ragdoll adventures....I'll post another entry in a day or two with the exciting conclusion...and hopefully some videos of these badboys in action!

Also...just for the record I have managed to get ragdolls working in the game previously [grin]....*OLD SCREENSHOT ALERT*


- Dan
Previous Entry Finally, an update!
0 likes 2 comments

Comments

frecco2k
ragdoll are awesome.
cant wait for some videos of em.
March 12, 2006 10:01 AM
Gaheris
Wow, you're so damn productive. I feel ashamed of myself.
March 12, 2006 11:37 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement