home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 100.lha / Planete / planet.doc < prev    next >
Text File  |  1986-11-20  |  7KB  |  122 lines

  1. ================================================================================
  2.                  ____                                                   ____
  3.                 / / /                                                  / / /
  4.                / / /        PLANET GENERATOR                          / / /
  5.               / / /                                                  / / /
  6.    ____      / / /          BY: Russell Leighton          ____      / / /
  7.    \ \ \    / / /               December 1987             \ \ \    / / /
  8.     \ \ \  / / /                                           \ \ \  / / /
  9.      \ \ \/ / /                                             \ \ \/ / /
  10.       \ \/ / /                                               \ \/ / /
  11.        \/_/_/                                                 \/_/_/
  12.  
  13. ================================================================================
  14.  
  15. Any comments?  I can be reached at the following address:
  16.  
  17.                Russell Leighton
  18.                845 W. Newgrove
  19.                Lancaster, CA  93534
  20.  
  21. This program has been released to the public domain and can be freely
  22. distributed.  I only ask to be given credit for the long hours spent.  Please
  23. include this file with the program and if any parts are used I would be
  24. interested in knowing about it.
  25.  
  26. ================================================================================
  27.  
  28. This is version 1.0 and is therefore somewhat lean on user interface.  There
  29. may be updates to come.  If you have any suggestions I welcome them.
  30.  
  31. Simply put, this program will map any IFF picture around a sphere (hence forth
  32. referred to as a planet).  The planet is then shaded based on the location and
  33. size of a light source.  The mapping is done by equating constant latitude and
  34. longitude lines around the planet with constant horizontal and vertical lines
  35. on the map.  The planet view is computed by applying a transformation based on
  36. inputted planet rotation angles.  The result is displayed using HAM mode in
  37. lo-res interlaced resolution (320 x 400).
  38.  
  39. The method used to shade the planet involves taking the cosine of the angle 
  40. between the normal vector on the surface of the planet and the light source
  41. vector and multiplying each color component with the result.  The actual color
  42. displayed is computed by attempting to get as close to the desired color as
  43. possible.  This is accomplished in three steps.  First a color is computed
  44. using the rules of HAM mode (see ROM Kernal manual).  A difference factor is
  45. then computed and compared to the difference between the desired color and each
  46. color in the existing color palette (initially this color palette may be all
  47. black).  If a color in the palette comes closer then that color is selected and
  48. the difference factor is again computed.  If this difference exceeds a set 
  49. maximum allowed difference then the desired color is added to the color palette
  50. (if room exists).  In this manner the color palette is adaptive (you can 
  51. override this feature by specifing the map color palette be used as the planet
  52. color palette).  A color bar located in the screens title bar shows the planet
  53. color palette as it is updated.
  54.  
  55. If the specified map is a HAM picture a further complexity develops.  The
  56. program computes the map coordinates from the pixel location on the planet
  57. display.  Therefore, the map coordinates will not progress in a linear fashion.
  58. For HAM pictures the RGB value at any location on the map is dependant
  59. on all preceding color values on a particular row and is not necessarily 
  60. dependant on the last color value obtained from the map.  Therefore, to obtain
  61. the correct RGB value for a location on the map all preceding color values
  62. must be taken into account.  The overall effect is an increase in the amount
  63. of time required to generate the planet.
  64.  
  65. The size of the light source has an effect on the "wrapping" of the lighted
  66. portion of the planet.  If the light source is the same size as the planet then
  67. half the planet will be illuminated.  If the light source is significantly
  68. larger than the planet (say 5 planet radii) then the planet will be illuminated 
  69. around a noticably larger area.  Likewise, if the light source is smaller than
  70. the planet the illumination will cover less than half.
  71.  
  72. Both the planet rotation and the light source position are specified in terms
  73. of rotations about the three axes, x, y, and z. Counterclockwise rotation is
  74. positive and clockwise is negative.  These angles can be specified in any 
  75. order.  The resulting rotations are very dependant on this order of input.
  76. I could try to explain how the transformation is accomplished, but I'm lazy
  77. so I recommend just trying some different angles to get a feel for how it
  78. works.  I suggest using the same angles while changing the order.
  79.  
  80. Currently this program can only be run from the CLI and takes the following
  81. form:
  82.  
  83.        planet [filename] [-r -px -py -pz -lx -ly -lz -s -f -h]
  84.  
  85. The arguments are optional and may or may not require numerical input.  A 
  86. filename may be supplied for the planet map.  This file must be an IFF picture
  87. (form ILBM) and may be in any mode or mixture of modes (LORES, HIRES, LACE, 
  88. HAM).  If no filename is given then the map is assumed to be planet.map (which
  89. must be present).  The radius of the planet (argument -r) is specified in 
  90. number of pixels.  If the radius is not input it is assumed to be 180 pixels.
  91. The planet rotation angles (arguments -px, -py, -pz) are specified in degrees.
  92. If any of these angles are not specified they are assumed to be 0.  Likewise, 
  93. if the angles for the light source position (arguments -lx, -ly, -lz) are not
  94. input they are assumed to be 0.  The radius of the light source (argument -s)
  95. is given in terms of the planet radius.  A value of 1.0 indicates that the 
  96. light source is the same size as the planet.  This is the default value.  If 
  97. you require the color map of the planet be the same as the map include the -f 
  98. argument.  This option is useful for those occasions when successive planets 
  99. are generated from the same map and they require the same color palette (this 
  100. is required by some animation routines).  This argument does not require a 
  101. numerical input.  If it is not included then the planet color palette is 
  102. adaptive and will depend on the values specified for the other arguments.  The 
  103. maximum allowable difference can be specified with the -h argument.  The hard 
  104. upper limit for this value is 45 (the difference factor between white and 
  105. black) and hard lower limit is 0 (somewhat rediculous since this would result 
  106. in every computed color value failing the final test and being added to the 
  107. palette).  The default value for this argument is 6.
  108.  
  109. An example follows:
  110.  
  111.    planet fractal.map -r 120 -pz 30 -py 20 -lx -30 -ly 45 -h 12 -s 2.0 -f
  112.  
  113. If you need to be reminded of the optional arguments just type the following:
  114.  
  115.    planet ?
  116.  
  117. I have had very good success with a variety of pictures ranging from paintings
  118. to digitized pictures.  I hope that this program provides some insight into
  119. programming with graphics on the Amiga.  A lot of time was spent trying to get
  120. HAM pictures to process properly and I feel that those parts of the program
  121. could be very useful.
  122.