Platform Tutorial Importing Static Models

From Multiverse

Jump to: navigation, search


Contents

Overview

This section of the tutorial leads you through the process of importing 3D assets from 3ds Max to the Multiverse platform. Although you can create assets with other 3D modeling tools, such as Maya, this tutorial focuses on 3ds Max.

NOTE: Multiverse includes a set of free predefined assets that you can use in your world. If you are not immediately interested in learning how to import custom assets, you can skip this section and go directly to Defining Mobs.

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. [1].

In general, importing 3D models to the Multiverse Platform involves the following steps:

  1. Install the COLLADA exporter plugin for your 3D modeling tool (you only have to do this step once).
  2. Export the model from the tool to COLLADA data exchange format (.dae file).
  3. Use the Multiverse Conversion Tool to convert the .dae file to Multiverse format.
  4. Use Multiverse Model Viewer to confirm that the model looks good.
  5. Add .materials and .physics files.

Multiverse asset files

At a minimum, a Multiverse 3D asset consists of the following set of related files:

  • .mesh file: binary file that defines the geometry of the model and refers to the model's .material and .skeleton files.
  • .material file: text file that specifies attributes of the model's appearance, such as lighting and texturing. The .material file refers to one or more texture files.
  • texture file: binary image file that provides the appearance of polygons in the model.

Additionally, an animated model has a .skeleton file, a binary file that specifies the model's bones, bone hierarchy, and the animations expressed in terms of the bones.

A model can optionally have other related files, such as a .physics file that defines collision volumes.

Download and install COLLADA exporter plugin

Before proceeding, you must install the COLLADA exporter plugin for 3ds Max. Of course, if you are using another 3D modeling tool, then install the plugin for that tool (but then you won't be able to follow along with this tutorial). See Exporting Models for more information.

Follow the instructions in Installing the COLLADA 3ds Plugin to download and install the COLLADA exporter.

Download tutorial files

If you haven't already done so, download the tutorial files from the Platform Tutorial File Package. Save the zip files to your computer, create a tutorial files directory, and then extract the files into that directory. You can call the directory whatever you like, but the tutorial will refer to it as c:\MVTutorial. Create a sub-directory called MyFiles to contain the files you create.

The files in the package include the 3ds Max file used in this section, and files resulting from intermediate steps in the tutorial. As you follow the tutorial, you can compare your results with the files in the package, or if you want to skip some steps, you can use the files to pick up where you want to start folllowing the tutorial again.

Add collision volumes

When you create a model with a modeling tool such as 3ds Max, you can associate one or more collision volumes with each submesh. A collision volume (CV) defines how a model physically interacts with other models in the world. The Multiverse physics system prohibits the collision volumes from overlapping in space, so models models with collision volumes cannot move through each other. The collision volumes associated with a single model cannot overlap.

The procedure for defining collision volumes for mobs and static objects, like buildings, is the same. The end result of creating collision volumes is a .physics file, in COLLADA physics format.

See Creating Collision Volumes for more information.

CV shapes

There are four shapes of collision volumes:

  • Oriented Bounding Box - mvcv_obb_name_uniqueID: The most common collision volume for environmental assets is the oriented bounding box. Oriented bounding boxes can be rectangular and square but all corners must maintain a 90 degree angle. There can be no trapezoidal or custom shapes. The boxes can be rotated along any axis and along multiple axes as long as you don’t mess with the angles on the corners of the boxes.
  • Axis Aligned Bounding Box - mvcv_aabb_name_uniqueID: Axis aligned bounding boxes always retain orientation of their local axis with the world axis and thus can never be rotated. This is not a good volume to use for environmantal assets since the model that is associated with it cannot be turned in any way when placed in the world. Note: the client drops the flag on this type of volume and consequently turns it into an obb anyway, so this type of volume essentially is obsolete and is retained for backwards compatibility only
  • Sphere - mvcv_sphere_name_uniqueID: The sphere is the least expensive volume to use but is the least usable so use where you can of if complete collision boundry representation on the object isn't that important.
  • Capsule - mvcv_capsule_name_uniqueID: Second least expensive volume in testing, capsules are used for the collision volume on characters tree bases and other similar forms the central height can be compressed as long as the ends remain perfect half spheres, otherwise they must be uniformly scaled for fitting purposes.

Naming conventions

The naming convention for collision volumes is:

mvcv_shape_submesh-name_uniqueID

Where

  • shape is the abbreviation for the CV shape: obb, aabb, sphere, or capsule.
  • submesh-name is the name of the submesh. If you have more then say one mesh in a file like a house with a porch then the collision volumes for the porch should be associated with that mesh so if it is turned off in the world then the collision volumes for it go away as well.
  • uniqueID: you can use anything here as long as it is unique. One scheme would be to use this identifier to associate a name of the volume with the piece it represents such as the floor. eg: mvcv_obb_human_wishbone_houseShape_floor. It's just easier and faster to use a number especially if you have to rename a bunch of volumes.

NOTE: Be sure to pay attention to upper/lowercase, since the names are case-sensitive!

For example:

mvcv_obb_human_wishbone_houseshape_01
mvcv_obb_human_wishbone_houseshape_02

Where "mvcv" stands for "multiverse collision volume" and "obb" stands for "oriented bounding box."

Process with 3ds Max

To create collision volumes for a building, define the smallest possible set of CVs (usually obbs) that matches the shape of the building. Collision volume interaction consumes CPU cycles, so minimizing the number of CVs will improve performance.

In the 3D modeling tool (3ds or Maya), collision volumes start out as meshes. After you export the model to COLLADA and then convert to Multiverse format, they become .physics files.

For this section, you will be using two files: tutorial_shack.max and tutorial_material.dds.

In 3ds Max, follow these steps to create collision volumes:

  1. Load the model into 3ds Max. It will look like this:

    Image:max_load_model_in.jpg

  2. Check the materials to make sure that they are dds format. Open the 3ds material editor:

    Image:material_editor_open.jpg

  3. Check 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. 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 really close to 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.
  5. Create a cube (a box). In the 3ds Max Create Panel, select box. Then resize it and shape it to fit a portion of the current structure like the floor. For example:

    Image:collision_volume_floor.jpg

    To avoid a non-uniform scale issue, use the Scale and Rotate tool and Transform tool in local mode and using selection center. You must set these for each tool, as illustratd here:

    Image:collision_volumes_transform_setup.jpg

    Avoid this:

    Image:collision_volumes_bad_transform.jpg

    Repeat this process until you have associated CVs with all the important surfaces. For example:

    Image:collision volumes_all_placed.jpg

  6. Name the collision volumes. Be sure to:
    • Give each collision volume a unique identifier.
    • Name each collision volume with its associated submesh, so that the collision volumes are turned off in the world when that submesh is turned off.
    You name CVs in the Modify panel:

    Image:collision_volumes_modify_panel.jpg

    There are two submeshes in this file: One is the building itself (tutorial_shack--not to be confused with the file name) and the other is the fireplace (tutorial_chimney). The names of the collision volumes for the fireplace and chimney should associated with the tutorial_chimney and tutorial_fireplace submeshes. So, for example, for the chimney, the CV name should start with mvcv_obb_tutorial_chimney_ and end with a unique identifier like 001 to give mvcv_obb_tutorial_chimney_001, as shown here:

    Image:collision_volumes_chimney_name.jpg

    Similarly, associate the names of the shack CVs with the shack itself.

    Image:collision_volumes_shack_name.jpg

  7. Export the model and load the .mesh into the model viewer. Exporting from .dae file to the mesh and related files strips the collision volumes information out and places the information in a .physics file. If you are not getting a physics file, then you probably need to update tools or something has gone wrong in your export process. The collision volumes should not be visible in Model Viewer. You should go back and double-check your collision volume names. If you get a physics file and no volumes show up in the model viewer then you are good to go! So go have fun running around in your building.

Special considerations with Maya

If you are using Maya instead of 3ds Max, there are some special issues. See Creating Collision Volumes with Maya.

Add attachment points (Sockets)

Attachment points or sockets are places on a model where you can attach another model or a particle effect. For example, on an animated model (mob), you might create an attachment point on the right hand for a sword. On a building model, you might create an attachment point at the top of the chimney for smoke.

Follow this process in 3ds Max to add attachment points to a static 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 building, as illustrated here:

    Image:sockets_create.jpg

  5. Rotate the dummy object so the local z-axis is pointing in the direction you want the particle or item to consider up or out. Note: to see the effects of your rotations on this 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_check_pivot.jpg

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

This type of node (not attached to a skeletal structure) is a static node that is exported eventually into the mesh file, so no extra files are created.

The section on exporting animated models will describe creating sockets for animated models.

Export a static model from 3ds Max

Follow these steps:

  1. In 3ds Max, open the model file tutorial_shack.max. This model has collision volumes and static attachment sockets for particle effects.

    The figure below illustrates how the model looks in 3ds Max. The image also shows the selection picker so you can check your naming conventions for these items.

    Alt Shack in 3ds max with Outliner showing name information

    NOTE: The COLLADA exporter will not export anything that is hidden in 3ds. This also goes for biped or bone objects. So make sure that everything you want exported is visible.
  2. In 3ds Max, choose File | Export.
  3. In the dialog box, enter the following information:
    • Save in: Directory path to save the model. Browse to C:\MVTutorial\MyFiles. Note: As mentioned previously, this is just the suggested path; it can be any directory of your choosing.
    • File Name: File name of the .dae file. Enter "tutorial_shack".
    • Save as type: Choose COLLADA (*.DAE). If you do not see this choice, then you need to install the COLLADA exporter plugin (see above).
  4. Click the Save button.
  5. The COLLADA dialog box appears. Fill out this dialog box as shown below:

    Collada Dialog Box

    Specifically, set:
    • Standard Options: Bake Matrices - checked (on), Relative Paths - checked (on).
    • Geometry: Normals - checked (on), Triangles - checked (on, the default), xRefs - checked (on).
    • Animation: Sample animation - unchecked (off). This is is for exporting a partial animation defined by start and end. Single <animation> - checked (on). This is for exporting a static world object such as a building.
    • Experimental: Y Up - unchecked (off), Mixed FX - unchecked (off), Tangents/Binormals - checked (on).
  6. Click OK.
  7. The exporter plugin will save the .dae file in the directory you specified.

Convert a static model with conversion tool

The Multiverse Model Conversion Tool converts COLLADA (.dae) files to the Multiverse binary formats. Conversion Tool is a command-line tool. 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_tutorial_shack.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 --src_dir "c:\\MVTutorial\\MyFiles" --dst_dir "c:\\MVTutorial\\MyFiles" tutorial_shack.DAE
    

    This command runs Conversion Tool on the .dae file you created previously in your tutorial directory and outputs files into the same directory. Note: If you saved the COLLADA file in a different directory, specify that directory as the source directory (argument to --src_dir). Likewise, to save the files in a different directory, specify it as the destination directory (argument to --dst_dir).

  6. Open a DOS Command Prompt Window (not a Cygwin command shell), and enter the following command to change the current working directory to and then run the batch file:
    cd "C:\Program Files\Multiverse Tools\Multiverse Model Viewer"
    convert_tutorial_shack.bat
    

    The Command Prompt window will display some text, and another window will briefly appear.

    Note: You can also run a batch file by double-clicking on the file in Windows Explorer, but it is easier to diagnose any errors you encounter by using a Command Prompt window, because the window will remain open rather than automatically closing.
  7. Conversion Tool will create the following files in the destination directory (c:\MVTutorial\MyFiles if you used the exact command line above):
    • tutorial_shack.material
    • tutorial_shack.mesh
    • tutorial_shack.physics

Now you are done with the import process and you can use Model Viewer to see how your model turned out.

For more information on using Model Conversion Tool, see Model Conversion Tool.

Personal tools