September 7, 2011

Mixamo to Panda3D Pipeline

Mixamo allows you to save models in a variety of formats (FBX, COLLADA, BVH Motion Capture)…

Mixamo Blender Panda3D
Character and Animation Pipeline

PRE-REQUISITES:

A basic knowledge of Blender (driving the user interface and installing plugins).

PROCESS:

Mixamo allows you to save models in a variety of formats (FBX, COLLADA, BVH Motion Capture). I began choosing the COLLADA export option.  I do not generally need to model much so I do not have any expensive 3D suites such as 3D Studio or Maya. I instead opted for the free and open-source solution Blender. Upon attempting import of the COLLADA I was greeted by a mess of a model in Blender. Something had gone wrong. Retrospectively, at this point, finding out why it hadn’t worked would have been the best course of action. Instead, I concluded there was some quirkiness going on with COLLADA and switched to the other export option offered by Mixamo – FBX. After a bit of digging I stumbled on an FBX Converter (Windows only sadly). The best option it had (for a format that would include the animations, not just the static model) was, you guessed it, COLLADA. Irritating. 🙂

Zombie Walk

After yet more digging I found what I was looking for on the Mixamo website itself (by fluke, in an “order confirmation” email for a free sample!). I wish they’d put this kind of information more upfront on their website, the “model pipeline” is the first thing anyone will want to know who has an actual use for their creations!  Mixamo offer a free Blender plugin for “Mixamo COLLADA Import”. It is only for Blender 2.49 but that’s a good thing as the same applies to the Chicken Exporter we use later! (in other words, you need Blender 2.49, it should run happily alongside newer versions). I thought COLLADA was COLLADA was COLLADA, y’know, the whole point of it being a standard? Mixamo say their importer conforms to the COLLADA standard. I don’t know what the truth is or why the COLLADA importer that came shipped with Blender didn’t work. Don’t know, don’t care really. The Mixamo importer is Windows or Mac only (as is their site really since it uses the Unity3D plugin). It worked too – or so I thought.

I tried to render a scene in Blender and observed “no textures”. Looking at the console output for the importer there were errors regarding the images not being readable. Long story short, I finally clicked that it could not handle spaces in the file path. So storing the COLLADA file in a “C:\Documents and Settings\….” style path was a problem. Pity the importer didn’t report an error in Blender itself. Once I moved the files to a non-whitespace path (C:\getting-annoyed-now\, for example) it worked perfectly.

Final hurdle. From Blender to Panda3D. There is a Blender plugin called the Chicken Exporter. I installed it and exported from Blender. The resulting EGG file worked – but with no textures or animations. Fixing the textures was easy, I just edited the EGG file directly (it’s a text format file) and fixed the paths by changing them to relative paths (the exporter had added absolute paths such as “c:\getting-annoyed-now\…..” to all the image paths, I was not even on the same machine or operating system at this point, so those files certainly did not exist in an “absolute” position). Fixing the animations was something a bit more involved.

In Blender, select the Armature in the Outliner panel. In the buttons panel you will now see a “Modifiers” tab. In that tab, there is a button “Make Real” (with the text “Armature Parent Deform”). I don’t fully grasp what it is doing when you click this but a “modifier” appears under the Armature in the Outliner. It has something to do with armatures via parenting or modifiers but I’m not a Blender guru (in fact very much a newbie!). Once done, the Chicken Exporter window now shows the option “add animation”.

Ok, now, find out how long the animation runs. Open up the NLA Editor and click right at the end of the animation. In your main Blender window (3D View) the current frame should show up at the bottom left. Cool. Also, in the outliner, note the name of your Armature. In my case it was “Zombie_Hips” (or open up enough panels that you can see all of this information in one screen, like the screenshot below).

Blender

Blender

Finally, export via Chicken. Make sure you have done “select all” (hover over the 3D view and hit the ‘A’ key on your keyboard until everything is highlighted) before launching Chicken.  Click the “Add Animation” button. Set the animation name to the same as the Armature/Object name (both set the same for Mixamo imports), set the End frame to the final frame, and export. The job is done, it should all work, 3D character and animation. In Panda3D’s PVIEW, hit “l” to enable lighting else you won’t see the textures.  BTW – that last bit, I just flippantly mentioned (set the animation name to the armature name) is critical.  It cost me hours of head scratching time that!  All being well, you’ll find you have an EGG file that works with animation and texture!