Xaml Export Script for Blender

[UPDATE: The Xaml Exporter now is hosted on CodePlex (here) ]  

The 3D features in the Windows Presentation Foundation make it easier than ever to integrate 3D content into your applications.  However, unless you are satisfied with basic solid geometry you are going to need more than just the WPF.  You’re going to need 3D authoring tools to create interesting content.

Unfortunately 3D tools tend to use their own proprietary file formats with limited import/export support for other formats.  Xaml, being new to the scene (no pun intended), is not yet supported by most tools.  However, some modeling programs feature an add-in architecture that allows custom exporters to be written by 3rd parties.  The free 3D software package Blender is such a tool.

All very interesting you say, but where is this going?

I have posted a new release of the 3D Tools for the WPF which includes a Python script to export Blender scenes as Xaml.  The Xaml can then be dynamically loaded or compiled into your WPF applications.  Figure 1a shows a 3D model being edited with Blender.  Figure 1b shows the final exported Xaml as viewed with the WPF Model Viewer.

Figure 1aThe Steve Ballmer model* is authored in Blender and then exported to Xaml. Figure 1bThe final model as it appears in the WPF Model Viewer.

(Click for full sized images)

Because the WPF and Blender have different goals for their rendering engines their feature sets do not match precisely.  Specifically, the WPF uses the hardware accelerated real-time rendering capabilities of your GPU.  Blender is a software based rendering engine not targeted at real-time applications.  However, the results of the export are frequently quite good.  Figure 2a is the same 3D model as rendered by Blender.  Figure 2b is the exported model viewed from a similar angle with the same lighting configuration in the WPF Model Viewer.

Figure 2aSteve Ballmer model* rendered using Blender’s internal software engine. Figure 2bExported model rendered using the WPF. The blue background is not part of the scene.

(Click for full sized images)

To get the Xaml Export Script for Blender and the WPF Model Viewer download the latest version of the 3D Tools for WPF (available here).  Copy the xaml_export.py script to your Blender scripts directory.  Blender will automatically add the script to the ~File~Export menu the next time it is started.  More detailed instructions and a list of known issues are included in the Read-Me.

* Steve Ballmer model courtesy of Bonnie Lehenbauer