3D Programming for Windows

Three-Dimensional Graphics Programming for the Windows Presentation Foundation

by
Charles Petzold

3D Programming for Windows

3D Programming for Windows explores and elucidates the 3D graphics programming facilities of the Windows Presentation Foundation (WPF) under Windows Vista and the .NET Framework 3.0.

ISBN: 0-7356-2394-5; Microsoft Press; July 2007; 430 pages.

Availability

This book is available from:

as well as many other real and virtual bookstores.

Table of Contents

  1. Lights! Camera! Mesh Geometries!
  2. Transforms and Animation
  3. Axis/Angle Rotation
  4. Light and Shading
  5. Texture and Materials
  6. Algorithmic Mesh Geometries
  7. Matrix Transforms
  8. Quaternions
  9. Applications and Curiosa

Source Code

For source code to programs in the book, go to the companion content page.

Information about this source code can be found in this blog entry.

The Petzold.Media3D library

The source code for the book includes version 0.9.0.0 of the Petzold.Media3D library (including source code). Purchase of the book entitles you to royalty-free use of the library in your own programs, including commercial applications. Please do not distribute the source code or a modified version of Petzold.Media3D.dll.

The latest version of the Petzold.Media3D library is version 0.9.1.0 and can be downloaded here:

Petzold.Media3D.dll

Petzold.Media3D.zip source code

To be informed for future updates, subscribe to the RSS feed of my blog for notifications of new versions.

Using the Book

To use the book, you will need to be running either Microsoft Windows Vista or Microsoft Windows XP with Service Pack 2 installed. You'll also need Visual Studio 2005.

Step 1. Install the .NET Framework 3.0 Redistributable Package (also known as the Runtime Components) from here. You do not need to do this step if you're running Windows Vista because the .NET Framework 3.0 is an intrinsic part of Vista.

Step 2. Install the .NET Software Development Kit from here. This is the big one! You can either download an ISO image to burn on a DVD, or run a Setup program that installs the SDK from the Web. The Web install is available here.

Step 3. Install the Visual Studio extensions for .NET 3.0 from here.

Step 4. The book presumes that you use the Empty Project option in Visual Studio. The .NET 3.0 extensions do not include an Empty Project option for WPF programming. To add this option, copy this WpfEmptyProject.zip file to the directory:

To create a new WPF empty project in Visual Studio, select the File | New Project item from the menu to display the New Project dialog. Select Visual C# at the left and then WPF Empty Project.

Applications and Curiosa from Chapter 9

Chapter 9 of 3D Programming for Windows highlights several example applications that use 3D graphics. Source code for the three XBAPs (XAML Browser Applications) are available with the source code for the book. All programs require .NET 3.0.

Knife-Switch CheckBox

Use 3D in WPF templates to turn ordinary controls such as a CheckBox into animated 3D objects like these antique knife switches used in countless mad-scientist laboratories and executions.

State Population Animator

Visualization of data gains extra dimensions when you add 3D and animation through data bindings. The graphs show population data for each state based on census data from 1790 through 2000. Move the progress bar to advance by year. Click the checkbox to see state proportions rather than totals. Move the mouse to a bar to view the state and population. Use the scrollbar at the right to get a different view.

Goblin Market

Reading online is a whole different experience when you can actually turn the pages of the book. Read Christina Rossetti's eerie and erotic poem Goblin Market by clicking the pages with the mouse.

Mouse Tracking

Getting interactive with 3D is a non-trivial exercise. This program demonstrates how to write code that lets users grab and move 3D objects with the mouse. Click one of the cubes with the left mouse button and drag it to a new location. The program is written so that objects always move parallel to the XY plane. Use the mouse wheel to move the cubes along the Z axis. Use the scrollbars to view the cubes from a different direction.

Space Station

Put on your cyan/red 3D glasses for this anaglyph of a 3D space station rotating in the darkness of deep space.

© Charles Petzold, 2007
cp@charlespetzold.com
This page last updated August 2007