Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    215641

Butterfly #229

Sign in to follow this  
Mushu

59 views

So, I've been working on different methods of loading/generating terrain, and so far I've got the 3 basic ones:

generatePlain - essentially creates a grid with set y value
loadHeightmap - loads data from a *.bmp heightmap
generateFromFunc - sweetness that you can pass any function to

For the project I'm working on, most of the terrain will be procedurally generated, so I'll probably end up using the last one the most often. Here's a sample:




// y-generation func
float sine(int x, int z) {
return sin(x) + sin(z); }

// function prototype to generate the terrain
void cOGLTerrain::generateFromFunc(cCallback2_* func, GLint x, GLint z,
GLfloat w, GLfloat h, GLfloat xOff=0,
GLfloat yOff=0, GLfloat zOff=0)

// actual call which generates above terrain
hills.generateFromFunc(new cCallback2
(this,sine),30,30,1,1,-12.5f,-1.1f,-20.0f);

// woot, templated callbacks are sexy :D

Now to correct the normal generation :/
Sign in to follow this  


4 Comments


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now