Generate your own landscape Dean Cracknell serves up the second course of his three part fractals recipe. ihe Basic program that created the fractal landscape last month takes only a few minutes to calculate and plot the entire fractal. This phase in the creation of the Landscape Generator is replaced by a machine-code version that does the trick in a few seconds. The Machine Code Loader program (Program 1) loads and saves the machine code which, when installed by the Landscape Generator program, adds twelve new commands to Basic's vocabulary. These create the fractal data and generate random numbers for the fractal image. The fractal is now created in memory, rather than in the array ‘height', and this memory is between &8000 and &90FF. You can quickly test this machine code by typing the following at the keyboard: MEMORY &7FFF - reserve space LOAD “FRA-A.BIN”,&9100 - load M/ Code CALL &9100 - Log-on RSX's |WIPE - Clear Fractal Data MODE0: |FRACTAL,1 - Calculate and Plot Fractal This will produce the now familiar fractal contour map in the bottom left-hand comer of the screen. Entering: |WIPE: |FRACTAL,1 - Clear, Recalculate & Plot plots a new fractal over the first. Program 2 is the first instalment of the Landscape Generator program: type in this program and save it as “prog-1.bas” (part 2 will be listed next month). This will run perfectly as it stands, but does not perform the 3-D image projection (yet). This is an expansion of last month's program and introduces a keyboard scan loop for changing certain parameters around the system. The keyboard options so far are as follows: [cursors-keys]: Move over the landscape, [SHIFT] will step 10 and [CONTROL] steps 30. [U] and [D]: Move up and down, [SHIFT] moves 10 and [CONTROL] moves 100. [A]: Switches between auto and manual elevation. In auto, the elevation is set to 2 units above the surrounding landscape. [U] and [D] will turn off auto. [S] and [I]: These keys add 1 to the two seed values; shifting the keys subtracts 1. [N]: Turns cursor ON and OFF. [Q]: Quit. The screen area is divided into 3 sections: the main image area where the landscape will be projected; the contour map area; and the data area that displays some of the more relevant landscape data. The information shown in this last screen areas is as follows: - I: The Image Seed
- S: The Comer Seed These describe each landscape. Changing “1” affects the entire image, producing drastic changes in the landscape; “S” only alters the four comers', producing more subtle changes. In theory these two numbers can generate 17,592,186,044,416 different landscapes [i.e. 128 x 128 x 128 x 128 (comers) x 65536 (images)], but in order to allow the two seeds to be displayed, this total has been restricted to 1,000,000.
- L: Current Level
- E: Current Elevation “L” determines the resolution level that the projected image will have (from 2,8,16,32 or 64) “E” is the elevation of the viewer above (or below!) the landscape. In “AUTO” mode the “E” changes to and “A” and shows the average height of the surrounding cells.
- X: Current X-position Y: Current Y-position The following are for the image projection and will be covered in more detail next month.
- W: Wire, Solid or Mixed Drawing -mixed is wire-framed solid.
- C: Contour or Shaded Display.
- B: Show Below Sea Level, Draw Sea, or Fill Sea.
- Frame: Frame Number to save to Disc/Cassette.
- Time: The time taken to perform the option, in seconds.
If you wish to experiment with what we have so far, make a copy of the program and work on that, (you will need the unaltered version next month). Subroutine 5 from last month can be readily added for isometric projections; the 4 variables - tiltl, tilt2, tilt3 and tilt4 - will ‘tilt' the comers of the fractal. In the program these are preset to tip the landscape towards the viewer, but can be changed to alter the landscape to any angle. Setting other locations within the map, using :STORE,x,y,value, 1 will allow you to preset other parts of the landscape: for example, making all tilt variables zero and setting the centre to a value (eg :STORE,32,32,100,1) will create islands.The next instalment gets down to the nitty-gritty of 3-D image projection (you will not need the special red and blue glasses, it is not that kind of 3-D projection), and adds the finishing touches to the Landscape Generator.# ACU
|