WPF 3D Resource

I’ve been following Eric Sink’s fascinating The Twelve Days of WPF 3D blog leading up to the important release of Charles Petzold’s new book due to be released tomorrow, July 25th. Eric was involved as a technical reviewer and had early access to its content.

3D is one of the most important distingishing characteristics of WPF XAML. 3D is new to the browser world, at least in a native browser form, and WPF 3D affords a rich set of capabilities that make possible 3D web applications. Eric’s blog provides a nice tutorial with helpful pointers on the use of 3D WPF. Without going into great detail it describes his insights from developing an application called “Sawdust”. The application itself is not online but the insights are applicable to online xbap as well as a standalone program.

Charles Petzold is a legend in the Windows programming world. He has produced a long line of reference books for those needing to program in WIndows and his latest is
3D Programming for Windows

Anyone developing 3D content for .NET 3.0 will need to study Charles Petzold’s new book as well as Chapter 12 of Nathan Adam’s book Windows Presentation Foundation Unleashed.

This is a test of WordPress 2.2.1

I’ve manually run a blog for the past couple of years, but decided it was about time to setup a more automated approach. WordPress,  is a popular webblog tool using PHP. It was very straightforward to install WordPress 2.2.1 on a server with a MySQL DB. After playing around with a few options it was not difficult to start importing items from my existing site: http://www.cadmaps.com/gisblog.htm

I managed to edit the html from the old site and even found a work around for embedded YouTube videos without too much effort. So far I’ve found WordPress easy to use, but I have yet to work on customizing the styling.

The recommended w.bloggar tool is actually a better interface for editing and adding content. For example, I found that modifying the YouTube embed code to use <div> in place of <p> did not work in the WordPress editor, but worked fine from a w.bloggar publish.

 Overall the WordPress experience has been pleasant. In the past I’d attempted to use a Java weblog tool , Roller Weblog , without much success. I now see that Roller has been released from Apache incubation and I will need to check out the 3.1 version. There doesn’t seem to be much advantage to java over PHP in my current configuration. WordPress is a tool to get the job done. I have not yet thought of any real use for customized map interfaces in a weblog that can’t be accomplished with a straightforward embed.  If I want to work with a 3D connected graph sometime using WPF to show article relationships in a 3 axis spatial model, I might need to work with a weblog tool that is .net 3.0 friendly.

Now I just need to readup on WordPress and see about some customization of styling.

WPF Camera flight over Pikes Peak terrain model

In this experiment the WPF camera flight control is used in a terrain of the Pikes Peak Colorado area. This is similar to the previous Broadmoor Flyby but uses a larger terrain model. The YouTube video below is a screen recording using the iCord screen capture project from sourceforge.net. This screen capture was done from a low end tier0 XP PC, which would be a worst case system.

Fig 1 – Flying WPF Camera – Pikes Peak


The terrain model in this example is about 20Mb. The WPF GeometryModel3D TIN was constructed from USGS 30m DEM data. In this larger terrain the flight timer interval was set to 500ms. Z-fighting occurs again when using the camera gimbal control. However, in this model the camera can descend into the mountain without a rendering problem. This was not the case in the previous Broadmoor model. Feedback from several viewers confirms that this rendering breakup occurs on a variety of hardware configurations including a tier 3 Vista setup.

Flying the camera

In the past few experiments using WPF terrain meshes I’ve made use of scrollbar bindings to manipulate the scene. Although this is satisfactory for experimental proof of concept it remains an obstacle for flying through a 3D scene. This week I finally built a flying camera with instrument controls for throttle, banking, and tilting which lets me fly my camera around in the model and swivel its LookDirection with a gimbal tool.

Fig 1 – Terrain model with a camera flying control


There are at least three ways of manipulating a viewport in WPF/XAML:

      1) transform the scene itself

      2) move the camera position

      3) finally change the camera’s look direction and zoom lens.

    Under the covers all these approaches would seem to be manipulating the scene viewport with the same set of matrix transforms. Curiously, however, there are differences. When either transforming the scene, or moving the camera position, the view tends to break up at close distances. This is apparently a form of z-fighting, where the rendering stack from front to back gets confused. However, when using the FieldOfView zoom lens the viewport can go right into the scene with no z-fighting. There may be some issue with Microsoft’s DirectX code used for WPF/XAML or it may be related to the specific graphics driver used on my system. Either way navigating a scene at close quarters is not always a smooth journey. I can only hope Microsoft will work this out for the next WPF/Xaml release.


Fig 2 – Terrain model with camera swiveled to show example of z-fighting

Conceptually, viewing the camera as mounted on a flying vehicle using a swivel gimbal seemed better than many scrollbar control bindings. In the flying camera model there are three parameters for the vehicle and three for the gimbal:

  • vehicle bank – left and right
  • vehicle tilt – up and down
  • vehicle throttle – up and down
  • gimbal swivel – left and right
  • gimbal swivel – forward and backward
  • camera zoom lens – near and far

In order to fit these six parameters into a simple interface I attempted to create a flight instrument icon. The target geometry on the right menu provides a simple 2D geometry for connecting parameters to x,y axis. While using the mouse left button inside the target icon, x and y values connect to vehicle bank and tilt. In addition, mousewheel events are used to set throttle for the moving vehicle. A simple horizon line gives the client feedback hints for the vehicle attitude with a position red dot to show current parameter location.

The right mouse button changes the gimbal swivel, left, right, forward, and back. The mousewheel is connected to the FieldOfView to simulate camera lens zoom. Feedback is simply a green dot indicating location in the target axis. Once the right mouse button is lifted the gimbal snaps back to straight down.

To help with orientation a key map is displayed in the lower right with a red ball to indicate the current vehicle position. If flying becomes tedious, this red ball can be dragged with a mouse left button to a new location where the camera view is updated.

This simple interface is used to continuously set the six parameters while a timer thread ticks at 500ms to update any changes to the scene view resulting from interface changes. The result is a simple flight interface with a bit of a jerky motion. Setting the tick of the timer to smaller intervals did not seem to smoooth the flight. Perhaps scene transforms are hardware constrained due to the weak tier0 GPU available in my development system. It would be interesting to see how a high performance GPU would deal with a 30ms timer interval.

The model in this case was created from USGS 10m DEM and the Broadmoor Hotel model is a translation from a Google .skp file. The small area was useful for frequent development cycles. In the future it will be helpful to modularize the flight instrument for backporting to other terrain models. Ultimately it would be interesting to work out a terrain stream connected to JPL STRM30 DEM servers and use this type of flight paradigm for navigating across the globe.