Character Setup Overview

From Valve Developer Community
Jump to: navigation, search

The following procedure is a step-by-step overview of how to prepare and compile a character for use in the Source engine, using the SOFTIMAGE|XSI Mod Tool.

Warning.png Warning: The .smd exporter addon supplied with the Source SDK does NOT work with Current versions of XSI and XSI Mod Tool. There is an updated version of the addon available here, but it still will not work with Mod Tool 7.5, the most current version. In order for it to work, you'll need to download Mod Tool 6.01 here.

Build Your Model

Warning.png Warning: The term model is used in several different (and sometimes incorrect) ways in modeling discussions. It can variously mean:
  • The character seen in-game or in the Half-Life Model Viewer, usually loaded from a .mdl file; the combination of mesh, bones and animations comprising a character. Although texture names and paths to texture files are imbedded in the .mdl file, the textures themselves are not part of the character model.
  • Incorrectly as the surface mesh created or imported into a modeling application, simulating the surface or skin of the character. Mesh or character mesh is a more precise term to be used for this modeling object.
  • A distinct type of object in the XSI Mod Tool; in XSI, for Valve character model examples: a container for a heirarchical set of deformers ('bones') and their characteristics, and for groups of objects such as animation controls for the deformers.
Note.png Note: Examine the context closely when running across the word model, on this or any page discussing 'models'.

The Goal

The purpose of modeling in the XSI Mod Tool is to put together information and export files which the model compiler, studiomdl.exe, will use to create the files necessary for the game engine (HL2, HL2DM, CS:S, etc.) to display an animated character in-game.

With regard to the XSI Mod Tool, Studiomdl will need:

  • a model reference .smd file
  • an animation or skeletal reference .smd file
  • optionally, a vertex animation .vta file (primarily for facial animations)

A detailed description of what's contained in those files can be found on the SMD file format page.

General Construction Steps

In general, there are several steps for creating a character model:

  • Create or import a mesh for the character, and apply a texture to the mesh. This provides the 'skin' that will be seen when the character model is viewed.
  • Create or import a rig (deformers and controls). This provides the structure on which the 'skin' will be placed and provides the means to animate or provide movement for the character.
  • Envelope the mesh to the deformers. The 'skin' will now move with the skeleton and be rendered as a solid object.
  • Create new or adapt existing animations for the character.
  • Export model reference, animation and, optionally, vertex animation files.
  • Create or modify .qc and, optionally, .qci files.
  • Compile the model.

Note.png Note: If a model is being constructed using the XSI Mod Tool, the number of triangles in the model must be keep within export limits: 7500 triangles per enveloped mesh or character, or 4000 triangles for prop objects or meshes without skeletons.

To get a triangle count for selected objects in XSI:

  1. Do one of the following:
    1. Click any viewport's eye icon and choose Visibility Options from the menu.
    2. From the main menu, choose View > Visibility Options (All Cameras). The Visibility Options property editor opens.
  2. From the Stats tab, activate the Selection/Scene Info > Show Selection Info option.

Texture The Character Mesh

  1. If the mesh does not have a Texture Projection (check in Explorer):
    1. Click Get->Property->Texture Projection
    2. Select a projection appropriate for the mesh.
  2. Select all the polygons in the portion of the mesh you want to texture (e.g., the head).
  3. Click Edit->Create Cluster.
  4. Click Render->Get-Texture->Image and answer Yes to make a local material.
  5. In the image section of the property box, click New and select New from file..
  6. Select the texture for the cluster just created.
  7. Open the Texture Editor (alt-7) and UV map the cluster points as appropriate.

For information on how textures in XSI relate to materials in the Source engine, refer to Character Textures and Materials.

Set Up the Eyes

  • Each eye needs its own texture. For example, "eyeball_r.tga" and "eyeball_l.tga", or "dark_eyeball_r.tga" and "dark_eyeball_l.tga" (for the right and left eyes respectively) are used as the eye textures for most Valve characters. These texture names are accessed for rendering the eyeball shaders in the engine.
  • Create and position spheres for eyeball reference. These spheres should not be textured or enveloped, and will not be exported with actual model geometry.

click to view

  • A VBS file (Visual Basic Script) such as this one can be used to determine the positions of the centers of the spheres. Download the script file and save it with a .vbs extension to a location accessible from within XSI. In XSI, open the Script Editor, load the script and press F5 to execute the script. Click on the sphere center in a Front view to get X-Y values and in a Top or Right view to get the Z value. Those positions are used for input to the QCEyes application or to manually update the .qc file for the model.

Set Up the Mouth

The mouth geometry also needs its own texture (e.g., "mouth.tga" or "fmouth.tga") which has the texture data for the upper and lower teeth and inner mouth. The texture name is accessed by the mouth shader in the engine.

Freeze Your Model

Before setting up and creating the facial animations, freeze the model using XSI's Freeze and Transform > Freeze All Transforms commands.

Define Animation Clusters

Create two clusters for the facial shapekeys (morphs):

  • One cluster for the flexible portion of the front of the face - from the lower front of the neck back to the front edge of the ears and up to the upper forehead.
Note.png Note: Be sure NOT to include the teeth or inner mouth polygons in this cluster.
  • A separate cluster for the lower teeth.

Initialize the Shapekeys

On each animation cluster, initialize the shapekeys for frames 0 through 35.

A quick way to do this is to run ValveSource> Shape Tools > Init Shape Keys on each animation cluster. Be sure the cluster is selected before running the script. This will create a keyshape copy of frame 0 on frames 1 through 40

Create Shapekeys

You'll need to create shapekeys for frames 1-34. For the complete list of keyshapes see the Character Facial Animation Shapekey Set page.

  • To create a new keyshape, translate, rotate, or scale points to 'sculpt' the keyshape, then make sure that you have the appropriate cluster selected before you hit Animate > Deform > Shape > Save Shape Key.
    • Since XSI 5.0, Save Shape Key has been renamed to Store and Apply Shape Key
    • Make sure that the Construction Mode is set to Shape Modeling Mode
  • To copy a shapekey to another frame number you can use the script ValveSource > Shape Tools > Copy Shape Keys.

Make sure to select the cluster with the corresponding shapekey, then run the script; you'll be prompted for the destination frame number.

You can blend a portion of one shapekey with another shapekey as follows:

  1. The first step is to select a cluster on the model and then hit ValveSource > Shape Tools > Blend Shape Keys > Set Cluster . This defines the cluster on which the shape key blending will occur. Points outside this cluster will never be changed.
  2. The second step is to make sure that proportional modeling is turned on, move to the frame that you want to blend from, then make a proportional selection of points in the cluster. This defines the source frame and the weight map for the blending.
  3. The third step is to move the key frame index (right click and drag in the timeline) to set the destination frame for the blending. You'll notice a green frame indicator on the destination frame, the red indicator on the source frame.
  4. Finally, hit ValveSource > Shape Tools > Blend Shape Keys > Blend Shape. This will update the shape key at the destination frame by blending the points between the two frames based on the weight map.

click to view

Import the Character Rig

You'll need to get a character rig. Use ValveSource > Characters > Biped Guide to set the size and position of your rig, then run ValveSource > Characters > Create Rig From Guide to create the rig.

You can also get a default male or female Valve rig with ValveSource > Helper Bone Tool > Default (Male/Female) Rig to load a Valve rig.

To add interpolator (helper) bones to your rig to help maintain better joint and limb deformations, you can use ValveSource > Helper Bone Tool > Import helper bones.

click to view

Envelope the Character Mesh to the Skeleton

Export a .smd File

The .smd file contains geometry, textures, envelope data and skeletal data.

To export a .smd file:

  1. Select your enveloped mesh and the entire ValveBiped branch.
  2. Open the SMD Export Options dialog from ValveSource> Export SMD....
  3. Select Model (.SMD) as your file type. Leave all Options checked, and click OK.
  4. Navigate to the appropriate directory and name for the exported .smd file and click OK.

Export a .VTA File.

The .VTA file contains facial animation data.

To export a .VTA file:

  1. Select your enveloped mesh and the entire ValveBiped branch.
  2. Open the SMD Export Options dialog from ValveSource> Export SMD....
  3. Select Vertex Animation (.VTA) as your file type, leave all Options checked, and hit OK.
  4. Navigate to the appropriate directory and name for the exported .VTA file and hit OK.

Set up Character Eye Data for the .qc File.

There are two ways to set up the character eye data:

  • Using the QCEyes applet: run QCEyes and the help screens/text will take you through the process.
  • Doing it by hand, as described in the Eye Position Setup tutorial.

click to view

Edit the .qc File

The .qc file is the script for compiling your character resources (geometry, textures, animations, etc.) into a run-time model (.MDL).

To compile a new .MDL, you’ll need to do the following:

  1. Update the eye/face data (see Set Up the Eyes).
  2. Update the names of the model (modelname_reference.smd) and animation files (modelname_expressions.VTA) to the same names you exported from XSI.
  3. Update the run-time model name (modelname.MDL) to what you want the model to be named.

Compile the run-time model with StudioMDL

See Compiling Models for information on using StudioMDL to compile your character.

If you wish to make further changes to your model, see Making Changes to Your Character Model.