Exporting Characters to Engine

Overview

Bodies

Exporting the Model

A model can be exported as a character only when it is weighted to at least a single Bone using the Skin modifier.

It is highly recommended you are using a skinning method which is Quaternion, this creates a more accurate deformation around joints.

When exporting a character, make sure that you select the .chr export option in the exporter settings.

Setting Up the Material

This is necessary to ensure that the character will be displayed correctly and that all the physical attributes behave correctly.

The material of a character underlies the usual restrictions of the material system.

By default, the in game model will look for an .mtl (material file) with the same name as the material that it got assigned in 3ds Max. It should have the same name as the model to make it easier to identify.

  • Name of the object's default material: You need to name the material file, Marine.mtl in order to automatically load it with the object in Sandbox.
  • 11 is the minimum number of materials for a standard character using the Biped.
  • The first 10 materials are reserved for the skeletal information.
  • The last material is the material actually displayed in the game.

Refer to the for more information.

The same material displayed in the Sandbox Material Editor:

  1. Materials reserved for the skeleton.
  2. Actual material of the rendered model itself.

Character Physics Authoring

For a detailed description, refer to the Ragdoll reference document.

Creating a Material

For a detailed description, refer to the tutorial.

Preparing character for Animation

Once you have exported your base character you will want to refer to the for more information.

Setting Up a Simple .CDF File

CDF - Character Definition File

Although this is not necessary, it allows you to modify and vary the characters and in most cases it is used to have the same base skeleton with attached animations for many characters that have alternating attachments for variation. An attachment-based system usually contains an empty (no draw) .chr, including a physicalized skeleton which becomes the base skeleton for many other characters. Onto this skeleton-model, various other .chr or .cgf files (potentially with a different set of materials) can be attached as desired and saved as a .cdf file.

Attaching character models to each other through skin attachment works only if both models have been exported based on the same skeleton. This means that the skeletal hierarchy and the bone naming of both models needs to be identical. However, objects that will be attached to each other are allowed to have less bones then the base model.

  1. This is the initial bone system, containing 4 bones.
  2. This is the base model, skinned to the initial bone system.
  3. The branch has been removed from this bone system; the naming remains the same (this model could be attached to either 1 or 2).
  4. This bone system has another branch. The naming of the base and the first branch is the same as in 1. As it has more bones than 1, 2, or 3, it cannot be attached to any of those. On the other hand, using 4 as the base will allow 2 and 3 to be used as attachments.
Character Editor UI

  1. Attachment list: This is the list of all the attachments that are being attached to the base model.
  2. The objects and material slot: Loads attachments; the mtl slot allow the assigning of custom materials to the attachments.
  3. Attachment styles: Lets you select the way you want to attach the attachment.
    1. Bone attachment: The attachment can be placed wherever you want and will be stuck to the selected bone. Do not attach a .chr as a bone attachment, as attaching one skeleton to another will consume unnecessary memory. This works well for hats, glasses, and everything that needs to stay 100% in place.
    2. Face attachment: The attachment will look for the next and closest Polygon. It will be stuck to this polygon and always be woven along with it. This can be tricky in areas with strong deformation such as armpits or the belly area. It works well for pouches, external pockets, holsters, and everything that just stick to the surface.
    3. Skin attachment: Use this to attach one .chr file to another. You won't be able to move the model anywhere as the deformation is limited by the skin weights. It works well for heads, hand, exchangeable body parts, and everything that needs to be very accurately placed.
  4. Position tools: Use these tools to position the bone and face attachments.
  5. Character slot: This allows you to assign a custom material to the base model.
  6. (and 7) Shape deformation slot: This slot allows you to alter the size of vertex color-coded areas. Use the Wireframe check box to display the assigned colors and the bar or the text field to vary the model to the required size. The natural value goes from -1 to +1, but those values can be exaggerated up to -2/+2.

Creating a Character with Exchangeable Parts

It is also possible to create a character whose parts are 100% exchangeable. For the base character, you can use a simple object like a box, which should have a no draw material assigned. This will make sure that you won't have to deal with any visual glitches later in the game. This model contains the skeleton and all the necessary information.

All other parts can now be attached to this model using the Character Editor.

Creating and Exporting Morphs

Morphs are stored as sparse morphs. This means that only the distance of the actual, different vertices will be stored. This saves a lot of memory. A side effect can be that the *.max files can become quite large (150MB), while the *.chr file, including all these morphs, stays small (1.3MB). The file size heavily depends on the vertex count and the amount of morphs you use.

When you create morphs, you have to ensure that the base mesh and all the morphs:

  • Share the same vertex count.
  • Share the same vertex IDs.
  • Have their pivots in the same relative space.

For exporting morphs, you only need to add a morph modifier onto the model, and then add all the morphs into its list.

  1. The Morph modifier is applied beneath the skin modifier.
  2. The Exporter will export only whatever is stored in the Morph modifier. Make sure that you click Reload All Morph Targets before you export any morphs. Optionally, you can use the auto refresh option of the Morph modifier. However, it may become slow and jerky when the Morph modifier fills up.

A character equipped with morphs exports like every other character.

Ensure that the morph offset is set to 0.0001. The morph offset culls unnecessary data from the morphs. The number will set the maximum number of decimals that can be used for vertex coordinates within a morph target. Values too low (0.00000001) can produce gigantic files. Also, high values (1) will cull all the morphs and no morphs will show up in the game.

This value is very important.

By default, 3ds Max displays only 2 decimal points (0.01). If you want to see what you set up, in 3ds Max, go to Customize > Preferences > Spinners > Precision and raise the decimal count.


This value will set the spinner accuracy.

You can export multiple meshes at once; just add them in the Object Export list box.

Character Orientation

Make sure the character (without animations) is facing positive Y in the Editor. It cannot be stressed enough, you need to always check characters for correct orientation in the Character Editor, as if it is set up incorrectly, you will encounter flipping of your animations.

In order to see the base pivot, click ShowBase in the Debug Options (this is highlighted with a red box in the screenshots below.


Notice how the character faces positive Y in the Character Editor. It's extremely important that your exported .chr is like this (irrespective of the DCC you used to create the character).


Notice how the character faces the negative Y axis. This is wrong.