I’ve been trying to gear up for some Unity usage, which has meant concocting an asset pipeline from my (newly!) preferred level geometry editor, DeleD. The process isn’t quite as trivial as would be ideal hence I’m going to relay it here in the hope that mine is the only sanity lost on this endeavour. Bibble!

Rustle up a quick scene...
1: DeleD Scenes
As we’re going to be using Cheetah3D for texture baking – in this case a nice, radiosity-soaked lightmap – we have to be mindful of C3D’s material limits. Baking in Cheetah3D is done on a per-object basis and (at the time of writing) no object can have more than 16 materials, so in DeleD remember to restrict yourself to 16 materials and to merge your objects (go into object mode, use ctrl+shift to select every primitive in the Scene Inspector then click ‘Merge’ in the Geometry Toolbox) before exporting. Did someone mention exporting?!

The all important Merge tool.
2: Export to .dae
Now we’re going to make use of DeleD’s Collada exporter – if you don’t see it in the Plug-ins menu then you’ll have to grab it from the DeleD plug-in repository. Export your model as a .dae file – I tend to leave the scale at 1, triangulate nothing, and include normals and lights. I also set up a subdirectory for textures as it makes things slightly easier down the line. You may as well delete any lightmap file that might’ve been created alongside the textures at this point.

3: Converting to .fbx
Cheetah3D can’t open Collada files (but Unity can so if you don’t need to swing through Cheetah3D then you’re already good to go!) but it can read fbx files. Fortunately Autodesk offers a free utility for converting from .dae to .fbx (the appropriately named FBX Converter) so download, install and run it…

There really aren’t many options. I go with the default format in binary form without embedded media.
4: Load into Cheetah3D
Your scene should now load into Cheetah 3D with nary a hitch. Even so you’ll probably want to adjust the scale under the fbx import preferences to 0.100 as one C3D unit feels much larger than one DeleD unit, something which will be evident in the lighting even when you scale things down – in the example scene I have set the light’s intensity to 200 and added a radiosity tag (with an intensity of 0.5) to the camera to stop the final render looking like Doom 3.
You’ll also notice that the materials come furnished with a modicum of likely-unwanted specularity. However, as there will inevitably be less than seventeen of them, it’s not particularly arduous to correct them individually.
Once this fine-tuning is done save your scene as a .jas file.
5: Bake!
We’re now ready to generate a lightmap for the scene. If you don’t know how to do this I’ll quickly run through it: First up, highlight the mesh in the Object Browser and add a Bake Texture tag to it. In the properties pane of this tag you need to set ‘bake to’ to UV2 rather than UV1 and ensure that diffuse and radiosity (if you added a radiosity tag to the camera) are the only channels ticked. The rest of the pane’s settings you can adjust to taste. Now click on the Create button next to ‘baking UV coords’, re-save the .jas file and hit the Bake Texture icon (which looks helpfully like an oven).

At this point the Render Manager will pop up with your lightmap – save it to the texture directory along with the others.

6: Get it into Unity!
Finally! It is sensible to first drop the texture folder into Unity’s Project pane as the textures will then be available for your scene’s materials. After that drop your .jas file in there and you will be able to use the Inspector to confirm that the materials are correct and tweak them for lightmapping: Select each material in turn and change its shader from Diffuse to Lightmapped>Diffuse, this will reveal a second texture slot to which the lightmap can now be assigned.

With that done, drag an instance of your scene into the Hierarchy pane and – Houston, we have a beautiful black triangle!
Of course, with a little extra bakery you can get those draw calls down to one ;-P
