damdoy / opengl_examples

Collection of examples for OpenGL: Perlin noise, ambient occlusion, shadow mapping, water reflection and others

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flat terrain in terrain_camera example

Mohammadreza99A opened this issue · comments

I am wondering how we can change the Terrain class in order to have a simple flat terrain which is at the bottom of the scene so we can place objects on it?

Hi,

It has been a while since i played around with this, but quickly looking at it, it seems to generate the random terrain heightmap by passing a function func to the method

void generate_heightmap( float (Terrain:: *func)(float, float), unsigned int grid_x, unsigned int grid_y)

In the example the function function_recurs_noise is passed which returns the heightmap for some sort of perlin noise.

There are few functions that could be passed to the generate_heightmap method such as function_sin which should return a 2d sine wave or function_flat which is a constant and should make a flat terrain

Hope this helps

That is it. Works like a charm. Thank you for your help and this awesome repository.