View Full Version : A terrain patch
06-25-2000, 12:43 PM
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 !!!
06-25-2000, 01:17 PM
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.
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!
06-25-2000, 04:55 PM
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...
06-25-2000, 06:31 PM
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..
- x loop -
- z loop -
- end z loop -
- end x loop -
Hope this helps! =)
06-25-2000, 06:35 PM
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.
06-25-2000, 06:44 PM
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 ???
06-25-2000, 07:09 PM
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!
06-26-2000, 02:55 AM
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.
06-26-2000, 04:41 PM
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!!
my mail is firstname.lastname@example.org
if it's possible send another topic codes that you consider its hard to understood.
06-26-2000, 06:03 PM
>if it's possible send another topic codes >that you consider its hard to understood.
Don't forget that 3D programming, as a whole, is hard to understand! I think that looking over others people's source is important, sure. But nowhere near as important as writing your own, making mistakes, and then slowly learning enough from documentation to fix them. It's a long process.. after all, my limited knowledge came from working through Nehe's tuts and then reading the redbook about 50 times! I'm sure you can understand that I get a little frustrated when people expect to learn everything staright away without putting in the hard work.. OK, i've had my winge.. =)
06-26-2000, 06:37 PM
I think as you think. When i said to send me others topics thats because i'm tired of reading and reading the same docs as you.
i've been proggraming on a four or five years ago and the way that i learned: hard work, alone, nights and nights but i always reached there. And opengl isn't goind in the same way. So the last alternative are asking for others codes. Just to put my mind in movement, understand me ???
anyway again, thanks for your attention
06-27-2000, 04:33 PM
Thanks Phrantik for the code sample.
I still don't have time to try it.
but i ll test it as fast i could.
[This message has been edited by Gelero (edited 06-28-2000).]
06-28-2000, 12:58 AM
you are using delphi as me guys http://www.opengl.org/discussion_boards/ubb/smile.gif)
i have coded all of libraries i want to code but i can't do collision detection because i have no think http://www.opengl.org/discussion_boards/ubb/smile.gif)
Hım i want to find the object which hits the others and object with being hit , hımmm?
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.