Archived

This topic is now archived and is closed to further replies.

Jonbca

Terrain problems

Recommended Posts

I''m working on a terrain engine (for a physics project). I''m using triangle strips for each row of the terrain. All data is stored in a single array (ie adjacent row''s data bumps up against each other). I''m getting an anomaly when rendering however. What appears to happen is that there is a gap between each row of triangles. This leaves strips of empty space across my entire ground. This isn''t exactly the look I was going for, so any help would be greatly appreciated. This is the rendering code for this section:
int height = ft.getHeight();  // really is depth
int width = ft.getWidth();
float[] surface = ft.getSurface();  // terrain data

gl.translatef(-100.0f, -150.0f, -200.0f);

for (y = 0; y < height - 1; y++) {         //  0--2--4 
  gl.begin(GL.TRIANGLE_STRIP);             //  | /| /|
  for (x = 0; x < width; x++) {            //  1--3--5
    gl.vertex3f(x, surface[x + y * height], y);
    gl.vertex3f(x, surface[x + (y + 1) * height], y);
  }
  gl.end();
}
 

Share this post


Link to post
Share on other sites