home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
CreativeComputers.iso
/
shareware
/
fractals
/
landscape
/
landscape.doc
< prev
next >
Wrap
Text File
|
1994-11-17
|
32KB
|
657 lines
LANDSCAPE (c) June 1990
A Fractal scenery generator.
Programmed by Andrew Kreibich with AMOSv1.21 (C) 1990 Mandarin/Jawx
and compiled with the AMOS compiler.
Note: to quit at any time (without using the menu) press Ctrl-C.
To save memory this programme closes the workbench while it is
running.
LANDSCAPE V1.11 docs
This doc file applies to the full version. You may have the landscapeDEM
version. The only difference between the two is that all saves have
been disabled in the DEM version. You can save a lot of calculation
time and time spent copying parameters as well as being able to
save your pictures by registering. (see DISTRIBUTION, below)
#####################
Memory requirements
#####################
As it stands the programme probably needs 1 meg. I may work on a version
which will run on a 512k machine if I get enough response
BUT!:- This programme generates a 256X256 array of points to render
the scenes with. The only way I can reduce the memory requirements
is to reduce this to a 128X128 array, and this will reduce the
maximum resolution of the pictures to resolution setting 2.
Purpose:
This programme generates Fractal scenery. There are already a few
commercial programmes which do this but this is written in AMOS
(and is unfortunately a bit slow, although the compiled version is a
bit quicker.)
It does this by generating a square array of random points and then
converting these to heights before plotting them on the screen.
I used the midpoint displacement algorithm on page 100 of
"The science of fractal images" by Pietgen and Saupe
Springer-Verlag 1988
to generate the array of points and the projection and illumination
formulae on pages 126 to 128 of the same book to get me started,
although all of the routines have been modified many times since I
read the book.
################
DISTRIBUTION
################
THIS PROGRAMME IS SHAREWARE!
This means that my ego and my wallet would appreciate a little feedback
for all my efforts!
You may distribute the LandscapeDEM programe to anyone providing you
observe the following conditions.
(a) You don't make any money from it (apart from a nominal copying fee)
without my prior written permission.
(b) You may not include it or any routines from it in any commercial
release (including SHAREWARE or one of its variations) without
my prior written permission.
(c) You distribute this entire doc. file file with the programme.
(d) You do not distribute the full version of LANDSCAPE to anyone
(e) You write back and let me know what you think of it along with a
shareware donation. (minimum $20 Australian)
To Andrew Kreibich
Box 333
Wantirna South
Victoria
Australia. 3152
When you register (In Australian dollars please, our banks charge a
fortune to convert:- another benefit of deregulation?), you will receive
the latest compiled version with all features enabled, together with
details of other programmes I have written and the source code to
this programme (in AMOS).
Naturally if you think I have done a really fantastic job on this
and you cannot help but show your appreciation by sending more money
(Australian Dollars!) etc. then I will happily accept it!
If you have the full version and have already registered: Thankyou
If you have the full version and have not registered: Pleas do so and
may the person who supplied it to you be renedered in the gobberwarts
with a blurglecruncheon!
USAGE
*****
This programme is driven by the menus.
There are two stages to drawing a picture.
STAGE 1. Calculate the array of data points. Use "Data Points" menu.
STAGE 2. Render the data as a picture. Use "Picture" menu.
MENUS
*****
PROJECT:-
ABOUT: try it!
LOAD IFF: Loads a picture from disk. I put this in so that
you could see all of your creations without having
to exit the programme. You can't actually do anything
with the picture.
This is inactive during CALCULATION and RENDER.
SAVE IFF: Saves the current screen to disk. Make sure that
none of the message windows are open or they will
get saved too!
This is inactive during CALCULATION.
AND DISABLED IN THE DEM VERSION.
ADVERT: Try it!
IFSgen is an iterated function system generator. It
allows you to generate (and save) IFS codes and produce
pictures of self-similar objects (ferns, trees,
Sierpinski triangles etc). Fully driven by mouse and
menus. The mouse is used to define and manipulate the
images. You can save IFS data and IFF picture files
of your creations. Many example pictures and IFS code
files are included
IFSgenV2.0 is shareware and probably requires 1Meg.
If you want a demo version of it, all you have to do is
write and send me a disk and enough to cover the postage.
or $20 for the full version (including source).
QUIT: say bye-bye.
DATA POINTS:-
All items in this menu are to do with generating the array of data
points (STAGE 1). (If you haven't got any points then you don't get
much of a picture!)
The data points are stored in bank 7, To fill this bank with data
select CALCULATE from the DATA POINTS menu. This will generate a
set of points using the data in the parameters table. A default
set of parameters based on a random number seed of 42 is provided
so that new users can easily generate a set of points to play with.
PARAMETERS: This brings up a table of parameters which you can
change to get different sets of data points.
RESOLUTION: There are four calculation resolutions
1: Calculates every point in the 256X256 array
2: Calculates every second point.
4: Calculates every fourth point.
8: Calculates every eighth point.
The more points you get, the better the resolution of
final picture, but more points take longer.
The following are typical calculation times when running
from AMOS. The compiled version completes these routines
about 3╜ times as fast.
Resolution Time Available plotting resolutions
1 5 min. 1, 2, 4, 8, 16
2 1 min. 15 sec. 2, 4, 8, 16
4 20 sec. 4, 8, 16
8 5 sec. 8, 16
EXTRA RANDOM: ON/OFF
If this is on it adds an extra random value to every point
after it has calculated the random midpoint displacement
(see "The science of fractal images", above)
When this is on it has one obvious effect (It takes about
twice as long to generate the points) and one not so
obvious effect (Without it you sometimes get rows of
mountain peaks in a straight line across your picture.
Turning it ON reduces the effect). The times above were
calculated with this OFF.
TO CHANGE VALUES IN THE DARK BROWN BOXES JUST CLICK ON THE BOX WITH
THE MOUSE AND START TYPING. DUE TO A SLIGHT PROBLEM WITH THE ROUTINE
WHICH HANDLES THE INPUT YOU MAY NOT ALWAYS GET EXACTLY WHAT YOU TYPED!
MAKE SURE THAT THE STUFF IN THE BOX IS CORRECT, (YOU CAN USE THE LEFT
AND RIGHT CURSORS AND THE DELETE BUTTON OR JUST TYPE OVER THE NUMBERS)
AND THEN PRESS RETURN WHEN IT IS OK.
FRACTAL PARAMETER: This changes the FRACTAL DIMENSION
of the data. The fractal dimension is equal to
3 - fractal parameter.
This controls the roughness of the surface. You should
normally set this to BETWEEN 0.5 and 1, although any numbers
BETWEEN 0 and 1 will do.
For a smoother surface set this close to 1, for a rough
surface set it a bit lower. Default is 0.85 which seems
to work fairly well for most scenes. If you are not
sure about this then try a few different values on
resolution 1.
SEED:
This seeds the random number generator. Change this
value to get different scenes.
***************************
By the way, if you have been playing around with the
AMOS random number generator and had trouble regenerating
the same sequence of random numbers from the same seed,
the following may be of interest.
If you use Randomize 42 (or any number) you should (according
to the manual) get the same set of random numbers each
time. In fact you get a different set (at least with
AMOS 1.21) every time, just as if you had used Randomize Timer.
If you want the same set each time you must use a negative
value for the Rnd function.
eg. Rnd (-10) generates a random number between 0 and 10 and
you will get the same series of numbers each time you randomize
with the same seed.
Rnd (10) will generate a random number between 0 and 10 but it
will be (truly?) random and does not seem to depend on the seed
value.
I hope this is of some use, it had me stumped for a while!
**************************
ALL DATA (3 buttons)
DEFAULT: Returns all settings to their default setting.
RESTORE: Returns all settings to what they were before
you started fiddling around with them after you
chose this menu item.
QUIT: Accepts what is in the boxes and returns you to
the main screen.
LOAD DATA: Loads a bank of data points (and the data parameters)
from disk. This is included to save you the trouble
of waiting 5-10 minutes (on highest resolution) for
the calculation, although with the compiled version
you may prefer not to waste the disk space.
All data files are suffixed with ".DATABK".
SAVE DATA: Saves a bank of data points (and the data parameters)
to disk.
DISABLED IN THE DEM VERSION.
CALCULATE: Calculates the data points using the parameters you
specified. If you have not specified then the default
values will be used.
STOP CALC: Stops the calculation. This could leave you with a
data bank which contains a mixture of two sets of
data, so either recalculate or load another bank
before you render it. Naturally you can only use
this while you are CALCULATING and all other menu
items will be disabled while you are calculating.
PICTURE MENU:
All items in this menu are to do with rendering the picture (STAGE 2)
PARAMETERS: Brings up a screen of parameters which you can change.
Most data is displayed in brown boxes which can be
changed in the same way as the data points parameters.
RESOLUTION: This is similar to resolution of Data Points,
except that there is a 16 button which plots
every 16th point.
As before small numbers are high resolution.
You cannot plot in a higher resolution than the
resolution which the data was generated in.
Eg. if you generated the data at resolution
4 you can only render in 4, 8 or 16. The
other buttons (1 and 2) will be inactive.
The main purpose of this is so that you can
preview a scene quickly.
Typical scene rendering times (using the
default data and plotting parameters) and running
from AMOS are shown below. The Compiled version takes
about 60% of these times for the rendering. The speed
improvement is not much because most of the time is
taken in the graphics operations (drawing the
polygons) and AMOS is already pretty quick at this.
Resolution Time
1 35 min.
2 9 min.
4 2.5 min.
8 43 sec.
16 13 sec.
VIEW: The 3 parameters in this box define the way the picture
is viewed.
Elev. Angle: angle of elevation which you view the scene
from. Must be between 0 (low view) and
90 (viewed from directly overhead).
The actual appearance also depends on the
height scale used.
Horizon: This is the level of the horizon in pixels
measured down from the top of the screen,
assuming you are looking at it from zero
elevation. Higher elevation angles push the
horizon higher up, and the perspective
control has a small effect at high elevations
as well.
Change this to move the picture up and down
the screen, the smaller the number the
higher the picture. Making this larger can
stop the picture finishing before it reaches
the bottom of the screen.
Perspective: As the picture is generated the points
nearest the front are made larger (just
like in real life). This parameter
controls how much larger. The smaller the
number the larger the effect. Typical
values lie between 100 and 999.
SCALING: The first 3 define the scaling factors used in each
direction.
Horizontal: Magnifies the picture horizontally.
Any number less than about 1.3 will not
fill the screen.
Vertical: Magnifies the picture vertically. Make this
a little bigger if the picture doesn't
reach the bottom of the screen.
Both Horizontal and Vertical should be above about
1.3 (or else you will get blank bits at the edges)
but can get bigger.
Height: changes the height of the mountains.
Typically 50(low) - 300(high). This
Actually determines the maximum THEORETICAL
height which could be plotted. In most cases
the highest height actually plotted will be
less than this because your data points
generated in stage 1 will often not reach
the maximum possible level. Anyway if you
want taller mountains make this bigger.
Power: all heights are raised to this power (i.e. h^power)
before plotting. This is used to simulate erosion
by making the mountains steeper than the
valleys. Higher numbers increase this effect.
Power must be a whole number >=1, although numbers
much bigger than 3 will result in some fairly
steep mountains (depending on the height
parameter). Usually you will leave this on 3.
LEVEL BLEND: These define the level at which trees give way
to rocks and rocks to snow and how smooth the
transition is.
LEVELS: Define the levels of the different colours used.
These should be used in conjunction with the Height
parameter. I.E. if height is 50 there is little
point in setting the sea level at 100 because
all of the points would be below sea level.
Sea: Sets the sea level. Anything below this height
will be plotted in blue, the shade depending on
the depth of the water. If you don't want to see
any sea then make this low. (i.e. close to zero)
Tree: Sets the maximum possible tree level, any point
above this will be rendered as rocks or snow.
If you don't want trees then set this below sea
level.
If you want the trees to go right up to the snow
then set this greater than or equal to the snow level.
Snow: Sets the snow level, any point above this will be
rendered as snow.
If you don't want snow then make this bigger than
height.
BLEND: The two blend boxes to the right of the tree and
snow level boxes define how quickly the tree and
snow will change to rock. Numbers close to zero
make the transition sharper (Zero will result in
a horizontal line defining the snow and tree
levels) while higher numbers (eg 4 or 5) will
blend the change over a much larger range.
If the tree level is above the snow level (so that
there are no rocks) then snow will blend into trees,
otherwise both snow and trees will blend into rocks.
MAX. ANGLES: These parameters set the maximum steepness for
sand, trees and snow. Any slope steeper than
this will be rendered as a rock. This is to
simulate the fact that snow, sand (and trees)
don't stick to very steep surfaces. Each is
an angle (between 0 and 90) which measures
the maximum possible slope for SAND, TREES
and SNOW. (Experiment for best effect)
LIGHT SOURCE: These specify the position of the light source
(i.e. the sun).
Azim: Measures the azimuth (horizontal) angle of
the sun (any number from 0 to 360). 0 is left.
Some special cases:-
0 or 360 Light from left
90 Light from back
180 Light from right
270 light from front
(Yes I know that this is backwards (anticlockwise), but
if you knew that then you can probably work out why!)
Elev: Measures the elevation of the sun in degrees
between 0 (low) and 90 (high).
DEFAULT, RESTORE AND QUIT BUTTONS work the same way as those in
the data menu.
LOAD DATA: loads all the Rendering Data (the stuff in the picture
parameters), the Data points Data (seed, resolution
Extra random) and the palette from disk.
SAVE DATA: saves all the Rendering Data (the stuff in the picture
parameters), and Data points data (seed, resolution
Extra random) and the palette to disk.
DISABLED IN THE DEM VERSION.
All Rendering Data files are suffixed with .REND, these
files are just sequential data files.
RENDER 2D renders a 2 dimensional (contour map) picture of the data.
Resolutions of 1 are plotted the same as resolutions of 2
because a full size resolution 1 picture will not quite
fit on the screen and it takes ages!
This is included so that you can get a rough idea of
your scene before you render it. The view is from the
middle of the lowest side looking towards the top.
The 3D picture will not include the left and right edges
of the front because of the perspective. If you want more
of the front in then set the PERSPECTIVE PARAMETER to a
higher number.
Blue areas are below sea level, the darker blue represents
deeper water.
Areas above sea level are rendered in shades of green,
brown and grey/white. Dark green is the lowest and
white the highest. In V1.11 I have made no attempt to show
tree and snow levels on the 2d plot.
The flashing lines show approximately how much will be
visible for the parameter settings you have chosen.
RENDER 3D Renders a 3 dimensional image using the parameters set up
in the picture parameter screen and the data that is
currently in the memory. If you haven't generated any data
(Stage 1) then you will not get much of a picture.
STOP REND Stops the rendering (2D or 3D). Naturally this is inactive
unless you are already rendering. You cannot use any of
the other items in the picture menu (except PALETTE) or
any of the items in the DATA POINTS menu or the LOAD IFF
menu item while the picture is rendering.
PALETTE Brings up a palette tool in case you don't like the
default colours. This is a scaled down version of a
general palette tool which I wrote (in AMOS), called Gumby's
Palette V1.0. You will get the full procedure (which you can
use in your own AMOS programmes) when you register (if you
want it: please ask if you do).
The landscape version of this procedure supports the following features.
DRAGBAR:
This is the message (Gumby's Palette) at the top of the screen.
Hold left mouse button down while you are over this and drag the
palette screen up and down your screen.
ABOUT:
Work this out for yourself!
RGB sliders: These work in the usual way, just click on the slider
with the left mouse button and drag it along, or just click on the
spot you want it to go to.
Up to 32 colours are displayed in little boxes on the right of the
screen. You can select two of these at any time.
Left mouse button selects the CURRENT colour. This will be changed
by moving the slider bars.
Right mouse button selects the TO colour. This is used by COPY,
SPREAD and CYCLE, to copy, spread or cycle from the current colour
to the TO colour, and also by SWAP to swap the current colour with
the TO colour.
The TO and CURRENT colours are outlined in different colours so that
you can see them. It is possible that the colours used by these
outlines are hard to see because they are the same or similar
to the colour used for the background of the box.
COLOUR Buttons:
There are 5 of these COPY, SWAP, CYCLE, SPREAD and SKIP.
These are selected with the left (and sometimes right) mouse button.
COPY and SWAP are explained above.
CYCLE. Press Left mouse button to cycle forward and right mouse
button to cycle backwards. Cycles all colours between TO and FROM.
SPREAD spreads the colour from the current colour to the TO colour
and works in conjunction with the SKIP button.
If SKIP is 1 then the spread will skip 1 colour in between each
one it spreads. Best way is to try it! I put this in because I
thought it might be useful in a Mandelbrot type programme.
SKIP can be any number you like providing it is between 0 and 9.
I don't think it would be a very good idea to set it to a number
greater than the number of colours between the two colours you are
spreading between. This could cause some unpredictable results.
Usually you will leave this set to zero.
PALLETE BUTTONS. There are three of these in the original procedure
They are SPR, ICON, and DEF. (ICON is new in v1.1)
SPR performs a Get Sprite Palette when you click it.
The procedure checks to see if there is anything in the sprite
bank (bank 1) and if you have no sprites then this button will be
inactive. INACTIVE IN LANDSCAPE
ICON performs a Get Icon Palette when you click it.
The procedure checks to see if there is anything in the icon bank
(bank 2) and will render this button inactive if the bank is empty.
INACTIVE IN LANDSCAPE
DEF Left mouse
returns all colours to the programme's default colours.
DEF right mouse
Returns to the AMOS default colours (which are not much use in landscape!)
Exit CANCEL cancels all changes and returns you to your programme.
Exit ACCEPT keeps all changes and returns you to your programme.
OTHER FEATURES OF LANDSCAPE
***************************
DRAGBAR. If you are not rendering, then the entire screen can be
dragged up and down by holding down the left mouse button.
This feature is inactive during all other menu operations,
and only works on the screen which shows the 2D and 3D plots.
This has been included because some of the picture is often
generated off the monitor screen (the actual screen used
is 320 pixels high), and I wanted to see what I had generated
without moving the horizon and regenerating the whole thing
again. When you let go of the mouse it will return to its
usual position.
TROUBLESHOOTING
***************
If you want to copy a palette from one scene to another then save the
source scene as an IFF file and load it into your new scene, then
regenerate.
If your picture is all sea, then increase the height and/or lower the
sea level. If this doesn't help it may be because you have been a silly
sod and forgotten to generate any data points!
If all of your mountains are very pointy then decrease the height and/or
the POWER parameters.
(You may also have to decrease the sea level to compensate.)
If the sides of your mountains are very smooth and you want to make them
rougher then regenerate the data points using a different Fractal
Parameter. Make it smaller for rougher terrain.
While you are trying to adjust everything for a scene set the resolution
on 8 or 16 and render in 2D. When this looks as if it might make
something interesting then try it on resolution 16 with 3D.
This will allow you to adjust the horizon to get the scene to fill the
screen. Use the dragbar to see what you are missing. When it all looks
about right then try it on a finer resolution.
Sometimes you will generate something which has very high mountains
at the front which block out the rest of the picture. These should
show up if you render in 2D first. At present the only way around this
(assuming you don't like it) is to regenerate the data using a different
seed. I hope to do something about this in a later version.
############
BUGS
############
None. (That I know of!) All Bug reports and/or suggestions should be
sent to the above address.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I hope you find this programme and/or its procedures useful and that
you bother to take the time to write back. If you have written anything
that you would like to send me, please feel free to do so.
BUT PLEASE DON'T SEND ANY SILLY SCROLLY DEMOS, MEGADEMOS, ULTRADEMOS,
ULTRAMEGADEMOS, MEGAULTRADEMOS, ULTRACOSMICDEMOS, ALPHAGAMMAOMEGADEMOS,
ZAPHODEFFINGBEEBLEBROXDEMOS OR ANYTHING ELSE VAGUELY RESEMBLING A DEMO!
AMOS IS A BRILLIANT LANGUAGE SO HOW ABOUT USING IT TO WRITE SOMETHING
REALLY USEFUL?
Happy (real) programming.
Andrew.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FUTURE VERSIONS
I hope to add the facility to put in roads, lakes and rivers and also to
make a few waves around the coastlines. Some clouds and haze if I can
make them look good on a lowres screen, (which might be a bit easier in
interlace now that I have the amos upgrade that handles it) if not I
will try to adapt to hires but this will probably mean slower rendering
times and certainly less colours.
(Unless I get really ambitious and try a HAM version!)
Some other possibilities include:
* Rotating the map so that you can view the scene from a different
position. (Maybe even the facility to view from any position.)
* Flipping the map so that the highest points become low points and the
low points high points.
* Mouse control of the perspective by changing it on the 2D map.
* Interlace option.
* Better interface for controlling the parameters.
At least one scenery programme that I have heard of generates music
while it is rendering. I am not quite sure what the point is but if
anyone would like it let me know and I will see what I can do.
You tell me, if I have enough time and memory I will do it.