Game Development Community

dev|Pro Game Development Curriculum

TGEA Rag Doll working using Tokamak

by Duncan Gray · 04/21/2009 (12:54 am) · 15 comments

I used the Tokamak physics library to implement Rag-Doll behaviour for death scenes.

It is animated client side only because we don't care if the body falls in different locations on various clients. Its visual eye candy only.

I still need to fine tune the joint rotational limits so that it mimics human behaviour more realistically and I'm having to locate/fix some collision bugs. Excuse the low-res weapon, its place-holder art. The good stuff is still being worked on.

The biggest problem I had was with trying to get/understand data matching between TGE world and Tokamak because Tokamak uses Y-axis as up and it's matrix data is also stored differently, plus, its not documented to that level of detail, but once that was ironed out I modified the TGE matrix class to import and export a Tokamak matrix and after that it was conceptually straight forward to implement the changes. Thanks also goes to David Lam, creator of Tokamak, for pointing me in the right direction with understanding the matrix differences.

I say 'conceptually' straight forward but as usual it's the finer details that turn into land-mines and headaches that consume many days and late nights.

I chose Tokamak because it comes with free source code and license and a very small footprint of only 943K for the compiled lib file. It has built in opcode functions as well but I used the existing Tokamak collision routines.

Other physics libraries apparently require you to feed them all the data upfront, meaning you need to tell them about every collision poly on every object in the game world and they handle everything from there on, which can be a good thing but there are pro's and con's to everything. Tokamak has a callback which allows you to provide your own pollylist of collision triangles which makes it easy to use in TGEA because the engine already has function calls for getPollylist and so on. The only TGEA enhancement I can still think of is to cache polly lists per bin for static objects but I have not really investigated that option yet.

So the implementation consists of an enhancement to the Player class and small changes to the animation code to allow for direct bone-control. On death, instead of firing off a death animation, we switch to ragdoll mode which will create rigid bodies and joints for each of the player limbs and orientate them the same as the current player pose and velocity. We then grab collision pollys from the surrounding area and advance time on the ragdoll, updating the pollylist if the ragdoll has fallen outside the bounds of the original polly grab area. That's the concept in short.

Now I'm sure GG staff can "roll their own" version in a day with one arm tied behind their back while solving a rubix cube with the other while delivering a lecture on the calculus of deep space gravitational field nano impulses from sun spots... but, it took me longer than that to get this far.



#1
04/21/2009 (4:37 am)
Nice work! Rag dolls are a must for any FPS today.
#2
04/21/2009 (4:51 am)
Awesome work. :) Looks pretty good.
#3
04/21/2009 (4:58 am)
Looks good. I always love Rag dolls! Do you plan to release this as a resource or is it just for show?
#4
04/21/2009 (5:47 am)
Well done, and good for you.

Quote:
I'm sure GG staff can "roll their own" version in a day with one arm tied behind their back while solving a rubix cube with the other while delivering a lecture on the calculus of deep space gravitational field nano impulses from sun spots
No one can solve the Rubix cube! okay, I can't ...
#5
04/21/2009 (9:44 am)
Awesome! I too say good for you and way to go!

Quote:No one can solve the Rubix cube!
I have.
#6
04/21/2009 (9:50 am)
Brilliant! I'd love to do something like this myself, except I wouldn't want the hassle of client/server sync, because that *will* matter for me.
#7
04/21/2009 (10:21 am)
A cool trick I've seen is to put some kind of little physics "push" around windows. Then if someone gets shot standing at a window, they are more likely to fall forward and drape over the window frame (or fall out altogether).
#8
04/21/2009 (1:12 pm)
Wouldn't one fall away from the force of the gunshot and not towards it? I mean the whole point of using physics instead of an animation solution is realism isn't it? Just asking...
#9
04/21/2009 (1:30 pm)
Nice job. I had the same thought as Gerry watching the videos. But good job on the Tokamak integration!
#10
04/21/2009 (4:31 pm)
In fact it has been -demonstrated- by the Mithbusters crew that a gunshot in fact wont throw you back as you see in the movies... the scenes where you see somebody flying back is more a movie resource than a real one.
But in fact... it is a game and it would be nicer to see bodies flying around.

Luck!
Guimo
#11
04/21/2009 (5:48 pm)
I have not gotten around to applying bullet impulses to the ragdoll but it will look better by having such in place. At this point I consider the ragdoll at proof of concept stage. Still lots of room for refinement and improvement.
#12
04/22/2009 (2:43 am)
Technically speaking, you're actually more likely to fall towards the direction of the bullet, particularly with high powered rounds. What happens is when the bullet passes through the body, it pulls the stuff along with it, so when it exits, you get that blood 'explosion' this will, when the body seizes up due to the initial shock, give a force impuse pushing the body in the direction of the shooter.
I recall a demonstration using a cantelope that was wrapped in resin to replicate the skull. It actually fell towards the shooter each time. This of course is dependant on the body seizing up instantly, and the bullet punching all the way through the body, but the idea still stands.
#13
04/22/2009 (8:48 am)
Technically speaking not many women look like Lara Croft. ;)

Even in fine art and not just in games it is what looks good that is more important than what is real. And the game player won't care what the technology is behind the scenes just that it looks good and is engaging etc.

Not saying that one shouldn't use physics solutions, just that if they don't add to the "appearance" of realism and fun etc., then one is perhaps wasting time and effort and may be better off with another less computationally expensive solution... the WW concept (whatever works).

Just speaking generally here and not dumping on Duncan's or anybody else's project. I look forward to those mentioned refinements and improvements. Keep up the good work.

And btw, that Mythbusters show is more about entertainment than it is about science. Like when they supposedly debunked that alternative magnetic energy device... it turned out (although they never mentioned it on their show) that those clowns forgot to put in the magnets...
I wonder if Big Oil is one of the shows sponsors? lol
#14
04/22/2009 (12:28 pm)
All this stuff is really cool. Is there a 'How to 101' anywhere around I can include in my Dev library to bring me up to speed on these things?


#15
04/27/2009 (6:25 pm)
It's awesome that you're bringing yet another option to the table in way of ragdolls. I for one love the ragdoll effect on death.