Page 2 of 2

Posted: Thu Oct 13, 2005 2:03 pm
by -_-
wif this "random terrain generator" is it possible to set max heights?

Posted: Sat Oct 22, 2005 1:10 pm
by Riley75
I've got nice curved uniform hills working now...

This terrain (click to view) contains two hills, where one overlaps the other. You can see what happens when two hills intersect each other. Each was created with a single API call "raiseHill"... This is the main program:

Code: Select all

#include <stdio.h>
#include <math.h>
#include "r3-swbf-terrain.hpp"

int main() {
	
	const char* filename = "C:\\Games\\BFBuilder\\Datatst1\\Worlds\\tst1\\World3\\tst3.ter";
	
	R3BFTerrain* terrain = NULL;
	R3BFEllipsoidHill* hill;
	int loop;
	try {
		terrain = new R3BFTerrain(filename);
		// Clear current terrain
		terrain->rectSetHeight(-1000, -1000, 1000, 1000, 0.0);
		terrain->rectSetColor(-1000, -1000, 1000, 1000, 0xFF999999);
		terrain->rectSetTextureAlpha(-1000, -1000, 1000, 1000, 0, 255);
		for ( loop = 1; loop < 16; loop++ ) {
			terrain->rectSetTextureAlpha(-1000, -1000, 1000, 1000, loop, 0);
		}
		// Paint two hills (the second will overlap the first)
		// Note: All measurements are in meters, where 0.0 is map center
		printf("Starting to paint hills...\n");
		hill = new R3BFEllipsoidHill(100, 0, 50); // Width, perimeter height, center height
		hill->raiseHill(terrain, -50.0, -100.0, 75.0, 150.0); // Corner points (x1, y1) to (x2, y2)
		hill->raiseHill(terrain, -75.0, 10.0, 20.0, -40.0);
		printf("Finished painting hills...\n");
		delete hill;
		terrain->save(filename);
	} catch ( IOException e ) {
		printf("IOException occurred: %s\n", e.getErrorString());
	}
	
	if ( terrain != NULL ) delete terrain;
	
}