Map File Structure


(ayatollah) #1

Hi guys…Haven’t posted here in AGES! But was looking for help regarding the structure of a .map file. I am going to build an importer for XNA to accept map files to produce levels. I am not interested in all the different entities, just the brushes. For this I need to know what each value stands for in the structure if the map file.

Example brush:

// brush 0
{
   ( 0 64 0 ) ( 0 64 64 ) ( 0 0 64 ) radiant/notex [b][i]-16 0 0 0.500000 0.500000 0 0 0[/i][/b]
   ( 64 64 64 ) ( 0 64 64 ) ( 0 64 0 ) radiant/notex -16 0 0 0.500000 0.500000 0 0 0
   ( 64 64 64 ) ( 64 64 0 ) ( 64 0 0 ) radiant/notex -16 0 0 0.500000 0.500000 0 0 0
   ( 0 0 64 ) ( 64 0 64 ) ( 64 0 0 ) radiant/notex -16 0 0 0.500000 0.500000 0 0 0
   ( 0 64 64 ) ( 64 64 64 ) ( 64 0 64 ) radiant/notex -16 0 0 0.500000 0.500000 0 0 0
   ( 64 64 0 ) ( 0 64 0 ) ( 0 0 0 ) radiant/notex -16 0 0 0.500000 0.500000 0 0 0
}

Here obviously the red values are the vertices but there are only 6 different sets of vertices, therefore for a cube you expect these to be for each face, but each face should have 4 vertices and here there are only 3.

The blue value is the texture used on that face but I do not know what the bold italicised vaules are used for. Anyone have an idea?

Also for a patch the values are different again.

Example patch:

// brush 0
{
   patchDef2
   {
      radiant/notex
      [b][i]( 3 3 0 0 0 )
      (
      ( ( 0 -63 0 0 1.937500 ) ( 0 -63 31 0 0.968750 ) ( 0 -63 62 0 0 ) )
      ( ( 63 -63 0 1.968750 1.937500 ) ( 63 -63 31 1.968750 0.968750 ) ( 63 -63 62 1.968750 0 ) )
      ( ( 63 0 0 3.937500 1.937500 ) ( 63 0 31 3.937500 0.968750 ) ( 63 0 62 3.937500 0 ) )
      )[/i][/b]
   }
}

Anybody know what the bold italicised values are for here?

Thanks peeps.


(murka) #2

in the brush part the bold ones should be texture alignment related.


(ayatollah) #3

Cheers, I expected as much but need to know exactly what each is for. I have been testing things and if I move the above example brush, some of the -16 values change, that can’t have anything to do with texture alignment surely?! I suspect that the 0.5000000’s are probably the x/y scales for the texture?


(murka) #4

when you move it the texture is possibly locked to the surface(there is an option to turn it on/off from Textures-Texture Lock-Moves + Rotates) and thus the alignment changes.

H offset - V offset - Rotation - H scale - V scale - [unknown] - [shader?] - [always 0?]
the last 3 numbers are still unknown for me.

edit: read trough a map of mine and saw only the first two change, the third unknown seems to be “0” all the time.
I think The second set of numbers might be related to shaders or sth.
examples:


( -32 -32 0 ) ( -32 32 0 ) ( -32 32 64 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
( 32 32 0 ) ( 24 32 64 ) ( -32 32 64 ) liquids_sd/siwa_water 0 0 0 0.500000 0.500000 0 281 0
( 32 -32 0 ) ( 32 -32 64 ) ( 32 32 64 ) common/clip 0 0 0 0.500000 0.500000 0 13 0
( -32 -32 0 ) ( -24 -32 64 ) ( 32 -32 64 ) assault/metal_c07a 0 0 0 0.500000 0.500000 0 0 0
( -96 -32 64 ) ( -96 96 64 ) ( 32 96 64 ) common/caulk 0 0 0 0.500000 0.500000 0 4 0
( 96 96 0 ) ( -32 96 0 ) ( -32 -32 0 ) liquids_sd/seawall_ripple1 0 0 0 0.500000 0.500000 0 0 0

but in my map the texture of assault/metal_c07a is different:


( -1080 -4888 -368 ) ( -1080 -5656 -368 ) ( -808 -5656 -368 ) assault/metal_c07a 175 160 90 0.500000 0.500000 134217728 0 0

(ayatollah) #5

Thanks for that Murka that seems to make sense. I think I’ll leave shader integration out for the minute, so that should negate the last 3 values.

What about the red values, why are there only 3 vertices defined for a square face?

Also what about patches? Any idea?


(carnage) #6

i think you are a little confused about the map format

the red number are not necessarily the exact vertices of the brush (although in some cases they can be). Because brushes can only solid convex shapes they are defined by the planes of each surface. To define a plane in 3D you need three vertices. So the actual vertices of the brush are not the vertices specified in the map file but the resulting vertices from the intersection of these planes

The more complex aspect is that if you give the vertices in clockwise/anticlockwise order it effects what direction the plane is facing. All faces must be pointing to the outside of the object or when you load the map in radiant it will not work properly

the text says what image or shader to use on this surface. There is very little complexity here as the compiler just reads the image/shader and applies the appropriate shader to the surface.

The final numbers describe the surfaces textures orientation and stretch attributes. In other words how the texture fits over the surface

for a better description http://collective.valve-erc.com/index.php?go=map_format


(MrLego) #7

If I remember correctly, the first three items in paranthesees define the XYZ coordinates of a point which is the starting point of a plane or face. This plane extends until it intersects another plane in the brush definition.

The next item on the line is the texture path/name string followed by the texture offset coordinates, texture scale and texture rotation.

Here is a link to the original Quake format —> http://www.gamers.org/dEngine/quake/spec/quake-spec34/index0.htm

There is also a basic definition here —> http://www.modwiki.net/wiki/MAP_(file_format)

Look at the bottom of that page for some links to other sites.


(kamikazee) #8

The modwiki link (which is supposed to be http://www.modwiki.net/wiki/MAP_(file_format)) talks about the newer D3 map format.
While GTKRadiant should be able to read it, Q3Map2 may not compile it.