Tuesday, April 5, 2011

Blender 2.57 Objective-C Export Script

A few days ago, the Blender Foundation put out the first release candidate of Blender 2.5. This release unexpectedly broke compatibility with most existing 2.5 python scripts, including my Objective-C header Export Script.

Which was great timing, since I needed to use the script today. I could've just gone back to an older version of Blender, but decided instead to re-write the script to work. I just added to GitHub, the new 2.57 compatible version of the export script. This version is back to being an add-on that you can add through the User Preferences.

I've also added a few options that you can select when exporting (they're on the left side of the file selection screen, underneath the volumes and recently visited locations). You can see the new options in the following screen grab:

Screen shot 2011 04 05 at 2 32 44 PM

The first option lets you specify whether modifiers are applied before exporting the mesh. If you uncheck this, the script will strip the modifiers before exporting, otherwise, it will apply them to the mesh before exporting.

The second option will rotate the object 90° along the X axis, which converts the object from Blender's Z-up coordinate space to OpenGL's Y-up coordinate space. I've made this the default, but I could foresee situations where people would want to skip the conversion.

The final option will move the export the object using its world space coordinates rather than exporting it using object space coordinates. This option will, for example, preserve relative distance between multiple objects exported from the same file into different headers. Or, to put it another way, objects exported will normally have use their coordinates as they relate to the object's origin, regardless of where the object is in the Blender scene. If this is checked, the vertex coordinates will be exported relative to the scene's origin.

NB: There was a problem with the triangulation code in the version posted earlier. If you're having problems, pull again from GitHub.


Neuro8 said...

Thanks for the update! Do you have any examples of how to parse or use a FBX file to show animations from Maya or Blender?

I'm trying to figure out the content workflow and am not sure keyframe animations (from your earlier tutorial - #6) are what I should use. I have several complex animations. Any advice would be mega appreciated.

Jeff LaMarche said...


Autodesk has an SDK you can download that has classes for parsing FBX files, probably something to look into if you're planning to use FBX files.


Mike Rand said...

Nice update. Would you please update your instructions on how to add the Objective C export script to Blender. Thanks again for your work.

Jeff LaMarche said...


Installation instructions have been added to GitHub. They're in the same folder as the script.

Thanks for the feedback.


lflynn_ said...

I have just found this and it is really useful, thank you. As an additional point, unless I have missed something in the code, this is a c header as opposed to objective-c. Clearly, this is not a criticism, but in fact means it could be used on other platforms too.

Jeff LaMarche said...


Yeah, it is just straight C and I've toyed with changing the name... I figure anyone who needs this is likely to be able to figure that out anyway :)

Klemen said...


I would like to thank you for this script, however I have a question regarding the exporting of colors. In blender 2.49b it worked fine, now blender does not want to export the materials/colors.

I get the following error:
AttributeError :Mesh object has no attribute named 'active_vertex_color'.

I have tried to fix but with no success. Am I doing something wrong?

Thank you