Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!amethyst.bucknell.EDU!hentosh From: hentosh@amethyst.bucknell.EDU Newsgroups: comp.sys.apple Subject: Re: 3-D vector graphics in assembly Message-ID: <8904220157.AA04218@amethyst> Date: 22 Apr 89 01:57:07 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 41 >I'm sure most people have seen games like Stellar 7, Arctic Fox, and >Elite. While fairly simple, the graphics are nonetheless realistic 3-D. >Question is, does anybody have source/object/vague general notions of >how to do 3-D transformations in assembly language? > >I have a couple of old Nibble magazines, but those requires some transcen- >dental functions and square roots (the latter of which is not well handled >in the GS toolbox... +/- 3...). Is there a better/faster way? > >On a related note, has anybody come up with a faster line drawing routine >than Applesoft hires? If you've ever looked at the code, you'd know that >writing faster code would be difficult... understanding the code is hard >enough in itself... > >fadden@cory.berkeley.edu (Andy McFadden) I wrote some fast 3d routines awhile ago, I don't have the source code but the general idea is that you compute the functions for the possible inputs and then place them into a lookup table. Then if you want a value just look it up. Now if do some checking of the position functions you will see that you don't need much accuracy for the functions so your table is actually quite small than you would think. I don't know what routines applesoft uses to draw a line, but a fast one I know is to take the end point and subtract the other end point from it. Choose the point that is the lower one to use as your subtrand. Now the delta_y over delta_x is the slope of the line. Start at the position that you subtracted and draw a dot. If the delta_x is greater than the delta_y then draw the next dot to the right of the previous and subtract one from the delta_x, otherwise draw the next dot above the previous position and subtract one from the delta_y. repeat until both delta_x and delta_y equal zero. This method is fast becuase it doesn't use division. You will note however it is for lines that only have a positive slope. To do the negative slope subtract from the delta_y and move down instead of up on your check. Also this algorithm is nice in the sense that if you give it the same two endpoints, it will always draw the same line. (You won't have any stray pixels if you try to erase a line by drawing another one over it) I leave the rest to you, have fun. -- InterNet: hentosh@amethyst.bucknell.edu | 'Ever have deja vu and amnesia BITNET : hentoshr@bknlvms.bitnet | at the same time?' AppleLink PE : RobertH128 | -- Steve Wright