home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / lenssrc / lens.txt < prev    next >
Text File  |  1993-12-01  |  3KB  |  43 lines

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