Archived

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

Terrain problems

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

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 on other sites
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 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

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 13
• 14
• 9
• 9
• 9
• Forum Statistics

• Total Topics
632927
• Total Posts
3009242
• Who's Online (See full list)

There are no registered users currently online

×