Platform Tutorial Importing Animated Models

From Multiverse

Jump to: navigation, search


Prerequisite: To follow this section, you must have Autodesk 3ds Max 7 with service pack 1 or 3ds Max 8 with service pack 2.
To use the proper format of images you will also need Adobe photoshop with the Nvidia DDS export plugin.

Contents

Create Animated Model in 3ds Max

Create or load the model

When you open the model with 3ds, make sure it is to scale. Set world units to centimeters before import and use a model that you know is to scale. Also, you can always check it with the measure tool. To avoid problems later on, make sure it's the right size initially.

If you use Maya and bring it across with an .obj format there are issues with reversed normals in the export process: see Troubleshooting.


Image:Create_model.jpg

Check the model for errors

To make sure there won't be issues with the normals in your finished product, check the mesh for errors. To do this, add an STL modifier to the stack. Then check the mesh and delete the modifier when you're satisfied the mesh is correct.

Add an STL Check modifier, as shown here:

Image:STL_modifier_add.jpg

Check for double faces (coplanar faces) and double edges, as shown here:


Image:STL_checking_errors.jpg

Here is an example of multiple edges (coincidental edges)

Image:DoubleEdges_Example.jpg

Here is an example of doublefaces.
Image:DoubleFaces_example.jpg
If your model is open, then the open edges are to be expected. If it is supposed to be closed, then they are wrong.

Delete the modifier out of the stack when you are finished checking the model.

Combine dependent submeshes

A good final export requires that the model is either a single mesh or that if submeshes exist, they must be attached at the root(base) mesh layer before any skinnning goes on. If this does not happen, then the submeshes recieve a double transfom that leads to an improper export. See Troubleshooting.

If you have submeshes to combine or attach, make sure they are editable mesh objects. To do this, right click the object in the modifier stack to get this menu:

Image:Convert_to_editable_mesh.jpg

To attach a submesh to the main mesh at the root mesh modifier level follow these steps:

  1. Select the parent object.
  2. Click Attach in the Edit Geometry rollout for that object.

  3. Image:Attach_submesh.jpg

  4. Select the object to attach.

UV map the model

Explaining how to lay out the UVs using the uv unwrap modifier is beyong the scope of this tutorial. See any good book on 3ds for more information.

After you lay out the UV map, collapse the UVW modifier into the stack. If you don't, there will be export issues.

Assign materials to the model

To assign materials to the model, follow these steps:

  1. Check the materials to make sure that they are DDS format. You can save the .dds format in Photoshop using the Nvidia plugin.
  2. Open the 3ds material editor.
  3. Assign the .dds format image you've created to the diffuse map setting. Make sure it refers to the right file and the file is a .dds file:

    Image:material_editor_map_check.jpg

  4. Check the specularity.
  5. In the material editor, make sure the specularity color is set properly. White should look shiny and black dull. Characters and buildings tend to be almost black, for example:

    Image:Material_editor_specular.jpg

    NOTE: if this is not set properly, then the model will appear shiny and washed out in Model Viewer when using the default material file export.

Rigging the model

Use biped or create a skeletal structure and rig your model.
Again another reason to have a good book on 3dsMax.

Keep the following in mind when doing the skeletal system (rigging/skinning):

  • There is a 64-count bone limit. If you don't include the 'nub' bones in any of the skinning 'add bones' processes and hide them before exporting then they don't count toward you're total.
  • When skinning any object into the skeletal system, all active bones (with the above acception) must be added into the skinning process including the root node.(Bip01)
  • If you have two skeletal structures in the same animation both Root Node Bones(Bip01, etc) must be perented under a common bone that acts as the new root node for both hierarchies. If this isn't done one of the bone systems will get dropped in the export process.


Image:AddingBones.jpg

Setting up attachment sockets

Define attachment sockets on a model to enable it to wield handheld items such as weapons. You can also use attachment points for targeting and to attach particle effects to a model. An attachment socket maintains orientation with the bone to which it is parented, and its orientation determines out/up etc. for the socket. (Beware: The pivot orientation is ignored, so the attachement null box must be oriented for the orientation to come through properly.)

Naming sockets

By convention, socket names must have the prefix "mvsock_". The following table describes the common set of sockets.


Name Location
mvsock_primaryWeapon Center of right hand grasp point,attached to right hand, oriented north polar of fist with thumb up.
mvsock_secondaryWeapon Center of left hand grasp point,attached to left hand, oriented north polar of fist with thumb up.
mvsock_primaryWeapon_reversed center of right hand grasp point,attached to right hand, oriented south polar of fist with thumb up.
mvsock_secondaryWeapon_reversed Center of left hand grasp point,attached to left hand, oriented south polar of fist with thumb up.
mvsock_shield Center of left forearm outward from back of hand when pronated, attached to lower arm, oriented in parallel to thumb in pronated position.
mvsock_name Six inches above head , attached to root, oriented north polar of head.
mvsock_icon When standing above head about a relative foot, attached to root node (bip01), always oriented vertical up.
mvsock_questavailable When standing above head about a relative foot, attached to root node (bip01), always oriented vertical up.
mvsock_head Center of head, attached to head, oriented with head.
mvsock_back Between shoulder blades, attached to top spine, oriented with top spine bone.
mvsock_chest Center of chest, attached to top spine,oriented with top spine bone.
mvsock_base Base of character, not attached. Defaults to 0, 0, 0. Note: There is no attachment for mvsock_base to the skeleton and the socket defaults to 0,0,0 local which is at the base.
mvsock_waistR Right hip, attached to pelvis, oriented with pelvis.
mvsock_waistL Left hip, attached to pelvis, oriented with pelvis.
mvsock_footR Center of Right foot, attached to left foot, oriented up the leg.
mvsock_footL Center of Left foot, attached to left foot, oriented up the leg
mvsock_eyeL Left eye, attached to head, facing forward.
mvsock_eyeR Right eye, attached to head, facing forward.
mvsock_nose Base of nose/nostrils, attached to head, oriented down and forward.
mvsock_earR Center of earlobe right, attached to head, oriented outward to side of head.
mvsock_earL Center of earlobe left, attached to head, oriented outward to side of head.
mvsock_mouth Center of lips, attached to head, oriented forward.
mvsock_shoulderR Slightly above shoulder, attached to clavicle, oriented upwards.
mvsock_shoulderL Slightly above shoulder, attached to clavicle, oriented upwards.
mvsock_tail At tailbone, attached to pelvis, oriented towards back.
mvsock_groin At groin, attached to pelvis, oriented forward.


The following image illustrates socket location on a canonical figure (front view):

Image:Sockets_front.jpg

The following image illustrates socket location on a canonical figure (side view):

Image:Sockets_side.jpg


Creating the sockets

Follow this process in 3ds Max to add attachment points to a model:

  1. Activate Creation Tab.
  2. Goto the helpers subset.
  3. Select and create a dummy object.
  4. Position the dummy object where your would like it to exist in relationship to your character:

    Image:Sockets_creation.jpg

  5. Rotate the dummy object so the local y-axis is pointing in the direction you want the particle or item to consider up. The x_axis then represents the direction that blades or guns would point(out). Side to side is then the z-axis. (Note: to better see the effects of your rotations on the attachment-socket dummy's axis, go to the hierarchy tab and click "Affect Pivot Only," as shown below. Be sure to click it again afterwards to turn it back off.)

    Image:Sockets_orientation_02.jpg

    Image:Sockets_orientation_01.jpg

Name the socket

Rename the node to the Multiverse convention: preceed the unique name of the attachment point with "mvsock_", for example, mvsock_name.

Image:Sockets_name_01.jpg to Image:Sockets_name.jpg


This type of node attached to a skeletal structure is a dynamic node that is exported eventually into the skeleton file,

Attach the sockets to the skeleton

Normally every socket will be attached to the characters skeleton except for the mvsock_base which isn't attached so that it will always default to the center of the character at ground level.

To do this, access the schematic view in 3DS:

Image:Sockets_menu_schematic.jpg

Under the nested tree view of nodes the sockets will appear green while the biped bones appear blue.

Image:Sockets_view_schematic.jpg

Turning on the connect tool in the schematic view, drag fron the Socket node to the bone node under which you want it to be parented.

Image:Sockets_schematic_connect.jpg

You might need to reposition the socket nodes, but after dragging and dropping you should see a tree that looks like the above figure.

Create the animations for your character

Here is another place where having a good book on 3ds is essential. For best results, do animations at 30 frames per second (FPS). If doing them in biped, save them out to a bip file as well so you can interchange them later on.

Create an animation of you character that is just the bind pose. Use this animation as the base animation (the file that is converted into the first st of files including the skeleton file.) Do this so the weighting data of the skin comes across uniformly into all of the animations that get folded into the file after this point.

Export an animated model from 3ds Max

Next, you will use the COLLADA exporter to create a .dae file for each animation.

If you are using 3ds Max 9, use the internal fbx/dae file export. Select FBX export and in the export dialog name the export with the .dae extension and the tool will export .dae in the proper format.

With one animation, export using the Single Animation option.

NOTE: The first animation you must create should be created from the bind pose of the character: frame zero and frame one should be duplicate keys containing the information of transform and rotations on the model. This animation should be used in the first .dae file exported that is used to convert into the skeleton file.

The animation's sample rate will depend on how well COLLADA is able to extract the animation information. For example, if you have an animation that is 30 FPS, and there are motion artifacts in the final file, reduce the frame rate in the Max file until the motion artifacts are eliminated. For example, reduce the frame rate from 15 to 10, then to 5. DON'T save this frame rate information back into your file.

This is fixed in version 1.0.

To export to COLLADA format, choose File | Export. Select the COLLADA plugin and destintation.

Image:Export_animation_01.jpg

Here's an example of the settings:

Image:Export_animation_02.jpg


You will end up with a collection of files, one for each animation.

Also export a file with the name you want the asset to have while being used by the engine. This is the file into which all the other animations will be combined. The animation in this file will be placed in the final file as the 'base' animation. You can use any animation in this file, but the idle animation is usually a good choice.

The final files you end up with are:

  • biosuit_male.dae: The base export from which you will pull the skeleton and to which you will add the animations.
  • biosuit_low_g_run_5s.dae
  • biosuit_low_g_walk_5s.dae
  • biosuit_idle_5s.dae
  • biosuit_death_5s.dae
  • biosuit_laugh_5s.dae
  • biosuit_wave_5s.dae

See also Tips on exporting animated models from 3ds Max.

Convert animated model using Conversion Tool

Gather all Your .DAE files having to do with the asset to be converted into an animated model in the engine and place them in the conversion tool directory (by default C:\Program Files\Multiverse Tools\Model Viewer).

Convert the Base Model by itself to extract the skeletal information required by the next step in the process.

The command-line Multiverse Conversion Tool converts COLLADA (.dae) files to the Multiverse binary formats. In this section, you will create a Windows batch file to run Conversion Tool. You can also simply type the commands from a command prompt, but this technique is handy when you want to convert multiple files.

  1. In Windows Explorer, browse to C:\Program Files\Multiverse Tools\Model Viewer. This is the directory that contains the Conversion Tool executable. You are going to create a batch file in this directory so you can run the ConversionTool command without specifying the path to the executable.
  2. Create a new text file. Right-click and choose New | Text Document.
  3. Rename the file to convert_biosuit_male.bat. You can put multiple commands in one batch file, so you can convert many files at the same time. For now, though, you're only going to add one command.
  4. Right-click on the file, and choose Edit from the pop-up menu. Notepad will open.
  5. Add the following text to the file:
    ConversionTool --3ds biosuit_male.dae
    

    Since you have the files in the same directory as the conversion tool itself you can leave out the source and destination command line parameters (not shown). This command runs Conversion Tool on the .dae file.

  6. Double-click on the newly created batch (convert_biosuit_male.bat) file in Windows to run it.
  7. Conversion Tool will create the following files in the Multiverse Tools\MyMedia directory: *biosuit_male.material *biosuit_male.mesh *biosuit_male_skeleton *biosuit_male.physics - (if you have a collision volume capsule difined in the file)

Add animations to the base file

To add the animations to the base file, follow these steps:

  1. In Windows Explorer, browse to C:\Program Files\Multiverse Tools\Model Viewer. This is the directory that contains the Conversion Tool executable.
  2. Create a new text file. Right-click and choose New | Text Document.
  3. Rename the file to convert_biosuit_male_animations.bat.
  4. Right-click on the file, and choose Edit from the pop-up menu. Notepad will open.
  5. Add the following text to the file:
    ConversionTool.exe --3ds
    --base_skeleton biosuit_male.skeleton
    
    --animation run biosuit_low_g_run_5s.dae
    --animation walk biosuit_low_g_walk_5s.dae
    --animation idle biosuit_idle_5s.dae
    --animation death biosuit_death_5s.dae
    --animation laugh biosuit_laugh_5s.dae
    --animation wave biosuit_wave_5s.dae
    
    --out_skeleton biosuit_male.skeleton
    

    This all goes on one line, but is shown on multiple lines for readability.

    This command runs Conversion Tool on the .dae files. It loads up the skeleton out of the biosuit_male.dae and uses it to process the tha animations that are loaded in. It then loads in the specified animations combines them and outputs them into the biosuit_male.skeleton file.

  6. Double-click on the newly created batch (convert_biosuit_male_animations.bat) file in Windows to run it.
  7. This will overwrite the biosuit_male.skeleton file in the Multiverse Tools\MyMedia directory.

Edit material files

For information on how to edit the material files, see Editing Material Files.

Create and edit the physics file

The character you've exported needs a .physics file or else it won't interact with the terrain or objects with collision volumes in your world. Generally, you will create collision volumes in the original max file before exporting.

To create the physics file, follow these steps:

  1. Create an mvcv_capsule_ file. You can copy a current file from another character, paste it and rename it to match your file. For example the Zombie.physics file:
     <physics_model>
      <rigid_body sid="Zombie_Body2-obj.0">
        <technique_common>
          <shape>
            <translate>0 .9 0</translate>
            <capsule>
              <height>1.3</height>
              <radius>0.25 0.25</radius>
            </capsule>
          </shape>
        </technique_common>
      </rigid_body>
     </physics_model>
    


    Image:Collision_Volume_Explain.jpg

    In this file:

    • rigid_body sid - is the Shape ID - the name of the submesh in the final export of the mesh file.
    • Translate - is the position of the center of the capsule in relationship to the ground directly under the character.
    • Height - is the height of the cylinder that makes up the central portion of the capsule.
    • Radius - is the radius of the half-spheres that make up the end-caps of the capsule.
  2. Make sure the sid is named to the proper submesh as shown in the model viewer.
  3. Adjust the perameters as neccesary for your character.
  4. Rename the file to match your mesh file name.

View with Model Viewer

TBD JH

Troubleshooting

Here are some common issues you may encounter, and their solutions or workarounds. All of these have been reproduced internally at Multiverse.

Reversed normals

The normals of the exported object appear to be backwards in that the light hitting the object seems to be coming from 180 degrees out. For example:

Image:issue_reverrsed_normals_01.jpg

Image:issue_reversed_normals_02.jpg

This occurs for example when you import into 3ds an .obj file that was originally created in Maya.

We are still working on a viable general solution for this issue. The current solutions are:

  • Don’t open an .obj file in 3ds that was originally created in a different program.
  • Try playing with the import options to not import smoothing groups and normals

Random-facing normals

The normals of an exported object appear to face in all sorts of random directions. For example:

Image:Issue_random_facing_normals.jpg

This is caused by problems in the mesh, specifically coplanar faces and double edges. To address this:

  • Make sure the mesh doesn’t have any of these.
  • Close off the meshes/submeshes, making them more efficient for the engine to process. I haven’t run into issues with open geometry but closed is for the most part faster and less work for the engine, so it’s a good idea unless you have a specific reason.

Submeshes offset translation with broken animation

Submeshes appear to be out of place and the animation is weird. For example:

Image:Issue_offset_translation.jpg

This is caused by the improper attachment of submeshes in the 3ds max file. It looks that what is happening is a double transform issue where transforms are duplicating on certain submeshes.

To address this:

  • Combine or attach the submeshes at the root mesh modifier level, before applying the skinning modifier to the stack.
  • Complete the uvw unwrap (uv editing) modifiers and collapse them into the base mesh modifier before skinning.
  • When exporting, make sure there is only be the base mesh modifier and the skin modifier in the stack. Do not collapse the skin modifier into the base mesh.


Personal tools