My contract for the book tentatively entitled Windows 3D: Three Dimensional Graphics Programming for the Microsoft Windows Presentation Foundation specifies that the book be about 350 pages in length, and that I should have half the manuscript delivered by January 31st.
As of today, I've submitted 40% of 350 book pages to my editor at Microsoft Press, so I'm not alarmingly far off the schedule. Whether I finish the book by April 30th as the contract optimistically specifies — well, only time will tell. But writing this book is a full-time job so it's entirely plausible.
When negotiating a book contract, I am required to present a proposal that includes a chapter outline. Almost always, when I actually start working on the book, that outline goes straight in the trash. It's not that I wouldn't like to work from a strict outline, but inevitably I find that actually writing the book causes me to rethink the ordering of material.
For example, the 1st of 8 chapters in the outline is entitled "The Three Dimensions" which was supposed to cover the 3D coordinate system and vectors. Necessary stuff, of course, but a whole chapter? No way! So, the first two chapters in the outline got merged into the first chapter of the book, now called "Lights! Camera! Mesh Geometries!" That chapter begins with some basics of 3D coordinates and vectors, then puts together simple scenes. I cover both PerspectiveCamera and OrthographicCamera, both AmbientLight and DirectionalLight, and DiffuseMaterial but only using a SolidColorBrush. In the discussion of MeshGeometry3D I cover Positions and TriangleIndices but not Normals or TextureCoordinates.
The original outline has "Transforms" as Chapter 3 and "Animation" as Chapter 5. These topics are so closely intertwined that I decided to cover them together in the book's Chapter 2, which is "Transforms and Animation." It turned out to be huge: about 92 book pages. It might seem as if transforms and animation are rather "advanced" graphics topics and shouldn't be covered in Chapter 2, but I feel that in 3D programming, transforms and animation are essential. This chapter focuses on the standard affine transforms only. It doesn't cover MatrixTransform3D or even Matrix3D, and also ignores quaternions. Those are the advanced topics for a later chapter.
So, the chapters are shaping up something like this. (So far, I've finished and submitted the first two chapters.)
Chapter 1. Lights! Camera! Mesh Geometries! (48 pages with 10 standalone XAML files, one C# project, and 34 illustrations and screenshots)
Chapter 2. Transforms and Animation (92 pages with 19 standalone XAML files, two C#/XAML projects, and 17 illustrations and screenshots)
Chapter 3. Texture and Lighting: Here's where the reader learns how to cover a 3D figure with a gradient brush, or one of the tiled brushes, how to use SpecularMaterial and EmissiveMaterial, how to set the Color properties of the materials, and how vertex-based illumination works. The chapter then goes into PointLight and SpotLight, and emphasizes ever more the need for ...
Chapter 4. Algorithmic Geometry Models: How to generate mesh geometries in code in a way that makes them conducive for covering with tiled brushes, for possible illumination with PointLight and SpotLight, and for non-linear transforms and mesh deformations. Accompanying this chapter will be downloadable source code for a whole 3D library with a namespace (and DLL name) of Petzold.Media3D.
Chapter 5. Applications: Various ways that 3D graphics can be used in the context of WPF programming. While most of the book involves documentation, theory, and coding, I think for this chapter I'll be scouring the web looking for people using 3D in WPF, and presenting code examples showing similar techniques. If anybody has ideas (that is, an existing WPF application that uses 3D in an intriguing way), let me know!
Chapter 6. Deeper Into Transforms: Here's the real math-heavy chapter of the book. I'll approach transforms from a less practical and more theoretical perspective, discuss non-affine transforms, discuss the perspective and view transforms of the camera, and show how these can be exploited to do wireframes in a Viewport3D. I think this chapter will also cover quaternions, but I might want to split that into a separate chapter.
I have a little bit of hit-testing in Chapter 2, but I think that Chapter 6 is the place to put more complex hit-testing, such as interactive dragging of 3D vertices, because that job really requires accessing the camera transforms to convert between 3D space and 2D screen space. (But maybe hit-testing needs to be in Chapter 5?)
The last chapter of my original outline is entitled "Curiosa" and I might still want to end with something like this. I'm thinking stuff like using WPF 3D to make anaglyphs, or to generate movies from individual 3D snapshots for renderings and animations that are too complex for real time, and anything else I can think of that wouldn't quite fit into the other chapters. If anybody has ideas, let me know!
Those days like today when I submit a chapter to my editor are always nice, because I can then take a mini-vacation for the rest of the day and not feel one speck of guilt. I'll be back to work tomorrow on Chapter 3.