• Advertisement

Archived

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

Terrain problems

This topic is 5314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Change in italics :

for (x = 0; x < width; x++)
{
gl.vertex3f(x, surface[x + y * height], y);
gl.vertex3f(x, surface[x + (y + 1) * height], y + 1 );
}

Share this post


Link to post
Share on other sites
That did it. Thanks a ton. Really explains why the gap got bigger over the length. Too bad I didn;t notice that earlier. Thanks again

Share this post


Link to post
Share on other sites

  • Advertisement