1. ## A terrain patch

Hi there...

i'm in trouble here, i've been trying and trying to draw a terrain or surface(whatever). But i dont know how. have to put in matrix ???
how can i do that ???
Somebody can give me a short and bull's eye explanation about ??
I ll really appreciate...

thanks a lot !!!

2. ## Re: A terrain patch

One way is to store your terrain data in a heightmap array - say terrain[x,z], and then step through this drawing each quad (to start with, triangle strips are better) one by one. eg.

for (x=0;x<max_x;x++)
{
for (z=0;z<max_z;z++)
{
glVertex3f(x,terrain[x,z],z);
glVertex3f(x+1,terrain[x+1,z],z);
glVertex3f(x,terrain[x,z+1],z+1);
glVertex3f(x+1,terrain[x+1,z+1],z+1);
}
}
glEnd();

This is only basic of course! You'll still have to include texture co-ords and normals, not to mention only drawing the quads or tri's that are within your field of vision.. But I hope that helps to get you started!

- Phrantik

3. ## Re: A terrain patch

yeah Phrantik...
but i have to a put some values in terrain array.

and what kind of values ??? more than 1 ???
less than 1 ???

and i get a lot tri's on the surface, how can i make it homogeneous...

sorry the many question, man...

thnx

4. ## Re: A terrain patch

Well, I usually use a greyscale bitmap to represent my terrains - that is, values between 0 and 255. You can use any values however, and then use glScale to adjust it.
The example I gave (using quads) should give you a continuous surface, but if you use Triangles, you're right, it will have holes all over the place! Off the top of my head try this for TRIANGLE_STRIP terrain..

glBegin(GL_TRIANGLE_STRIP);
- x loop -
- z loop -
glVertex3f(x,terrain[x,z],z);
glVertex3f(x,terrain[x,z+1],z+1);
glVertex3f(x+1,terrain[x+1,z],z);
glVertex3f(x+1,terrain[x+1,z+1],z+1);
- end z loop -
- end x loop -
glEnd();

Hope this helps! =)

- Phrantik

5. ## Re: A terrain patch

Sorry.. i f@#\$'d up!

The glBegin should go between the x loop and the z loop and the glEnd between the end of the x loop and the end of the z. This way you get long strips of triangles running in the z direction.

- Phrantik

6. ## Re: A terrain patch

Geee...
you're right !!!
Thanks for attention.

But man, i have another question:
I usually work with Delphi5. and i dont wanna jump to C. i mean, i know a bit of C and like Delphi a lot.
Is Delphi a good opengl plattaform ???
can i continue with delphi and write a nice engine ???

7. ## Re: A terrain patch

Personally, I much prefer Delphi 5! It's what I used to code my engine, and even though it's still in early development, it's getting there!! I've heard that C++ executes OpenGL faster than Delphi, which I have no doubt is true, but it's never made me want to switch. The point is, you can write a great engine in ANY language, you're still using OpenGL - which is a great API. The speed may not be as fast as commercial engines, but you have to work out what matters most to you - a few less frames per second or a finished engine!

- Phrantik

8. ## Re: A terrain patch

Yeah..

So, can you provide me some piece of your code, man ?
Just to take a look, make some step by step...

I ll not copy anything, just to get a look how you draw each object every frame.
I ll really appreciate that.

Thanks....

9. ## Re: A terrain patch

Sure.. give me your email address and i'll send you the terrain rendering code.. I'll warn you though, don't expect to find much if you havn't understood the code I posted above, it's basically the same thing!!

- Phrantik

10. ## Re: A terrain patch

Thanks Phrantik..
my mail is guivieira@brfree.com.br

if it's possible send another topic codes that you consider its hard to understood.
)

anyway thanks..
[]'s

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•