Posted: Thu Oct 13, 2005 2:03 pm
wif this "random terrain generator" is it possible to set max heights?
Get more from your games!
http://www.gametoast.com/
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;
}