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.
This book is available from:
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 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.zip source code
To be informed for future updates, subscribe to the RSS feed of my blog for notifications of new versions.
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.
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 CheckBoxUse 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 AnimatorVisualization 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 MarketReading 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 TrackingGetting 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 StationPut on your cyan/red 3D glasses for this anaglyph of a 3D space station rotating in the darkness of deep space.
© Charles Petzold, 2007
This page last updated August 2007