Saturday 30 July 2011

Python Scripting Distraction

Early on this week I received an e-mail from one of the lead developers for Blender asking me to test the latest pre-release Official FBX exporter with XNA.  He had done some work recently using bits of my XNA specific exporter and wanted to know if the official one was now compatible with XNA.

It was not compatible but I had always intended to merge the two in to one unified exporter so I spent the week doing that.

If you are interested all the source code and lots of notes are available by following these two links:

Its done now and the patch has been accepted.  The next release of Blender (2.59) will only need one FBX exporter and XNA will be supported by that official Blender FBX exporter.

It is not quite as user friendly as my current scripts because there are several tick boxes to select to output in the correct format for XNA. 

There is a convenient 'XNA Strict Options' tick box which forces the options to be compatible with XNA.  It is not required but is handy.

If you select the options manually the following are required:
  • Set the scale to 1.0 (which is is by default.)
  • Use the 'Rotate Animation Fix' (essential otherwise animations are a mess!)
  • Turn off, Empty, Camera and Lamp (makes the file size smaller)
  • Turn off smoothing (might not be necessary but I have not tested that yet.)
  • Do not include edges (makes the file smaller and can avoid some import errors)
  • Turn off optimized keyframes (not essential but might remove a duplicate keyframe that was added deliberately!)
  • Do not include default take (can be tricky to merge animations if they are all named 'Default_Take'!)
  • Select the 'Strip Path' mode so the uv textures use the same folder as the FBX file. (easier to manage the files.)
  • Enable Armature included as bone.  (This is the most important option to select.)

Further instructions are on the Blender Wiki:
I'm now going back to my .NET C# code.  So after spending days working in Python and remembering not to end each line with a semi-colon, I now have to remember to put the semi-colon in!

I much prefer C# with the structured code, type explicit variables (I avoid 'var' in .NET) and most importantly Visual Studio's auto complete and syntax suggestions all built in.  Happy coding.

No comments: