Maya to Director

Character Export Tutorial (Oct 2003)

This tutorial/lecture is about how to export an animated character from Maya into Director. The process for 3DS Max is already well-documented and a tad easier too. Click here for a good tutorial. But there's hardly any information for exporting Maya characters; so I decided to come up with this. Have fun.

Step 1: Get your Character Ready!
Model, texture, rig, animate, etc. Get your character ready to go. But here are some things to take into account. The character needs to be made of polygons. Make sure it's all clean and as optimized as possible. Note that procedural textures get crunched into one flat texture. Take a look at the Maya Documentation for what kind of shaders to use. At best, keep the networks simple and use lamberts or blinns. Also, make sure you do a smooth bind during the rigging process. If you did a rigid bind, go back to bind pose, detach skin and re-skin. Don't use any deformers. Oh yeah, one last thing amongst others, name all your bones.

Char

For this tutorial, I whipped out Mr. Fire Eater, did a cheap rig on it and laid a few keyframes here and there. I came up with two animations: Dawdle cycle from frames 0 - 20 and "Yo! Sup!" from frames 22 - 33. Whatever :P

Step 2: S3D Export! Now!
Now go to Window > Settings/Preferences > Plug-in Manager. Look for MayaShockwave3DExport and check loaded. This comes by default with Maya 5.0 but you can easily get the plug-ins for 4.0 and 4.5 from Alias Downloads section. Now, you should see an extra menu called Shockwave 3D Exporter appear on the top.

Plugin

Now would be a good time to light the scene up. Place a few point lights here and there. Then go to Shockwave 3D Exporter > Export Express - All. The options are pretty straightforward; check docs for more info. Should all go well, you should reach the 3D Preview window. This more or less shows what your character will look like in Director. Look thru it and ogle at the stats!

Preview

Step 3: It's time to Director!
Now you should have a W3D file of your character all animated and ready to put into Director. The file can be found at the location stated at the first line of your export results (under Exported file). Import this file into your Director cast. Drag the cast member (here: fireguy1) from the cast to the score. You should see your character on the stage. I suggest changing the color to something lighter. You can do this by clicking on the 3D sprite on the stage and going to the Property Inspector, 3D Model tab and change the color of Background.

Director Stage

Once you play it, you should see the character cycle through all his/her/its animation. Now for some scenarios, this might not be satisfactory. You might want to play certain animations at certain times or give the user control over it. Introduce the Bonesplayer!!

Step 4: Script the bones
The Bonesplayer modifier in Director is what manages the motions of the character. Once a model has a Bonesplayer attached to it, various properties (like speed) can be get or set and some commands (like pause or play) can be issued. In 3DS Max/CS4, you need to group the character mesh and biped, and that group acts as the model that has a Bonesplayer. However, in Maya, things are a little different. The root of the skeleton is the model that has the Bonesplayer (normally).
(Did I just say a bone is a model? Yes, in Director, bones and miscellaneous objects like curves and IK handles come in as or are referred to as models.)
In my case, the root was called "pelvis" and the model that contains the Bonesplayer is called "pelvis-skeleton." To actually confirm which model from Maya contains the Bonesplayer, one can use the Object Inspector. Go to Window and open up the Object Inspector; drag and drop the 3D cast member on to it. Expand the Models section and do a manual search. Usually, the root-skeleton node is the one. Expanding it will show you the Bonesplayer and its various properties.

Object Inspector

Time to put some theory to practice. We are going to delve into some Lingo that will let our user play the animation cycles. Press Control - Zero to open up the Script window. We are going to write a Behavior script so click the script in the cast, go to the Property Inspector, click the Script tab and set the Type to Behavior. Drag and drop this empty behavior on to the 3D sprite on the stage.
Switch back to the Script window. Type in...

on beginsprite me
member(1).model("pelvis-skeleton").bonesplayer.pause()
end me

This essentially says when the 3D sprite begins, pause the Bonesplayer on the pelvis-skeleton. Running the movie now should yield a still character. Next we are going to wait for some key input and play animations off of those BUT first -- time to explain the Bonesplayer play command.

.bonesPlayer.play("animation name", Looped, StartTime, EndTime, PlayRate)

The animation name can be found out by going through the Object Inspector. Here it's "pelvis-skeleton-motion0"
Looped is basically whether or not the animation is looped. 1 is yes for looping and 0 is no...
StartTime is the starting time of the animation in milliseconds. To convert your frame number to milliseconds, divide it by the frame rate (30 fps) to get the seconds and multiply it by a 1000. In my case, Dawdle cycle is frames 0 to 20. 0 is 0, no questions asked. As for EndTime, 20 frames divided by 30 fps is approximately 0.667. Multiply this by 1000 and you get 667. So your EndTime is 667.
PlayRate is speed of animation. Increase for fast motion and reduce for slow motion.

Now we are going to use the play command in a case condition.

on keydown me
case the
keycode of
123: member(1).model ("pelvis-skeleton").bonesplayer. play("pelvis-skeleton-motion0",1,0,666,1)
end case

Add this piece of code after the beginsprite event in the behavior script. It means to say, wait for the user to press down a key. Once a key is pressed, check its keycode. Keycode 123 stands for the left key. So if you press the left key, it will play a looping cycle of the Dawdle animation at a normal speed of 1. OK. Hang on. It's almost over. Now just repeat the same line and make necessary changes to play the next cycle. Start time is 733, end time is 1100 and the keycode is 124 which is the right key.

on keydown me
case the keycode of
123: member(1).model ("pelvis-skeleton").bonesplayer.play ("pelvis-skeleton-motion0",1,0,666,1)
124: member(1).model ("pelvis-skeleton").bonesplayer.play ("pelvis-skeleton-motion0",0,733,1100,1)
end case
end me

>> Take things to next level
This is just a start of the things you can do to the Bonesplayer and thus your character. You can queue actions, blend animations and even use playlists from other motion data.
Click here to download the Fire Eater W3D file. Experiment with it.
P.S. Be careful of copying and pasting code directly from the page into Director. Some HTML characters are interpreted as actual Lingo.
Please send some feedback

Back to Tutorials