There is nothing quite so immediately gratifying as graphics programming. Specify a few coordinates in a program, and you can draw a line right on the screen. From there you can build it up, add curves, enclose and fill areas, and experiment with different types of brushes. Start animating the coordinates and colors, and you're off.
But 3D graphics programming is not quite so simple. The programmer needs to master several difficult concepts just to get a little something on the screen, and a tiny miscalculation — a camera not quite pointed in the right direction, for example — can result in the scene being entirely invisible.
As someone who teaches programming concepts, I have found this situation very frustrating. I remain convinced that there is an untapped future of 3D graphics programming involving touch-based user interfaces, but I do not have sufficient vision and imagination to realize these myself. All I can do is try to teach programmers the intricacies of 3D programming with the hope that one of my readers will be able to carry the concepts into actual applications.
Yet, the current dominant Windows-based 3D programming interface is Direct3D, and DirectX is hard enough even without the difficulties of Direct3D.
To me, this situation has been a pedagogical problem that I desired to solve — a very hard nut I wanted to crack. To crack this nut I needed to find a way to introduce 3D concepts gradually and progressively without requiring a whole slew of programming techniques to be assimilated just to get a little 3D figure on the screen.
Some six months ago, I began making progress. I noticed that several programming features normally associated with 3D programming were actually available to Direct2D programmers. Within the confines of Direct2D I discovered that it is possible to define and manipulate 3D coordinates and matrices, to apply camera transforms, and to use vertex shaders and pixel shaders. Moreover, each of these topics could be approached incrementally, steadily building a tetrahedron of knowledge and skills that could later be applied to real 3D programming.
Over the next several months, my DirectX Factor column will present these techniques. The first installment is now available in the February issue, entitled "A 2D Portal into a 3D World". Using geometries generated from character outlines, I show how to create a spinning animated image that looks like this (click to see the full-screen version):
What you're seeing here is composed entirely of 2D geometries with a little manipulation and analysis of coordinates to suggest 3D space and hide the background image behind the foreground.
The performance is terrible, but that only suggests there are better ways to do it. Stay tuned.