home *** CD-ROM | disk | FTP | other *** search
- Fractal Scenery
-
- by John Greening
-
-
- (The programs in this directory are my copyright but may be freely copied
- providing that it is not for profit and this file is included)
-
- There are several programs that draw fractal scenery using random numbers
- and produce views such as might be observed from an airplane. The user has
- little control over the finished product as that is largely conditioned by
- the random numbers used.
-
- The present programs are not like that. The views shown (at least those
- given as examples here) are scenes observed from ground level such as you
- might photograph on holiday. There are no random numbers that determine the
- shape of objects. The general layout is determined by your imagination, just
- like a painting, but most of the fine detail is filled in by the program,
- though again under your control.
-
- The heart of the program is PROCfractal which is used in the examples to
- draw mountains, glaciers, hills, rocks, reflections and foregrounds. It does
- this by defining these objects as one or more triangles which are then
- repeatedly broken up into smaller triangles with the midpoints of the sides
- being somewhat displaced at each subdivision - a technique first used to my
- knowledge by Carpenter in the USA.
-
- The first six parameters of PROCfractal are three pairs of numbers that
- define the co-ordinates of the corners of the triangle that is to be drawn.
- As it stands the corners are defined in the order bottom left, bottom right,
- top. This order can be changed but will then change the distorted shape of
- the resulting object. The next parameter is a number that determines the
- minimum size into which the triangle is broken up. It is based on the
- minimum size to which the difference in the x co-ordinates of the first two
- corners of the triangle should be reduced. You will almost certainly have to
- adjust this by trial to get the effect you want. The smaller you make this
- number the longer the object will take to be drawn. (If you change the order
- in which the corners of the triangle are defined it is just possible that
- the x co-ordinates of the first two points will be the same, or nearly so,
- and no matter what you set this parameter to PROCfractal will not run. If
- you run into trouble change either x1 or x2 in the first line of PROCfractal
- to x3). The program runs in a 256 colour mode and the final parameter gives
- the number of the basic colour (0 to 63) in which the object is to be drawn.
- The program automatically uses all four tints of this colour when it breaks
- up the object into tiny triangles.
-
- The program you write should define objects in the background first, then
- move to the middle distance before dealing with the foreground. PROCfractal
- contains a quantity "snowline" which has to be defined before PROCfractal is
- called. Parts of the object with a y co-ordinate greater than "snowline"
- will be drawn in shades of white. This is illustrated in the program
- "Glacier". If you do not want any snow make "snowline" greater than 1024.
-
- PROCfractal uses random numbers to determine the tint of the tiny triangles
- into which objects are broken up. If you wish to draw a perfect reflection
- of an object seed the random number generator before drawing the main object
- and then re-seed the random number generator with the same seed before
- drawing the reflection. This is illustrated in the program "Reflection". The
- same hint applies if you wish to ensure that your drawing is exactly the
- same each time the program is run.
-
- The program "Himalaya" shows how to incorporate a sprite into your drawing.
- In fact it is an application rather than a program and the sprite "Sherpa"
- is contained in the sub-directory.
-
- A further example of my fractal scenery, with a fractal tree in the
- foreground, appeared in RISC User vol.2 issue 3 p.6.
-
- In designing a scene positioning of objects can be critical. To help you in
- this I have included a transient utility, an assembled program "Grid", which
- draws a grid of lines at every 100 graphics units and also, except in
- two-colour modes which will not be of concern to you in the present context,
- at the intermediate 50 graphics units positions. This program has its own
- ReadGrid file.
-
- The other help you might need is in deciding the number of the colour to use
- for particular objects. I have written another transient utility "Cols" to
- be of assistance in this respect. It also has its own ReadCols file.
-
- John Greening
- 15 Pentland Crescent
- Edinburgh, EH10 6NS