home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
100.lha
/
Planete
/
planet.doc
< prev
next >
Wrap
Text File
|
1986-11-20
|
7KB
|
122 lines
================================================================================
____ ____
/ / / / / /
/ / / PLANET GENERATOR / / /
/ / / / / /
____ / / / BY: Russell Leighton ____ / / /
\ \ \ / / / December 1987 \ \ \ / / /
\ \ \ / / / \ \ \ / / /
\ \ \/ / / \ \ \/ / /
\ \/ / / \ \/ / /
\/_/_/ \/_/_/
================================================================================
Any comments? I can be reached at the following address:
Russell Leighton
845 W. Newgrove
Lancaster, CA 93534
This program has been released to the public domain and can be freely
distributed. I only ask to be given credit for the long hours spent. Please
include this file with the program and if any parts are used I would be
interested in knowing about it.
================================================================================
This is version 1.0 and is therefore somewhat lean on user interface. There
may be updates to come. If you have any suggestions I welcome them.
Simply put, this program will map any IFF picture around a sphere (hence forth
referred to as a planet). The planet is then shaded based on the location and
size of a light source. The mapping is done by equating constant latitude and
longitude lines around the planet with constant horizontal and vertical lines
on the map. The planet view is computed by applying a transformation based on
inputted planet rotation angles. The result is displayed using HAM mode in
lo-res interlaced resolution (320 x 400).
The method used to shade the planet involves taking the cosine of the angle
between the normal vector on the surface of the planet and the light source
vector and multiplying each color component with the result. The actual color
displayed is computed by attempting to get as close to the desired color as
possible. This is accomplished in three steps. First a color is computed
using the rules of HAM mode (see ROM Kernal manual). A difference factor is
then computed and compared to the difference between the desired color and each
color in the existing color palette (initially this color palette may be all
black). If a color in the palette comes closer then that color is selected and
the difference factor is again computed. If this difference exceeds a set
maximum allowed difference then the desired color is added to the color palette
(if room exists). In this manner the color palette is adaptive (you can
override this feature by specifing the map color palette be used as the planet
color palette). A color bar located in the screens title bar shows the planet
color palette as it is updated.
If the specified map is a HAM picture a further complexity develops. The
program computes the map coordinates from the pixel location on the planet
display. Therefore, the map coordinates will not progress in a linear fashion.
For HAM pictures the RGB value at any location on the map is dependant
on all preceding color values on a particular row and is not necessarily
dependant on the last color value obtained from the map. Therefore, to obtain
the correct RGB value for a location on the map all preceding color values
must be taken into account. The overall effect is an increase in the amount
of time required to generate the planet.
The size of the light source has an effect on the "wrapping" of the lighted
portion of the planet. If the light source is the same size as the planet then
half the planet will be illuminated. If the light source is significantly
larger than the planet (say 5 planet radii) then the planet will be illuminated
around a noticably larger area. Likewise, if the light source is smaller than
the planet the illumination will cover less than half.
Both the planet rotation and the light source position are specified in terms
of rotations about the three axes, x, y, and z. Counterclockwise rotation is
positive and clockwise is negative. These angles can be specified in any
order. The resulting rotations are very dependant on this order of input.
I could try to explain how the transformation is accomplished, but I'm lazy
so I recommend just trying some different angles to get a feel for how it
works. I suggest using the same angles while changing the order.
Currently this program can only be run from the CLI and takes the following
form:
planet [filename] [-r -px -py -pz -lx -ly -lz -s -f -h]
The arguments are optional and may or may not require numerical input. A
filename may be supplied for the planet map. This file must be an IFF picture
(form ILBM) and may be in any mode or mixture of modes (LORES, HIRES, LACE,
HAM). If no filename is given then the map is assumed to be planet.map (which
must be present). The radius of the planet (argument -r) is specified in
number of pixels. If the radius is not input it is assumed to be 180 pixels.
The planet rotation angles (arguments -px, -py, -pz) are specified in degrees.
If any of these angles are not specified they are assumed to be 0. Likewise,
if the angles for the light source position (arguments -lx, -ly, -lz) are not
input they are assumed to be 0. The radius of the light source (argument -s)
is given in terms of the planet radius. A value of 1.0 indicates that the
light source is the same size as the planet. This is the default value. If
you require the color map of the planet be the same as the map include the -f
argument. This option is useful for those occasions when successive planets
are generated from the same map and they require the same color palette (this
is required by some animation routines). This argument does not require a
numerical input. If it is not included then the planet color palette is
adaptive and will depend on the values specified for the other arguments. The
maximum allowable difference can be specified with the -h argument. The hard
upper limit for this value is 45 (the difference factor between white and
black) and hard lower limit is 0 (somewhat rediculous since this would result
in every computed color value failing the final test and being added to the
palette). The default value for this argument is 6.
An example follows:
planet fractal.map -r 120 -pz 30 -py 20 -lx -30 -ly 45 -h 12 -s 2.0 -f
If you need to be reminded of the optional arguments just type the following:
planet ?
I have had very good success with a variety of pictures ranging from paintings
to digitized pictures. I hope that this program provides some insight into
programming with graphics on the Amiga. A lot of time was spent trying to get
HAM pictures to process properly and I feel that those parts of the program
could be very useful.