making 3d landscapes

Member
Posts: 36
Joined: 2004.10
Post: #1
Hello,

i am trying to make a 3d game, at the moment i have an OBJ loader with loaded models in my opengl program. But i want to find a way to load in landscapes like terrain. I have heard of different ways to do it, such as in the opengl program with QUads and such, in a 3d modelling app and tehen loading it, and height maps.

thes 1st one with opengl commans would be really to hard to do, so i would rather not to do that. NOw i have 2 choices either the 3d modelling ap and loading it or height maps. WHich way is better?

and if any of you guys would be so kind to give me source code to loading such things please i would appreciate a lot.

thanks
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
Try loading a grayscale heightmap. I dont have code because ive never done it but its how bryce does terrain so its can produce good results.
3D models can have tunnels but heightmaps cant, so its up to you.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #3
It really depends on what your doing, what type of game is it? For something like a flight simulator a height map would be great (you might need a 16 bit one like I do for my new game), but for something with caves it would be horrible.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #4
If you want to send me a PM or email with your email address, I could send you my code for my heightmap engine. It uses 8bit grayscale images and turns them into rendered terrain. It's a little sketchy and the lighting still doesn't work (luckily you can turn it on and off), but it shows how to do heightfields. I used SDL and SDL_image for the app and image loading respectively just to let you know ahead of time so you can get them.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #5
Like everyone already said, it depends on if you *really* need features like caves or outcrops, but I think height field terrain is easier to understand and implement and is particularly well-suited to the amateur game developer's needs. It seems that most of the examples and tutorials out there assume height field terrain is being used. Unfortunately, it also seems that most of those examples and tutorials assume you want it to be procedurally generated, but whatever, they're still applicable. Another advantage to it is that it's easier to do collision detection with compared to free-form mesh terrain. CLOD (Continuous Level Of Detail) algorithms seem easier to implement as well, although I haven't tried any myself so I don't know for sure - I'd probably try geo-mip-mapping first if the need arises. Probably the biggest advantage to using height field terrain, IMHO, is that it is far easier to make an in-game editor for it so that your friends (and maybe even players) can help you make levels, rather than relying on some (possibly expensive) third-party external package.

There is a lot of info about terrain rendering at the Virtual Terrain Project.

Nick, I don't know what your issues are with your terrain lighting, but there was a recent article on gamedev.net that talks about some ways to do normal calculations for height field terrain. Maybe it might help?
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
I'm working on mixing my heightfield terrain with OBJ model based features. My plan is to have a "hole" in my heightfield which is stitched into a cave modeled in Wings3d. I've already got static geometry features added dynamically pretty well, but the stiching is going to be non-trivial.

Also, if you're worried about collision detection, just give ODE a shot. It's beautiful.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #7
TomorrowPlusX Wrote:Also, if you're worried about collision detection, just give ODE a shot. It's beautiful.
Excellent suggestion. Still, implementing ODE isn't quite as simple as interpolating a height from a grid position. But, since you mention it, I have a question. If ODE works so well with free-form mesh terrain, then why do you still use height-field at all? Why not just use free-form for everything and let ODE handle it? Maybe just because of the editing issues?
Quote this message in a reply
Member
Posts: 36
Joined: 2004.10
Post: #8
Hmm thanks for the replies you guys.

Nick im going to try to first make the levels in an OBj thng thne load it in and see if that works if it doest ill let you know about the height map code.

I also think i want tunnels and buildings so i dont know if height maps would work for me. Im making a 3d shooter.

thanks you guys
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #9
nahid Wrote:Hmm thanks for the replies you guys.

Nick im going to try to first make the levels in an OBj thng thne load it in and see if that works if it doest ill let you know about the height map code.

I also think i want tunnels and buildings so i dont know if height maps would work for me. Im making a 3d shooter.

thanks you guys
Sounds good. One thing you can consider if your level is going to be mainly outside, make all tunnels and buildings separate models and make a heightmap for the general ground. Battlefield 2 seems to use this technique (in fact, on low settings, you can see the LOD adjusting the ground as you move). I believe even the city areas (cement and stairs) are all part of their heightmap but I don't know for sure.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #10
AnotherJake Wrote:Nick, I don't know what your issues are with your terrain lighting, but there was a recent article on gamedev.net that talks about some ways to do normal calculations for height field terrain. Maybe it might help?
Yeah I read that article a while ago, but I just don't know why my code doesn't seem to like that. I can't quite remember but I think they used a one dimensional array where as I used a two dimensional array. That could be it. I may restructure my height map code a bit (so it uses dynamic memory when created) so I could just make a one dimensional array and give that article another try.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
AnotherJake Wrote:Excellent suggestion. Still, implementing ODE isn't quite as simple as interpolating a height from a grid position. But, since you mention it, I have a question. If ODE works so well with free-form mesh terrain, then why do you still use height-field at all? Why not just use free-form for everything and let ODE handle it? Maybe just because of the editing issues?

Bingo. Blender's really hard to learn, and Wings is pretty mediocre. I think the "stitching" approach is probably my best bet.
Quote this message in a reply
Post Reply