Menu

Maya2OSG_User_Manual

Javier Taibo
Attachments
Maya2osg_cleanup.jpg (983 bytes)
Maya2osg_export.jpg (1224 bytes)
Maya2osg_import.jpg (1180 bytes)
Maya2osg_preview.jpg (1059 bytes)
Maya2osg_unload.jpg (1279 bytes)
Polygons_cleanup.png (28684 bytes)

Introduction

There are several ways of using Maya2OSG. The most quick, easy and user-friendly is through the Shelf Buttons, described in the next section. These buttons rely on some MEL Scripts that can also be used from user code. These MEL scripts are described in a later section.

Scripts (and so shelf buttons) call the two commands created by Maya2OSG plug-in (

maya2osg

and

osg2maya

).

The interface of these commands is described in the last sections of this page.

There is no need to load Maya2OSG plug-in prior to use the buttons or the MEL scripts. It is automatically loaded when needed.

The Maya2OSG plug-in, when loaded, also provides a FileTranslator that make OSG file formats available when exporting/importing contents inside Maya.

Shelf buttons

Export to OSG (quick export)

Pressing this button will open a file explorer to select the destination file to export the scene to. After choosing the destination file name and location, selected elements will be exported to this file. If there are no selected elements, all the contents of the scene will be exported. Display layers are ignored by the exporter, contents of every layer will be considered when exporting the whole scene (i.e. when exporting with no selected elements).

This export button will not open the option box to select export configuration options. Instead, it will use the last options set (or default ones if none were set). More information about the configuration options in the exporter section of this page.

The executed command is

maya2osg_export(false)

Export to OSG (option box)

This export button differs from the previous one in that it opens first the option box where user can select the configuration options for the exporter (see section [Maya2OSG_User_Manual#Configuration]). Once the desired options are set, a file browser will open to select the destination file to export to.

After selecting the destination file name and location, selected elements will be exported to this file. If there are no selected elements, all the contents of the scene will be exported.

The executed command is

maya2osg_export(true)

Import OSG file

This button opens a file explorer to select the file to import. The selected file will be added to current scene.

The executed command is

maya2osg_import

Cleanup scene

This button execute a cleanup of the scene. It is recommended to do this operation before exporting to OSG, to remove potential problematic components that would export incorrectly.

WARNING: This cleanup operation is destructive. It is recommended to save the Maya scene before performing the cleanup.

The executed command is

maya2osg_cleanup

Preview

This button will export the selected elements in the scene (or the whole scene if there is no selection) to the temporary directory and then execute

osgviewer

to preview the exported scene in a window. WARNING:

osgviewer

executable file must be in the

PATH

, as well as OSG libraries.

NOTE: Check the [Scene_preview] page for more information about camera preview.

The executed command is

maya2osg_preview("")

Preview with axes

This button works as the Preview button, but adding a model of the scene coordinate system axes located in the origin. This is very useful to check the location of exported elements in world space.

WARNING: File

axes.osg

must be accessible in

OSG_FILE_PATH

.

The executed command is

maya2osg_preview("axes.osg")

Unload plug-in

This button unloads Maya2OSG plug-in. It is intended to be used during development of the plug-in, as a quick way to unload it before its recompilation.

Executed code is

unloadPlugin maya2osg

MEL Scripts

maya2osg_export

Parameter: config (bool)

This script opens a file browser to select the file to export the scene (or selected elements) to. After selecting this file it will perform the export operation.

If parameter

config

is true, prior to opening the file browser, the option box will be open to let the user select the export options. These options are described in section [Maya2OSG_User_Manual#Configuration].

maya2osg_import

This script opens a file browser to select the OSG file to import to the scene. After selecting this file it will perform the import operation.

maya2osg_cleanup

This script will perform the cleanup described in section [Maya2OSG_User_Manual#Scene_preprocessing].

WARNING: This operation can be destructive. It is recommended to save the Maya scene before doing the cleanup.

maya2osg_preview

Parameter: model (string)

This script exports the scene (or selected elements) to the temporary directory and then previsualize it in a window using

osgviewer

program. Models specified in the

model

parameter will be also previsualized. They must be specified as an absolute path, a relative path to the export directory or a directory in the

OSG_FILE_PATH

. WARNING: osgviewer must be available in the

PATH

to use this command.

Exporter (

maya2osg

)

Scene preprocessing

This is not part of the

maya2osg

command, but before exporting to OSG, the scene should be prepared to avoid potential problems. The recommended sequence of operations is described below:

  1. Convert non-polygonal geometry (e.g. NURBS) to polygons.
  2. Tessellate objects to eliminate potentially problematic geometry in OpenGL. In the
    Polygons
    

menu select

    Mesh > Cleanup...

. At least you should include the options to fix by tesselation concave faces, faces with holes and non-planar faces. It is also interesting to remove edges with (near) zero length, faces with (near) zero geometry area, and faces sharing all edges.

3. Delete construction history (

    Edit > Delete By Type > History

).
4. Optimize the scene deleting unnecesary elements (

    File > Optimize Scene Size

).
5. Delete static channels (

    Edit > Delete By Type > Static Channels

).
6. Select the elements you want to export. If there is no selection, all the scene will be exported.

Below is the MEL code to perform these operations (steps 2-5) for all the elements in the scene.

polyCleanupArgList 3 { "1","1","0","1","1","1","1","1","0","1e-005","0","1e-005","0","1e-005","0","-1","0" };
delete -all -constructionHistory;
cleanUpScene 1;
delete -all -staticChannels;

These operations (steps 2-5) are included in the

maya2osg_cleanup

command and available from the "Cleanup scene" shelf button.

Configuration

Maya2OSG exporter saves an internal configuration structure that is persistent along command calls.

When the plug-in is loaded, the configuration is initialized with default options. Changes in the configuration options are persistent until the plug-in is unloaded.

These configuration options are internal to the plug-in and currently they are not synchronized with the options that appear in the GUI configuration window (shelf button "Export scene (option box)"). GUI options will change the plug-in configuration, but when GUI config window opens it does not reflect the current options, but default ones.

TO-DO: Options description list

Command-line interface

The command-line interface syntax for

maya2osg

is shown below in a pseudo-BNF notation.

"maya2osg" <options> <output_file>

<options> ::= " " <option>
            | <options> " " <option>

<option> ::= "-texenv " <texenv_mode>
           | "-exportDefaultCameras " <bool>
           | "-exportOrthoCameras " <bool>
           | "-surfaceMode " <surface_mode>
           | "-texClampMode " <tex_clamp_mode>
           | "-YUp2ZUp " <bool>
           | "-exportAnim " <bool>
           | "-animSampleBy " <integer>
           | "-particlesEmissive " <bool>
           | "-particlesLighting " <bool>
           | "-computeShadows " <bool>
           | "-shadowTechnique " <shadow_technique>
           | "-globalAmbient " <color>
           | "-localViewer" <bool>
           | "-useGLSL" <bool>

<bool> ::= "0" | "1"

<color> ::= <float> <float> <float>

<texenv_mode> ::= "DECAL" | "MODULATE" | "BLEND" | "REPLACE" | "ADD"

<surface_mode> ::= "SINGLE" | "DOUBLE" | "KEEP"

<tex_clamp_mode> ::= "EDGE" | "COLOR"

<shadow_technique> ::= "SHADOW_MAP" | "SOFT_SHADOW_MAP" | "SHADOW_VOLUME" | "SHADOW_TEXTURE" | "PARALLEL_SPLIT_SHADOW_MAP"

Importer (

osg2maya

)

Command-line interface

The only parameter currently supported by the importer is the OSG file to import the scene to Maya.

osg2maya <input_file>

Related

Wiki: Main_Page
Wiki: Scene_preview
Wiki: Test_models

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.