I'm currently working on a 3D PC game (written in C++ and DirectX 9.0) and I'm trying to find the best way to store level data in the memory.

The game's action takes place under the ground, so there's always a ceiling above the player. The ground is rather bumpy and there are things like stalagmites present at all times. Levels are small-ish in size and mostly look like corridors. Here are the options that I've managed to find so far:

Two height maps stored on the hard drive as either a bitmap or binary/text file. One height map for the ceiling (top), one for the ground.


A single 3D mesh in some 3D model format (say, .fbx, .x, .obj whatever).

How should I approach level data storage? What would my best option be, performance-wise speaking? I'm also having some trouble when it comes to texturing a level loaded via a height map; using a 3D model makes texturing a breeze.



3 Answers 3


Performance-wise, both options should be equivalent since everything will be converted to a model sooner or later.

+Easy to store and edit
+Easy to calculate texture coordinates if they're not precalculated
-Poor texturing on steep surfaces
-Needs companion models for better detail
-Does not allow overlapping terrain (no overhangs).

+More control over horizontal displacement
+Overlapping terrain is possible
+Maximum control over textures
-Collision is a bit more complicated
-Could use up a bit more memory on disk

In my experience, it's best to use a somewhat flat heightmap for the base terrain and the use models for things like the stalagmites, and you can even use repeating models for such objects (to save memory).

Of course, you could use a vector field, but that's basically a model with easier texturing.


It might help if you told us what genre the game is, what the camera sees, etc. I assume you're talking about an FPS but I'm not sure.

Anyway, here's a link to a talk about the terrain in Halo Wars that I found interesting and may give you ideas: http://www.gdcvault.com/play/1277/HALO-WARS-The-Terrain-of . It deals with some of the issues and possible solutions you mentioned.


You don't necessarily have to choose one over the other, both can be effective, and there's no reason you can't combine the two.

If you use heightmaps, I would personally choose a bitmap format though. Directx should be able to do all the bitmap loading for you and turn it into a resource you can use. If you use a plain text file, you'll have to parse it yourself. This of course gives you some more freedom in interpreting the file, and might be a good starting point to allow easier experimentation.

One thing to consider though is that a heightmap will leave you with a fixed resolution, so the stalagmites you mention might be hard to represent well, unless you increase the pixel density of the entire map.

Generally, I'd say a heightmap is an effective means to store your terrain, but adding detail like stalagmites would be a lot more flexible with models.


You must log in to answer this question.