views:

311

answers:

4

Hi Everyone,
I'm in the process of designing an rpg and I have run into a small snag. I'm not sure what to use for my world maps. I've looked at different formats over the past week and have determined that there aren't any maps (that I can find...) that are good for an outdoor environment. I found that .bsp maps (quake 4 or doom 3) would be good for an indoor setting, but not very good for outdoor settings because of the way they are done.

I'm trying to find something that would allow me to make huge outdoor maps, much like oblivion or morrowind. Granted I may not use the maps to that extreme, its just nice to have the room for expansion if I need it.

Thanks, Robbie

+5  A: 

Outdoor environments are typically done using terrain height maps. It's basically a giant grid with height info on each cell. Also each cell contains info about the texture(s) to be used.

You can create these maps using fractal and perlin noise based terrain generators

Toad
Ah ok. I had never thought about doing it that way. I had always thought they were done in blender or some other 3d modeling program and were then loaded into the game. Now how would you put things like a house or trees on that map? Just make the models separately, load them, and place them on the map wherever you want?
Robbie
Pretty much, yep.
Dave Sherohman
Huh... That's kinda cool.
Robbie
+1  A: 

There are many ways to implement game worlds maps.
Anyway, for huge maps check out Spatial indexes, and specifically the Quadtrees.

Nick D
+3  A: 

This article introduces the use of quadtrees for terrain storage, which I believe are commonly used. Basically, they're like the BSP trees used in Quake, but better suited for storing heightmaps.

unwind
The only thing I don't quite get is how to associate the graphics information with the quadtree. Say I have a 16x16 bmp file that I'm using as the map, with the smallest node a 1x1 square. How would I go about drawing the map with the quadtree? Or would I not do it like that and there is another way to do it?
Robbie
@Robbie: I think the point of using a quadtree for storing a heightmap is more apparent when you want to store actual 3D vertex data, generated from the heightmap. You then use the quadtree to organize the data hierarchically. See http://www.gamedev.net/community/forums/topic.asp?topic_id=410611 for more details, for instance.
unwind
+1  A: 

I think he's looking for a way to save and load maps from a file, not a way to store them in memory. (Or maybe I misunderstood ?)

IMHO there are four paths to handle this problem.


Extremum: Create your own format

You can create you own file format. The easiest way would be to choose a widely used and extensible file format (such as XML) since you'll find tons of parsers freely available on internet. (head to applied-mathematics.net for simple yet complete XML parser).

The problem here is that you'll have to create your own map editor. No doubt this is the "best" way if you want to learn tons of things, and have a clean format. But you also have to consider the time that you'll need to spend creating all these tools.

Extremum: Use the format of an other game/tool

You can also choose to use the file format of an existing game, and retro engineer it (or simply use the format of an open source game, such as Quake).

The problem here is that you'll inherit from the limitations of the format you chose. But the development time is quite reduced, you only need to find a way to load these formats.

Tradeoff 1: Decouple geometry from meta data

You can also choose to pick the things you need from an existing format, and to store your meta data elsewhere.

For instance you could use create a format that would look like:

<?xml version="1.0" encoding="UTF-8"?>
<map>
  <name>MyMap</map>
  <geometry type="bsp">my_map.bsp</geometry>
  <spawn id="1">
    <monster type="1" spread="5" />
  </spawn>
</map>

Here you have the best from the two worlds. You can design you map in any .bsp editor (3DSmax, Blender), and store the data you need in XML.

Middle 2: Adapt other's formats to your needs

The idea here is just to create your own unified format, and create exporters for widely used editors. You can for example write exporter scripts for Blender, that would generate files for you own format.


Just some more tips if I misunderstood and you were looking for memory storage of your maps. (In case just ask and i will complete my answer :))

  • Look for Quad/Octrees. It's a way to cut you map into quads/cubes. Then you'll be able to implement fast search in these structures, and so display only viewable parts of the maps, LOD, etc..
  • Fasten map loading by choosing a file format close to the memory layout of your map.
  • Combine multiple map-storing paradigms. Heightmaps are nice for bigs outdoor maps, but are very limited (espacially for multilevel maps). You could use heightmaps for the floor, and store rocks/flowers is quadtrees, etc.
Aurélien Vallée