3D Environments on the Palm

tri.prc - 3D graphics demo for the Palm
tri.zip - Source code

Hole #1 - a gentle slope downhill, a slight bend to the right, and uphill to the green just out of sight over a rise. In the distance, we can see the flag.

This B&W scene was not drawn by hand. It's a 3D environment constructed of arbitrary n-sided polygons and convex polyhedrons. It can be rendered from any viewpoint.

Black and white or very low bit-per-pixel displays pose some interesting problems. I spent most of my time in the Idaho Sawtooths in the last week of August 1999 looking at landscapes and shadows and trying to convert them to low-res silhouettes in my head. I made several attempts to do B&W terrain using texture mapped polygons only to discover that things don't scale worth a damn. You can't anti-alias anything, and as soon as you move a couple "steps" away from something, it becomes 3 pixels high and looks like gnats on the screen. I started wondering if what I wanted to do was impossible. On the way back, I stumbled across a Dr. Dobbs article in a Boise coffee shop about analyzing the contents of the Z-buffer (an array of per-pixel distances between the eyepoint and the first occluding surface) and using adjacent values to decide whether to light a pixel or not. It turned out to be exactly what I was looking for.

For a time, I was prototyping the graphics engine in Watcom C under DOS and writing to a virtual 160x160 B&W display. To do these screenshots, the program just dumped its video buffer to a PCX file. The basic prototype seen here has been ported to the Palm. It's not a speed demon. The Palm has no hardware floating point, and also has no 32x32 multiply or divide instructions. These scenes are deceptive; they look very simple, but actually take a tremendous number of cycles to produce. Work to convert the math to fixed-point and apply 68000 assembler where needed got frame rendering times down to about two seconds, where a frame consisted of about 300 Z-buffered backface-culled Laplacian-operator-outlined triangles.

Anyway, if the performance can be boosted by an order of magnitude, then all that's left to do is add the rocket-powered golf clubs, laser sights, exploding balls, rabid ball-snatching wildlife that must be hunted down and blown to smithereens, and of course, multiplayer deathgolf mode.


Walking up the hill to the green, and turning around to look back at where we came from. Note the slightly elevated ground on the left as we approach the flag, barely visible on the right hand side after we've turned around. This information could also be available to a physics portion of the program, so a ball rolling across that surface would break toward the downhill side of the polygon.