int131d@monu3.cc.monash.edu.au (mr s.d. twyford) (03/21/91)
I have been working on 3d vector graphics, trying to develop code that is acceptable for 3d commercial games (it ain't easy). At the moment I have filled polygon graphics with hidden surface removal and depth sorting, but I am still working on window clipping. I have a picture with 80 points and 57 polygons doing 2d rotation, with no polygons moving relative to each other, with one step taking somewhere between 2 and 3 frames in PAL (50hz). For those just begining 3d graphics or those planning to, I suggest that you do what I did. That is, start with a simple program, something that opens an Intuition screen, draws a few lines with Move(); and Draw(); and rotates and redraws until the mouse button is pressed (no double buffering, all real numbers). Then improve it by double buffering, changing all reals to integers, writing assembler drawing routines that use the blitter directly, switching completely to assembler and generating your own copper lists for the screen display. Some people will complain that this is reinventing the wheel, going too close to the hardware, or whatever. I don't see anything wrong with the practice of hitting the hardware as long as you obey the development guidelines in the front of the RKM, and you ask the operating system as politely as possible first, and restore the hardware to the operating system nicely when you exit. If there are any good books on 3d graphics relevent to what I am attempting, I have not found them. Maybe there is one out there somewhere. IMHO the best book on the Amiga display hardware is: The Amiga System Programmer's Guide, Dittrich, Gelfand and Schemmel. No. 6 of the series on the Amiga by Abacus. If anyone knows any good books on writing flight simulators or such, could they please inform me. Now to the algorithms I use in the above mentioned program. I generally grade the efficiency of an algorithm on the number of multiplications and divisions it takes per point or surface or whatever, just as a rough measure. Most surfaces only have one visible side, so I dot a surface normal with a vector from the eye to the surface to detect which side is facing the eye (3d dot product, 3 muls). This is slower than the clockwise method (2 muls), when the surface needs to be drawn, but if the surface is not drawn, and the points are not needed by other surfaces, then the clockwise method requires the 2d perspective of the first 3 points, which takes 6 divs. The surfaces of an object can be grouped into pieces where each surface never overlaps the other surfaces. For example, a cube. The back faces are eliminated by the dot product and the front are all at angles <= 180 degrees. No surface sorting is required, so I group surfaces into these "pieces", relative movements between surface is restricted or the surfaces will start to overlap. I use a binary tree to detect which pieces are behind others, again the pieces are restricted in their movements relative to each other by their places in the tree. To decide which branch of the tree to draw first, I have a surface that is between the pieces on either branch of the tree, all I need is to dot the normal and a point on the surface. Stuart Twyford Internet: int131d.monu3.cc.monash.edu.au