GAME PROGRAMMING RESOURCES

CLASSIC RAGDOLLS AND
SKINNED RAGDOLLS

In this tutorial we assume you fully understand this document.

RIGID BODY-PARTS RAGDOLL

A classic ragdoll is made of rigid body-parts (dynamic bodies) connected together by joints. Joint rotations are limited to approximate human body joints. Also, response properties for joint stops (rotational limits) and joint's rotational friction are set to achieve a convincing behavior.

The first step to understand ragdolls is opening, compiling and testing the Ragdoll project by following the procedure described in the Quick Start Tutorial for the BallGame project.

The demo allows you to play with ragdoll physics. Press [Ctrl] to fly the ragdoll, arrow keys to pull it around. Press [Esc] to terminate.

The source code is fully commented and examining it is strongly recommended!

Don't forget to refer to Reference document for details on all functions called in the source code!

REPLACING THE DEMO RAGDOLL
WITH YOUR OWN HUMAN MODEL

The following is just one possible procedure to model a ragdoll. It was followed, step-by-step, to make the demo ragdoll model.

1. Make a boned human figure, about 2 meters tall. 'Boned' means that it must include a skeleton made of bones connected to resemble the human body skeleton.

NOTE: all faces/vertices in the skinned mesh must be assigned to at least one bone, even if they constitute a part of the mesh that isn't animated. Non-boned parts will not render in 3Impact.

At least, the following 10 bone-joints should be there (assume 'Hip' as root bone):

  • Hip-ThighLeft, ThighLeft-ShinLeft
  • Hip-ThighRight, ThighRight-ShinRight
  • Hip-Chest
  • Chest-Head
  • Chest-UpperArmLeft, UpperArmLeft-ForearmLeft
  • Chest-UpperArmRight, UpperArmRight-ForearmRight




  • For our sample model we have defined more joints, but only the 10 listed above will be actually used by the demo ragdoll implementation.

    Save the model as a .x (DirectX®) file including bone information. In the example this file is called 'androrest.x'.

    2. Remove the skeleton and save the model 11 times, in your modeler's format, generating different files named, for example, 'androHip', 'androThighLeft', 'androShinLeft', 'androThighRight', 'androShinRight', 'androChest', 'androHead', 'androUpperArmLeft', 'androForearmLeft', 'androUpperArmRight' and 'androForearmRight'.

    Then load back each model, remove all polygons except those forming the body-part the model refers to, and save as .x (DirectX®) files ('androHip.x', 'androChest.x', etc).

    This procedure will ensure that all body parts preserve the original model-center (their location respect to modeling application's world center), thus ensuring that the body parts will assemble to the original human figure when they are loaded and placed to specific 3d coordinates, in 3Impact virtual space.



    3. By using each body-part mesh as a reference, make a collision detection model and save it as an '_.x' file ('androHip_.x', etc).

    Note: make sure that, in the process, you do not change the model location respect to the modeler's world center!



    4. By using each body-part mesh as a reference, make also a mass model, and save it as an '__.x' file ('androHip__.x', etc). Then generate the .spg file from the collision and mass models.

    Again, make sure you do not alter your model center!



    5. Because mass models have to be closed hulls, they can usually be used as shadow caster as well with no modifications. Simply save your mass models to new files named, for example 'androHip_shadow.x', etc.

    6. You should end up with:
  • a whole-figure boned model (e.g. 'androrest.x')
  • 11 texture mapped models, one per body-part, i.e 'androHip.x', etc.
  • 11 shadow caster models, one per body-part, i.e 'androHip_shadow.x', etc.
  • 11 .spg files, one per body-part, i.e 'androHip_.spg', etc.


  • Simply load your files in place of the demo one's, in the Ragdoll code and see what happens!

    SKINNED RAGDOLL

    Unlike a classic ragdoll, rendered as 'assembled' rigid meshes attached to the dynamic bodies (body parts), a skinned ragdoll is rendered as a skinmesh with its bone-joints 'attached' to the joints that connect the body parts together.

    Skinmesh bones will 'stick' to ragdoll body-parts following their movements. As a result, the skinned mesh will move arms, legs and all other parts by following ragdoll physics, performing a stunning animation effect with no joint seams.

    First of all, let's examine and run the the demo code. Differences from the classic ragdoll code are commented.

    Open, compile and test the SkinnedRagdoll project by following the procedure described in the Quick Start Tutorial for the BallGame project.

    Press [Ctrl] to fly the ragdoll, arrow keys to pull it around. Press [Esc] to terminate.

    The source code is fully commented and examining it is strongly recommended!

    Don't forget to refer to Reference document for details on all functions called in the source code!

    MAKING YOUR OWN
    SKINNED RAGDOLL

    You have already modeled all you need. Simply, in your modeler, make sure that your boned model morphs realistically when bones are bent within reasonable angles.



    In our example, we also applied a simple texture and a smooth surface material to the human model.

    SKINNED RAGDOLL REMARKS

  • Single texture mapped models representing body-parts are no longer needed, as the ragdoll is rendered (visualized) by showing the boned mesh (skinmesh) now.


  • Rigid shadow casters are easier and faster to render, but do not self-cast properly. So, remember that skinmeshes too can cast volumetric shadows. An improved version of the demo would use a skinmesh shadow caster instead.



  • BREAKABLE RAGDOLL!

    Commented source code implementing an amazing breakable ragdoll can be accessed as follows:



    Open, compile and test the BreakableRagdoll project by following the procedure described in the Quick Start Tutorial for the BallGame project.

    Press [Ctrl] to fly the ragdoll, arrow keys to pull it around. Press [Esc] to terminate.

    The source code is fully commented and examining it is strongly recommended!

    Don't forget to refer to Reference document for details on all functions called in the source code!