IanG on Tap

Ian Griffiths in Weblog Form (RSS 2.0)

Blog Navigation

April (2018)

(1 item)

August (2014)

(1 item)

July (2014)

(5 items)

April (2014)

(1 item)

March (2014)

(1 item)

January (2014)

(2 items)

November (2013)

(2 items)

July (2013)

(4 items)

April (2013)

(1 item)

February (2013)

(6 items)

September (2011)

(2 items)

November (2010)

(4 items)

September (2010)

(1 item)

August (2010)

(4 items)

July (2010)

(2 items)

September (2009)

(1 item)

June (2009)

(1 item)

April (2009)

(1 item)

November (2008)

(1 item)

October (2008)

(1 item)

September (2008)

(1 item)

July (2008)

(1 item)

June (2008)

(1 item)

May (2008)

(2 items)

April (2008)

(2 items)

March (2008)

(5 items)

January (2008)

(3 items)

December (2007)

(1 item)

November (2007)

(1 item)

October (2007)

(1 item)

September (2007)

(3 items)

August (2007)

(1 item)

July (2007)

(1 item)

June (2007)

(2 items)

May (2007)

(8 items)

April (2007)

(2 items)

March (2007)

(7 items)

February (2007)

(2 items)

January (2007)

(2 items)

November (2006)

(1 item)

October (2006)

(2 items)

September (2006)

(1 item)

June (2006)

(2 items)

May (2006)

(4 items)

April (2006)

(1 item)

March (2006)

(5 items)

January (2006)

(1 item)

December (2005)

(3 items)

November (2005)

(2 items)

October (2005)

(2 items)

September (2005)

(8 items)

August (2005)

(7 items)

June (2005)

(3 items)

May (2005)

(7 items)

April (2005)

(6 items)

March (2005)

(1 item)

February (2005)

(2 items)

January (2005)

(5 items)

December (2004)

(5 items)

November (2004)

(7 items)

October (2004)

(3 items)

September (2004)

(7 items)

August (2004)

(16 items)

July (2004)

(10 items)

June (2004)

(27 items)

May (2004)

(15 items)

April (2004)

(15 items)

March (2004)

(13 items)

February (2004)

(16 items)

January (2004)

(15 items)

Blog Home

RSS 2.0

Writing

Programming C# 5.0

Programming WPF

Other Sites

Interact Software

DirectX Mesh File (.x) to Xaml Converter and The Inevitable Teapot Demo

Friday 11 June, 2004, 05:37 PM

[Update 2004/11/25: A new version of this utility, updated for the Avalon CTP release is now available here.]

Well somebody had to do it sooner or later:

A Teapot in a XAML file

This is a XAML file using Avalon's 3D features to show the ubiquitous teapot. I won't post the XAML inline in this blog because it's big - I'm sure nobody wants to read through 100K of XAML in their RSS aggregator, especially when it's almost entirely coordinates. But if you want to try it out, it's available in the ZIP that contains the utility I wrote to create it.

What utility is that, he asked rhetorically?

It's a little tool to work around the limitation that today, there's only one working 3D primitive in Avalon, the MeshPrimitive3D. There's no built-in way of importing external meshes, nor are there any higher order primitives like cube, or sphere. There is the ImportedPrimitive3D element, but that turns out not to be implemented in the current build (4074 - WinHEC build). If it were, you'd be able to point it at a DirectX mesh file, in order to import externally-generated meshes directly into your XAML scenes.

Wouldn't that be useful?

Well I thought so, which is why I wrote this tool as a stopgap: DXMeshToXaml (V1.0). (75KB. This zip includes the source and the XAML file used to generate the picture above.)

The way you use this tool is from the command line. Just pass in the path of the .x file containing the DirectX mesh you'd like to import, and it will generate the <MeshPrimitive3D.Mesh> element for you. (It prints it to standard output. You'll probably want to redirect that to a file.) You can then copy this into a <MeshPrimitive> element in the model of a <ViewPort3D> file. (See here for a little more information on how to use these new 3D support elements in Avalon.)

Note that this tool requires the Managed DirectX runtime to be installed before it will work.

More importantly, note that this doesn't tool actually run on Longhorn, or at least not as Longhorn is configured out of the box. It will complain about the lack of Managed DX9 assemblies. (I think Longhorn's Managed DX assemblies are all marked as v10.) It might be possible to install the Managed DX9 bits on Longhorn, but I've not tried. For the time being, you'll need to do what I do, and run this conversion utility on some other box before copying its output over to your Longhorn machine.

This is a very rough and ready tool. I've only tried this on a few of the demo files in the DirectX 9 SDK. (It works fine on the dolphin, teapot and car models. I've not tried the rest.) If you use this and find it doesn't work on models you'd like to use, feel free to contact me to let me know where it doesn't work, and I'll see if I can fix the problem.

Copyright © 2002-2024, Interact Software Ltd. Content by Ian Griffiths. Please direct all Web site inquiries to webmaster@interact-sw.co.uk