Videogame Physics: Introduction Early Video Game Physics Modern Video Game Physics Dynamic Objects Ragdoll Physics Physics Hall of Shame Bibliography/Links |
Ragdoll Physics Inverse Kinematics, Your New Friend While there are many solid gameplay enabling examples of realistic physics in modern videogames, there are also a lot that are just eye candy. One common feature used today is called 'ragdoll physics'. Ragdoll effects occur when a videogame character goes limp(usually after death) and the body realistically falls against walls and the floor. In past 3D games such as Id Software's Quake, creatures would simply fall to floor in a preset animation when they died. Of course, for a game in which your soul purpose is to kill stuff, this would not suffice. So with dedicated graphics processors coming into vogue and the CPU being freed up for physics compuations, these dead bodies started being treated as a set of rigid bodies falling to the floor. Screenshot from FarCry by CryTek Games. Notice how this poor fellow's body wraps around the pipe realistically. A real description of ragdoll physics requires first an understanding of how 3D videogame characters are animated. Typically a model of the various bodyparts or in some cases the whole body is created from polygons. Certain sets of these polygons are assigned to a bone, which is part of a larger skeletal system. For instance, the polygons associated with the arm would form a bone. These bones are connected by hinges, and can be arranged into a hierarchy. This way, if the animator rotates the upper arm, the lower arm and hand will rotate as well. With the skeleton in place, the animator can create keyframes defining an animation and the skeleton will interpolate between them to create smooth animation. From PlanetQuake's MilkShape 3D tutorial. With ragdoll physics, these preset animated keyframes are thrown to the wind, and each bone is treated as a rigid body. Of course, it would look absolutely ridiculous if you didn't have a system of restraints on the body(just imagine a body's arms rotating a full sickening 360 degrees and you can see the need for restaints). Actually getting the body to move in a realistic manner is definitely NOT a trivial problem. This problem makes getting crates and barrels to play nice together look easy. You see, crates and barrels are unencombered by the complications of inner dependencies. When a crate hits a wall, it doesn't have arms and legs with well over 3 bones a piece that must react realistically without exceeding their restaints. Thus, for the most part, games fudge it. Our old friend inverse kinematics rears its ugly head here. Well, he may not be an old friend to you, but many a videogame programmer has butted heads with inverse kinematics. What's this kinematics business all about? 'Forward Kinematics' as applied to our skeleton system is where you specify the angle of say, the upper arm, and you calculate where the forearm and hand should be. This is a fairly trivial operation(extremely trivial in fact). 'Inverse Kinematics' is MUCH more complex. In this case, given a position of a hand, you can calculate the angles of the forearm and upper arm subject to constraints(e.g. so you can't rotate upper arm more then 30 degrees behind head). This is why IK is used for ragdoll physics. It's not too hard with collision detection to determine where the various parts of the body should be, but figuring out how the body's joints should rotate in order to achieve that position is hairy, hairy stuff. From PlanetQuake's MilkShape 3D tutorial. This is a particularly complex skeleton with a lot of bones! Because IK chews up CPU cycles like a rabid dog on fire, a typical simplification is to let the body pass through objects while it is flying. For instance, if you shoot a guy with a rocket launcher and he goes flying across the map, the game only computes collision detection for a bounding box approximation of his whole body. The arms flail wildly, and in some games ignore constraints, because the body is moving too fast to be scrutenized closely by the player. Then when the big simple bounding box hits something like a wall, full ragdoll physics go into effect. While this does often have funny results, such as arms going right through walls, it keeps the game running smooth. In end, does it really matter that much? It's cool just to watch the body go flying, or roll down a flight of stairs realistically. Yes, we gamers are a strange bunch. We game developers are stranger. Only a game developer would subject him/herself this much trouble to make virtual bodies roll around virtual worlds. |