A Media Independant Mapfile Format

by Sal Ferro

One of the primary goals of the Worldforge project is to present the game world to a variety of clients. Clients are being engineered that can display a world in 2D, 3D, and even in a non-graphical text mode.

The Worldforge project is operating under the intent that it will exist independantly of gaming hardware. It is vital that a gaming system is designed that will outlive today's hardware, and that will be able to take advantage of tomorrow's, when the need arises.

So the problem has been presented. A text client uses words to 'render' the world, a 2D client uses tiles, and a 3D client uses polygons and meshes. The game world must be represented in a fashion that is not specific to any of the client types, but that encompasses all of them. All client types need to be able to extract the information from a single database, and convert the data to their native format for rendering.

Being a 3D client developer, and in need of such a format to continue development, I initiated a proposal for such a thing. Currently it carries the name 'MIM' meaning 'Media Independant Mapfile'. And that is basically what it attempts to do: represent a map of the game world in a media-independant fashion. To put it simply, the elements of the game world are stored in a general fashion... not so specific that it excludes any client types, but not so broad that it cannot represent game data accurately.

How does then MIM system work? Take the following into consideration. In a text client, this is how the world information could be represented:


"The world contains 3 continents, named A, B, and C. On continent A there exists three towns, 1, 2, and 3. In town 1, there exists much farm land, and a large lush forest to the north. However, to the east of town 1 is a winding path, made of dirt that extends deep into the horizon. In the opposite direction of the path, there is evident much swampland. A steamy mist arises from the swamp water. To the west of the swamp, air bubbles of unknown origin perk to the surface..."


If you were using a text client to play the game, this would be sufficient. You would know that a stroll down the path might be a better idea than a swim in the swamp... However, what could the graphical clients do with this information? Since each tree in the forest needs to be drawn, more information may be needed....

For example, Joe (in his 2d client) attempts to render the forest to the north with tree pictures. He could draw a hundred or so trees at random locations, and show them to the player. What would be displayed would be a 'forest' of sorts... and the 2d and text clients -could- possibly co-exist.

But things aren't so simple. Lets say, John comes along and wants to render a 'forest to the north' in his 3D client. Every one of his trees must be placed in the exact same position as with Joe's client... in order to render the same world. Would it be fair, if the players using Joe's client could walk through areas where John's client placed a tree? Also, how big is the forest? How many trees are in it? What kinds of trees are they? (Also, in reality computer's aren't smart enough to parse that kind of textual information :-) So things need to be tweaked a bit more.

Given a number to seed a random-number generation equation with, software applications can be made to generate a sequence of random numbers that match. So if Joe, and John seed this equation with '15' and ask the equation for 100 numbers... they will both recieve the exact same 100 numbers.

I wanted to take advantage of this in the MIM format. Using random number seeds, and coordinate information, you can describe an area of randomly occuring objects, without having to specify the coordinates for each individual object. Areas are described as polygons with every vertice specified. In addition, 'entities' are associated with every area, along with a random number seed, and a frequency number. So take the following for example:


Town 1's Forest:
Polygon Vertices: 0,0, 10, 23, 23, 40, 0, 6
Random # seed: 345

entity Oak_Tree
frequency 10%

entity Poison_Ivy
frequency 5%

(Note: This is simply an abstraction of MIM data, not the actual file-format)

We now know exactly the dimensions of the forest, and what is in it. All clients, as long as they use a similair random number generation equation, will generate trees at the exact same positions. All that is left to do, is decide what picture is used to display 'Oak_Tree' in the 2d client, and what 3d mesh is used to display it in the 3d client.

Since this is client-specific it is stored external to the MIM file. People could make up their own pictures to represent an 'Oak_Tree' and use those in their clients. Maybe when computers are fast enough... we could raytrace a photo-realistic Oak Tree at that exact position. Since we have described the world in a media-independant fashion, anything's possible. We are not restricted to any media, or media type.

So for every client, that client author will make a media-definition file.


Text client:
Looks_Simple: A tree
Looks_Detailed: The bark is rough. Thick, burly branches grow from a massive central trunk. The leaves flutter in the wind. (etc. etc.)
Tastes: Icky! Maybe if you were a chipmunk...
Sounds: You listen but the tree makes no noise.

2D client:
2d_picture: /2dmedia/pictures/vegetation/trees/oak_tree.pic

3d client:
3d_mesh: /3dmedia/meshes/vegetation/trees/oak_tree.mesh


Of course I have grossly over-simplified the situation, but in effect this is the heart of what I propose. Many may be sceptical as to whether this is possible, as was I when I had begun implementing the MIM system.

Surprisingly, things have worked out rather well. For those interested, I have created an editor that will edit and render MIM scenes in 2d. It editor is currently known as 'XEdit' and an older (non-mim) version is available at http://www.wojo.com/sferro/

At the time of this writing (8/19/99) I am still putting the finishing touches on the first version of the MIM editor component of XEdit. It will be available from the worldforge ftp site, as well as the above location when completed. Feel free to download the source and binaries. The MIM-capable editor version is scheduled for release by the time you read this article.

However for the sake of discussion, I would like to say that things are working out fairly well. I am able to create and render a tiled scene from the MIM data, and a simple 2d definition file. I will extend this to 3d shortly after the next release. A few simple algorithms were implemented to determine how the tiles fit together in 2d, but that's a topic for another issue... :-)

It is still very early in development. The actual mapfile format is in a state of flux, so please check up on Wiki, and with the mailing lists for up-to-date details on the MIM format.