This package contains example source to do a lens effect. The QuickBASIC program 'LENS.BAS' will calculate the magnification displacement data file that is used when compiling 'LENS.ASM', the demonstration program. Each time you run LENS.BAS, have it write its calculations to LENS.INC and then when it's done, recompile the assembly source. The demonstration program is a real quick hack. It does not use double buffering so the image flickers. It requires a mouse driver (and obviously a mouse to be installed) to operate. It loads a TGA file and displays it. No checking is done on the TGA file and it must be of the dimensions 320x200x256. I am aware that there are several variants of TGA's and I do not know if they are all compatible, but if you want to have the example program load your own picture, use the Graphics Workshop to convert it. If you want to understand how the generator program works, read the information in the enclosed zip file. The text and image were created by another author. The basic algorithm is essentially the same, except the placement of origin in the calculation model (his was at the closest point on the plane to the center of the sphere, while mine was in the center of the sphere). Also, I don't know if the way he calculates the coordinates of the actual point to be displayed is the same as mine (it went over my head) but I essentially use a mid-point algorithm. Note that my variables are different from his. Since the point (x,y,0) is bouncing up (incrementing Z) and stopping when it touches the side of the sphere, that point is (x,y,sqr(r^2-x^2-y^2)). That point and origin(0,0,0) form a line and the place where that line intersects the plane 'Z = m'. The point on the plane is (?,?,m). The Z-coordinate in that point is m, which is a fractional portion between origin and the point on the sphere. That means that if you multiply x by sqr(r^2-x^2-y^2)/m you get the X-coordinate on the plane and if you multiply y by sqr(r^2-x^2-y^2)/M you get the Y-coordinate on the plane. Now, the X and Y coordinates are of course the actual point to display, but are in the range of -r to -r+d-1, so just add r and you get them between 0 and d-1 Have fun! Jeff .-------------------------------------------------------------. | Jeff Lawson of JL Enterprises haroldf@rcf.usc.edu | | University of Southern California Phone: (213) 258-5604 | | Course Assistant for Computer Use (213) 258-4264 | `-------------------------------------------------------------'