Once Maya2OSG is installed in your system, to use it, you can follow two different approaches, depending on the situation or your preferences: use it from the Maya GUI or use it from MEL code.
NOTE: There is a known bug in Maya2OSG version 0.1. The exporter ignores the user current selection and exports all the scene. It has been fixed in version 0.2.0. The bug is partially caused as a secondary effect of the scene preprocessing that has been disabled in version 0.2.0.
NOTE: Maya2OSG version 0.2 can cause Maya crashes after several exportations. The problem is in the MEL script, so when you update the software don't forget to replace the MEL scripts in your Maya directory.
The first action will be to prepare the scene to be exported. This is can be considered a destructive operation, as it cannot be undone. So maybe it is a good idea to save the scene before exporting it, even though the optimize operations should not cause a major problem, but anyway it is better to prevent, or... do it at your own risk :)
Finally, a file browser let the user select the destination file to export the scene to.
This automated process, in the first releases, loaded the plug-in to use the command and unloaded it after the scene was exported. This is quite interesting for developing, as the plug-in cannot be overwritten while it is loaded. However, Maya does not like this repeated plug-in loading and unloading, and can cause crashes. For this reason, current version only load the plug-in once if it was not previously loaded.
NOTE: From version 0.2.0 the scene preprocessing before exportation has been disabled. For more information about this stage, see the Scene Preprocessing section.
NOTE: A new button is included in the shelf to perform this preprocessing (Cleanup the scene before export). This is currently in SVN and will be included in release 0.3.0.
maya2osg.mll
) is loaded in Maya.
2. Select the geometry you want to export.
3. Enter the MEL command
maya2osg
output_path (e.g.
maya2osg C:/model.osg
).
Before exporting to OSG, the scene should be prepared to avoid potential problems. The recommended sequence of operations is described below:
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. It is included in the
prepare
function in the
osgexport.mel
script supplied with Maya2OSG in
maya
version
/scripts
directory. But from version 0.2.0 it is disabled. If you want to preprocess the scene automatically every time you push the shelf button, edit the script and uncomment the line "
// prepare();
" in the procedure
maya2osg_export
(previously
osgexport
) at the end of the script file.
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;
From release 0.3.0 this process will be available in a new button from the shelf (Cleanup scene before export).
The
maya2osg
MEL command accepts the following parameters:
maya2osg [options] <outputfilename>
Note: Angle brackets
outputfilename
- Output file path
Options:
- OpenGL TexEnv mode
* -exportDefaultCameras
0|1 - Export default cameras (top, front, side, persp) (default: false)
* -exportOrthoCameras
0|1 - Export orthographic cameras (default: only perspective cameras)
* -surfaceMode SINGLE|DOUBLE|KEEP
- Surface mode (all single sided, all double sided, keep as in Maya)
A file browser let the user select the input file to import the scene from.
maya2osg.mll or maya2osg.so
) is loaded in Maya.
2. Enter the MEL command
osg2maya
input_file (e.g.
osg2maya C:/model.osg
).
The
osg2maya
MEL command accepts the following parameters:
osg2maya <inputfilename>
TO-DO: Explanation of shelf buttons
axes.osg
file must be available in
OSG_FILE_PATH
).