Panda3D Manual: Converting from Maya
<<prev | top | next>> |
This section talks about how to prepare a Maya model for export, and then export it. Since exporting is the very last step, the actual instructions for the export process are last. ## Material Preparation Note: the information in this section is for Panda3D 1.5.0 and beyond. It does not apply to older versions of Panda3D. ### Basic Texturing In order for the Panda3D to correctly export your textures, you must texture your model in a manner that Panda3D understands. In fact, you have to follow a fairly strict formula in order for Panda3D to be able to make sense of your scene. Teaching how to use Maya is beyond the scope of this manual. We assume that you already know how to use maya, and especially the hypershade. The only purpose of this section is to show you what configurations are understood by Panda3D. The first step in texturing your model is to apply a `Phong` shader. This is the only kind of shader that Panda3D understands. You can apply a phong shader using the Maya menus: Next, tell maya that you want to control the color of the surface by clicking the color button: Now create a file texture - this will control the color of the surface: Set the filename. Once you do this, you will be able to see your texture in Maya: You now have a straightforward textured model that Panda3D can export. ### Advanced Texturing You may wish to use Panda's advanced texturing abilities: multitexturing, normal maps, gloss maps, transparency, or glow maps. To use these features, you will need to access Maya's hypershade editor: A straightforwardly textured model will look like this in the hypershade: To apply a normal map, create another file texture and connect the "out color" of the normal map to the "normal camera" input of the phong shader. The normal map must be a true normal map (you can recognize them by their light blue color), not a bump map (which are black-and-white.) Unfortunately, there is a maya button to help you set up a bump map, but what it creates is not correct for Panda3D. If you use the button, you end up with the following incorrect configuration. So far as I know, the only way to get the correct configuration (shown above) is to set it up manually in the hypershade. The incorrect configuration is: You may wish for parts of your model to be transparent. This is a little tricky, because Panda3D understands "opacity maps," and maya understands "transparency maps," which are opposites of each other. (In an opacity map, white is opaque, in a transparency map, black is opaque.) To set it up, you will need to create a reverser-object: You may also wish to control which areas of the model are glossy, and which are not. Panda3D calls this a "gloss map." To do this, create a black-and-white image and connect it to the "specularColor" input of the phong shader. Note that it must be black-and-white, or Panda3D won't understand it. You may also want to create glowing areas on your model. Panda3D calls this a "glow map." I have also heard it called a "self-illumination map" or an "incandescence map." Create a black-and-white image and connect it to the "incandescence" input of the phong shader: Creating a glow map will cause those parts of the model which are glowing to be bright even when the light is dark. However, it will not by itself create a full-featured bloom effect. To get that, you need to use a bloom filter in your Panda3D program in conjunction with the glow map. There is a Sample Programs: Glow Filter that demonstrates this process. Finally, there is plain old multitexturing. Create this structure in the hypershade, using a "Layered Texture" (NOT a "Layered Shader!"): This will cause the two textures to be multiplied, which is the simplest form of multitexturing. You can also obtain certain other effects by changing the settings of the Layered Texture, however, this functionality is very incomplete at this time. For the most part, you can only multiply. ### Merging Textures The Maya exporter may will try to merge textures. For example, if your model has an RGB color map, and a black-and-white opacity map, then the exporter will consider loading them together as a single RGBA texture. In order to merge two textures, the following rules must be satisfied: 1. Their UV mappings must be identical. 2. Their filenames must have a common prefix. By "common prefix," I mean that the files "house-color.jpg" and "house-opacity.jpg" can be merged, because they both start with the common prefix "house-". A common prefix consists of a series of alphanumeric characters followed by a dash. If you do not want two files merged, use a different file naming convention. ## Flagging Objects From Maya The Maya exporter is able to automatically flag objects for collisions if the objects are flagged properly in Maya. There is a MELscript in the available in the CVS that helps flag objects in Maya. Installation Open up maya's script editor (Window>General Editors>Script Editor) Open the script in the editor and execute it (Ctrl+Enter or Script>Execute) Type "eggObjectFlags()" at the script editor and select the text. Middle mouse drag the selection into your custom shelf. Optional: go to the shelf editor and give it a custom icon/name Usage Select the objects that you want to tag and press the shelf script. Set the object type by going to the channel box of the object, there should be a new attribute called Egg Object TypesN. Set the object type to the desired value.
Object Type | Meaning
barrier | The geometry defined at this root and below defines an invisible collision solid.
trigger | The geometry defined at this root and below defines an invisible trigger surface.
sphere | The geometry is replaced with the smallest collision sphere that will enclose it. Typically you model a sphere in polygons and put this flag on it to create a collision sphere of the same size.
tube | As in sphere, above, but the geometry is replaced with a collision tube (a capsule). Typically you will model a capsule or a cylinder in polygons.
bubble | A collision bubble is placed around the geometry, which is otherwise unchanged.
ghost | It means that the geometry beginning at this node and below should never be collided with--characters will pass through it.
backstage | It means that the geometry at this node and below should not be translated. This will normally be used on scale references and other modeling tools.
## Running the Exporter Maya's exporter can be run from the command prompt or via a graphical panel. The command line utility is called maya2egg. There are multiple versions of it corresponding to different versions of maya. For instance, the version to use for Maya 5.0 is maya2egg5, for 6.0 its maya2egg6 and for 6.5 its maya2egg65. The following is an example of how to convert a file(maya binary .mb) if using Maya 6.0 through the command line. The egg file will contain the filenames of the textures. These texture pathnames will be stored as relative paths, relative to the location of the egg file. For example, let's say that the files are laid out like this:
    c:\My Models\Maya Files\Character.mb
    c:\My Models\Egg Files\Character.egg
    c:\My Models\Textures\Character.png
In that case, the command to export the model is:
    c:\
    cd c:\My Models\
    maya2egg -o "Egg Files/Character.egg" "Maya Files/Character.mb"
Note that Panda Filename Syntax uses forward slashes, even under Windows, and this applies to the exporter as well. After doing this export, the character egg will contain the following texture reference:
    "../Textures/Character.png"
Again, notice that this pathname is relative to the egg file itself. Many artists find it convenient to keep everything in the same directory, to avoid having to think about this. This approach works fine. The above conversion process will turn the character into a static model. Models which are rigged (they have bones to help them animate), skinned (polygons attached to the bones/skeleton), and are animated need to use one of the following options:
    maya2egg -a model -o eggFileName.egg mayaFileName.mb
    maya2egg -a chan -o eggFileName.egg mayaFileName.mb
    maya2egg -a pose -o eggFileName.egg mayaFileName.mb
    maya2egg -a both -o eggFileName.egg mayaFileName.mb
The meanings of these options are:
-a model | Save only the skinned and boned model, ready for animation but with no animation attached. This is ideal for models with several event- or interaction-based animations.
-a chan | Save only the animation data on the current model, but not the model itself. This is ideal applying animations to an already-existing model egg file that is ready to receive animation. A model may have several animation channels applied to it.
-a pose | Save the model in the current key position of the animation applied to it. This position must be selected before choosing to export the file. This format does not save the animation.
-a both | This will export the model and animation out as one file.
There are many options to maya2egg. For a complete list, run maya2egg with the -h argument.
maya2egg -h
## Using the Graphical Front-End As of Panda3D 1.0.4, there is a graphical front-end to maya2egg. To run the graphical Maya exporter, drag MayaPandaTool.mel from the panda plugins directory into the Maya workspace. The UI window(below) will appear. You can alternatively load the .mel file from the script editor. To save space, the graphical tool does not have access to all of the features of the exporter. It is designed for rapid verification of assests. The features you can execute with the graphical tool are identical to the respective ones of the command line exporter listed below. Or, you can integrate the UI interface to Maya. There is a very convenient way to launch the MayaPandaTool, using Maya shelf to store the MEL script : [1] open the Script Editor : Window > General Editors > Script Editor [2] In Script Editor, load the MayaPandaTool MEL script : File > Open Script [3] select the MEL text (press Ctrl+A) [4] using middle mouse button, drag the selected text onto the shelf [5] (optional) using Shelf Editor, you can change the image of Panda exporter icon to distinguish it from the others. Anytime you need to open the Panda Exporter, just click the icon on the shelf. For Windows users : If you want a faster launch, you can put the MEL file on the QuickLaunch. Press Ctrl while dragging the MEL file onto QuickLaunch bar. If you don't press Ctrl, the actual file dropped to QuickLaunch is only the shortcut to the MEL file. Anytime you need to open the Panda exporter, just drag it from QuickLaunch bar to the 3D window of Maya.
<<prev | top | next>> |