Model Conversion Tool

From Multiverse

Jump to: navigation, search

For a step-by-step tutorial on using the Model Conversion Tool, see the Platform Tutorial.

Contents

Overview

Use the command-line Model Conversion Tool to convert a COLLADA model file (containing the composite mesh, and possibly skin weights and skeleton) to the Multiverse binary formats. Instead of using command-line you can use Moonshine Conversion Tool with Windows GUI.

The following diagram illustrates how Conversion Tool fits into the model pipeline process:

Image:Conversion1.jpg
The blue boxes indicate a single model export, or the export for a base mesh with skeleton for a single model with multitple animations. The Green boxes indicate the animations exported that are incorporated into the model exported skeleton/mesh base file.

Using Conversion Tool

To use the tool, you must first open a command shell window, either a Windows Command Prompt window or a Cygwin shell window. In both cases, to run the tool, you must change your working directory to tools_home\Multiverse Model Viewer (by default C:\Program Files\Multiverse Tools\Multiverse Model Viewer).

NOTE: Your working directory must be tools_home\Multiverse Model Viewer, by default c:\Program Files\Multiverse Tools\Multiverse Model Viewer. Currently, it is not sufficient to add that directory to your path.

In a Windows command prompt window:

cd c:\Program Files\Multiverse Tools\Multiverse Model Viewer
ConversionTool

In a Cygwin shell:

cd c:/Program Files/Multiverse Tools/Multiverse Model Viewer
./ConversionTool.exe

For consistency, this document will use the Windows syntax.

By default, the tool looks for the .dae file to convert and puts the resultant output files in the tools_home\Multiverse Model Viewer directory. To use different directories for input or output files, use the --src_dir and --dst_dir options.

Command line syntax

Conversion Tool's general command-line syntax is:

ConversionTool [--option [arguments...] ...] [collada-file.dae]

Where option is one of the options described in the table below, and arguments is one or more parameters, if applicable. You can use any number of options with Conversion Tool. The collada-file.dae option specifies a COLLADA file to convert.

See Command Line Syntax for a general description of command-line syntax notation.

Command line options

The following table describes the valid command options.

Option Description
--3ds Convert from a left-handed system (used by 3ds), where z is up to a right-handed system where y is up. This option does not take any arguments.
--animation name file Add the animation name in file, to the base animation file.
--args_file argsfile Use additional arguments from the specified file
--base_skeleton skeletonfile Read the base skeleton from skeletonfile.
--build_skeleton Build a skeleton. This option does not take any arguments.
--build_tangents Build tangents. This option does not take any arguments. This attempts to automatically generate the tangent information from the texture coordinates and normal information. This tangent information is required for shaders that use normal maps. This information should ideally come from the modeling tool, but in some cases, this is not available.
--dont_extract_collision_volumes Do not extract collision volumes. If this option is not specified, Conversion Tool extracts collision volumes from submeshes whose names begin with "mvcv_obb_", "mvcv_sphere_", "mvcv_obb_" or "mvcv_aabb".
--dst_dir directory Specify target directory to which to write output.
--extract_kmz_textures Extract and conform texture files from .kmz (SketchUp) source.
--lod_distance distance Sets the distance in millimeters between each level of detail. Use with lod_levels and lod_percent options.
--lod_levels levels Generate levels levels of detail. Use with lod_distance and lod_percent options.
--lod_percent portion Sets each level of detail remove portion percent of the previous level of detail. Use with lod_levels and lod_distance options.
--log_collision_volumes Log the collision volume extraction process in the file ExtractLog.txt.
--log_file logfile Log messages to the specified file.
--manual_lod distance meshfile Specify manual levels of detail, using meshfile at distance.
--optimize_mesh Optimizes submeshes to remove unused vertices.
--out_skeleton outputfile Build the new skeleton into the file.
--src_dir directory Specify source directory from which to read meshes.
--socket name parent transform Add an attachment point with the name to the parent bone parent, using the matrix represented by 16-float transform.
--test_physics Run a self-test of physics serializer code. This option does not take any arguments.
--throw Throw an exception on any fatal error
--transform arguments Apply a transformation consisting of 16 floating-point arguments (a 4x4 transform matrix). The model is transformed by this matrix before being output.
--version Display version number.

Note: Model Conversion Tool does not currently export materials. See Creating Material Scripts for information on how to create materials files manually.

Examples

This command converts a COLLADA file myModel.dae exported from 3ds Max to Multiverse format:

ConversionTool --3ds myModel.dae

This example creates the following files:

  • myModel.mesh
  • myModel.material
  • myModel.skeleton (if the model has skeleton data)
  • myModel.physics (if the model has collision volumes)

This example incorporates the animations from the animation files human_male_run.dae (containing "run" animation) and human_male_walk.dae (containing "walk" animation) into the human_male.skeleton file:

ConversionTool --3ds --base_skeleton human_male.skeleton
               --animation run human_male_run.dae
               --animation walk human_male_walk.dae
               --out_skeleton human_male.skeleton

Common tasks

You can convert both static and animated models with conversion tool. The process is slightly different for each type of model.

Exporting a static model

To export a static model such as a building without a skeleton:

  1. In a command shell, change your working directory to the Multiverse Model Viewer directory. Use the cd command to change the working directory.
  2. Enter the command to convert a COLLADA .dae file to the files used by the engine. The files that are created are:
    • A .mesh file - contains information on the mesh and static atachment nodes.
    • A .material file - this file is a prototype you will need to edit.
    • A .physics file - if you specified collision volumes for the model.
  3. The command for this (from 3ds max) is:
     ConversionTool --3ds model_name.dae
    

    Note: If you didn't create the model in 3ds Max or Google 3D Warehouse, you can drop the --3ds option. If your model comes out on its back, adding/removing this flag will generally fix it.

  4. Import the model into your local asset repository, and view the model with Model Viewer.

Exporting an animated model

To export an animated model for a mob or PC:

  1. In a command shell, change your working directory to the Multiverse Model Viewer directory. Use the cd command to change the working directory.
  2. Enter the command to convert a COLLADA .dae file to a mesh file, and export any skeleton and skin data to a skeleton file.
  3. For animated models, incorporate animations from the animation files into the skeleton file. Use this command:
     ConversionTool --base_skeleton modelFile.skeleton
                    --animation anim1 animFile1.dae
                    --animation anim2 animFile2.dae
                    --out_skeleton model.skeleton
    

    Where file animFile1.dae contains animation anim1, and animFile2.dae contains anim2, and so on.

  4. Copy the .mesh and .skeleton files into the Multiverse Tools MyMedia directory, and view the model with Model Viewer.

Note: The animation in the original model file used to export the skeleton is named base; you cannot replace it with another one from one of the animation files.

Setting level of detail

There are two ways to specify levels of detail (LOD), so that a model is displayed with a lower number of polygons at farther distances from the camera:

  • Manually, creating distinct models for each level. Use the manual_lod option for this method.
  • Automatically, using one model, specifying a percentage decrease in polygon count at specified intervals. Use the lod_levels option for this method. This method will generally not be as high quality as the manual method, but will not require any additional artwork.

To use the manual method, use the manual_lod option and specify a mesh to use at various distances. For example, the following command modifies the model_highpoly.mesh model to use the highpoly mesh until the camera is at 10 meters, then switch to model_mediumpoly.mesh<code> until 20 meters, then use <code>model_lowpoly.mesh beyond that.

ConversionTool --manual_lod 10000 model_mediumpoly.mesh 
               --manual_lod 20000 model_lowpoly.mesh
               model_highpoly.mesh

To use the automatic method, use the lod_levels option and specify the number of levels of detail, the interval to change level, and the percentage decrease in polygon count at each level. For example, the following command generates three additional levels of detail automatically, switching between levels every 10 meters until reaching the lowest level of detail, and removing 80 percent of the polygons at each level.

ConversionTool --lod_levels 3 --lod_distance 10000 --lod_percent 80 model_highpoly.mesh

Clarification: When incorporating separate mesh files for LOD usage, if those mesh files use seperate skeletons in their animation process then the .mesh files that are incorporated into the the final mesh file must already be combined with their seperate sets of animations. If however the low res versions use the same skeleton as the high res version then the the meshes being incorporated can be simple mesh exports without animations and this process will use the high res base skeleton on these meshes along with the current set of animations being incorporated; thus keeping the file size smaller.

Converting Google Sketchup Models

Google SketchUp is an easy-to-learn 3D modeling program suitable for creating static models that is free for personal use. The SketchUp 3D warehouse lets you search, share, and store 3D models. Because SketchUp exports models into a COLLADA-compatible format, with the Model Conversion Tool you can convert SketchUp models directly into Multiverse format.

Use the latest version of SketchUp (version 6.0.515 or later), since it has several bug fixes and produces better-optimized material and mesh exports.

To convert a model from SketchUp to Multiverse format:

  1. Export the model to Google Earth KMZ format. Choose File | Export | 3D Model and choose Export Type "Google Earth 4 (*.kmz)." Most of the models in the 3D Warehouse are available in .kmz format.
  2. Run ConversionTool.exe on the .kmz file using the following command:
    ConversionTool fileName.kmz
    

    NOTE: You may find it easier to use the COLLADA Import Tool instead of the command-line conversion tool. This creates a .mesh file and a new .material file, and extracts the textures into a kmz_textures folder. Each component instance becomes a separate sub-mesh in the .mesh file.

  3. Use the Asset Importer tool to import the model into your asset repository. See Creating asset definition files with Asset Importer for instructions.
  4. Start Model Viewer, choose File | Load Model, browse to the mesh file and select it.

The new release of Conversion Tool has improvements with SketchUp integration. Conversion Tool now exports a .material file that is directly usable with no hand-edits required. However, Conversion Tool creates two material definitions for each material in the SketchUp export (one using the name of the material in the library, and another using the name that is used by the geometry to reference it). This is a known issue and will be resolved in the future.

Conversion Tool extracts any texture images bundled in the .kmz file to the kmz_textures subdirectory of the destination directory, ready for importing into a Multiverse asset library. It will create the sub-directory if needed. Most importantly, because of Multiverse runtime requirements, it reshapes extracted images to dimensions that are the nearest lower power of two, if they are not already powers of two.

You can use the generated .mesh, .material, and extracted textures directly with Multiverse tools and the Multiverse Clients.

Personal tools