Terrain Generations question...

Started by
6 comments, last by James Trotter 18 years, 5 months ago
Do games generate terrain at game runtime, or is it something done in the modeling phase to give the developer a start of making a map? If done at runtime I do not understand how buildings and other environment objects could be accuratley positioned and integrated into the terrain, since things like buildings need surfaces that conform to the bottom of the object. the only workaround i can think of is to extend the bottom of the building so it protrudes though the terrain on all sides, but this doesnt sound quite right. thanks, -sd
Advertisement
Quote:the only workaround i can think of is to extend the bottom of the building so it protrudes though the terrain on all sides, but this doesnt sound quite right.


That's the way many people do it. Simple, and it works.

j
Terrains are usually models. You can do it at runtime though, and buildings usually protrude through the terrain anyway.
Graphics make the game! 8-)
Whether it's generated randomly at runtime or not depends on the game. But I've seen it done before, usually using Perlin noise to generate a heightmap.

I've also seen it done with buildings and such placed on the terrain. Now, I can't quite remember where, or how, so this isn't really helping much. I'm pretty sure you can manipulate the heightmap after it's been generated and create some flat spaces here and there, wherever you want your buildings. Where you have your buildings, would of course be random also.

Or you could a kind of hybrid approach, like in Diablo II. You would start in town, and this place would always be the same. Anything outside town was randomly generated. So if you were to start a new game with a new character, then everything outside town would look different. At least I think this is right!

Hope this helps.
Warcraft III does it that way, as far as I can remember. The base of the models are tall. They just sink the excess into the ground, and then apply a texture on the surrounding terrain to make it look good.
In unreal games, I belive they prestore the terrain after its generated, as you can see by just opening a map in ued. I think I will take this approach. I dont see any memory improvments by generating at runtime, only that you can make the terrain dynamic (not something I currently need).

I had another thought tho, If your engine generates terrain based on heightmaps, you may as well go one step further and make it more object placement friendly...

- for all environment objects on terrain...
- get object placement on x,z plane ( just get a bounding plane of some sort )
- get average y heights for terrain on that bounding plane
- reset all y heights in bounding plane to the average // flatten the terrain under the object
- set building.y = plane.y + building.offset // depending on where the local position of the object is

this will make the surface flat, but this assumes the bottom of your object is flat, so mabey alter one of the steps...

not quite shure how it would work out, but Im thinking after you flatten the terrain under the object, you could get the y heights of the object on it's bottom and offset the terrain by the same amount. this way the terrain will conform to the model, and it should fit like a plug :) but again, not shure how that would work out since the verticies of the model would not line up with the verticies of the terrain, but you could do some sort of clustering algorithm?

thx again for the replies,
-sd
Might be a nice proof of concept programming project, but probably not practical for the majority of games. The algorithms to work the terrain to find flat areas to place objects and/or adjust the terrain heights are complex and probably cumbersome. I tried this once with my terrain generator. I wanted to put a river through it, but never completed it. A nice challenge, but I doubt people are going to be happy waiting for these things to chug away tweaking the terrain and placing objects etc. That's why games usually come with some form of editor so you can build all of this beforehand and simply load it up a game play time.

hth
F451
Alright, I went looking a little, and I remember seeing this article, which is a somewhat related problem. And also some interesting, related stuff in this journal.

Hope this helps.

This topic is closed to new replies.

Advertisement