6

I want to make a simple 2d terrain with just a few bumps and height changes:

terrain with le car

I thought about just using random numbers to describe the height of a certain vertex, but I don't see how I can make one mesh from this. I'm looking for a way to find the vertex and indices buffers for the terrain.
How do I do this?

Community
  • 1
  • 1
user717572
  • 3,626
  • 7
  • 35
  • 60

1 Answers1

1

You could just use GL_POLYGON with a list of all the vertices with the first and last vertice below the view.

if you want to use a triangle mesh you'll have to create a point directly below each height point(out of view) then the pattern(for clockwise ordering) would be:

for (number of height points-1)
    //vertices
     vertice below height;
     height vertice;
     next_height vertice;

     next height vertice;
     vertice below next height;
     vertice below height;

then working out the indices depends on how you store the vertices, but there will be a similar pattern in the array.

Scott Logan
  • 1,518
  • 2
  • 17
  • 34