![]() |
Marching Ants
I wrote a simple polygonal modeller that supported airbrushing of polygon vertex colors. Since color was important, I needed another way to indicate which polygons were part of the current selection. Just like in Photoshop, the current selection acts like a mask when the paint tools are used. I devised a way to draw animated marching ants in a 3D rendered scene. Normally you only see these in 2D programs.
After the scene is rendered once, I redraw the scene in the backbuffer without lighting. Selected polygons are drawn in white, and unselected polygons are drawn in black.
I've already computed a screenspace bounding box of the selected polygons. This bounding box is used a drawing mask (with glScissor) to improve fill rate a little. I also read the contents of this rectangle from the backbuffer and scan across it horizontally and vertically, looking for transitions from white to black. At these discontinuities, a marching ant is drawn. I keep the locations of the ants in a big list, and redraw them all over and over again on top of the image of the frontbuffer. Many of the ants are redundant, but OpenGL draws points so quickly it doesn't seem to matter. The color of the ants (black or white) is determined by this equation: (x + y + t) % 8 < 4 Return to Drew's Home Page |