Call of Duty 2: d3dbsp: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Call of Duty 2]]
The .d3dbsp structure, Call of Duty 2's variant on the well-known BSP format, is rather difficult to decipher. Since it's a binary file you can't simply read it. A hexadecimal editor is the best tool in this case.
The .d3dbsp structure, Call of Duty 2's variant on the well-known BSP format, is rather difficult to decipher. Since it's a binary file you can't simply read it. A hexadecimal editor is the best tool in this case.


Line 9: Line 8:


'''Numbers are stored in little-endian.'''
'''Numbers are stored in little-endian.'''


==Header==
==Header==
Line 18: Line 18:
  (no solid skybox or not everything is IN the skybox) the bsp only has 24 lumps (or even 23 if light is not
  (no solid skybox or not everything is IN the skybox) the bsp only has 24 lumps (or even 23 if light is not
  compiled). The bsp description yet only supports the 37-lumps version (a valid map).''
  compiled). The bsp description yet only supports the 37-lumps version (a valid map).''


==Lump[0] texture files==
==Lump[0] texture files==
Line 27: Line 28:
     int  [2];
     int  [2];
};</pre>
};</pre>
<!-- 2 _ints_ for flags? -->


==Lump[5] planes==
==Lump[5] planes==
Each plane is defined by 4 DWORDs, 3 for the offset of the origin, and one for the normal vector. Planes are faces with infinite length, we suspect they have to do with the rendering system.
Each plane is defined by 4 DWORDs, 3 for the normal vector and 1 for the offset of the origin. Planes are faces with infinite length, we suspect they have to do with the rendering system.


<pre>struct
<pre>struct
{
{
     int  normal[3];
     float normal[3];
     float distance;
     float distance;
};</pre>
};</pre>
<!-- changed normal to type float -->


==Lump[8] vertexes==
==Lump[8] vertexes==
Line 51: Line 56:
     float [6];
     float [6];
};</pre>
};</pre>


==Lump[37] entities==
==Lump[37] entities==
The entities lump is readable and stored the same way described in the [[Call_of_Duty_4:_MAP_file_structure#Entity|.MAP file structure]].
The entities lump is readable and stored (almost) the same way described in the [[Call_of_Duty_4:_MAP_file_structure#Entity|.MAP file structure]].


<pre>struct
<pre>struct
Line 59: Line 65:
     char entities[];
     char entities[];
};</pre>
};</pre>
== Web Links ==
*[http://en.wikipedia.org/wiki/Binary_space_partitioning Binary Space Partitioning]
*[http://www.geocities.com/cofrdrbob/bspformat.html BSP Format]
*[http://en.wikipedia.org/wiki/BSP_(file_extension) BSP (File Extension)]
*[http://qxx.planetquake.gamespy.com/bsp/ BSP for Dummies]
*[http://tremmapping.pbwiki.com/Understanding%20Vis%20and%20Hint%20Brushes Understanding Vis and Hint Brushes (Portalling)]
*[http://graphics.stanford.edu/~kekoa/q3/ Unofficial Quake3 Map Specs]
*[http://www.gamers.org/dEngine/quake/spec/quake-spec34/ Quake Documentation v3.4]
*[http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml Quake 2 BSP File Format]
*[http://code.google.com/p/bsp-renderer/source/browse/#svn/trunk/src Quake BSP Renderer]
*[http://quark.planetquake.gamespy.com/infobase/glossary.html Quake Glossary]
*[http://www.modsonwiki.com/index.php/Call_of_Duty_2:_Map_File_Format Call of Duty 2: Map File Format]


''Made by CoDEmanX and Daevius''
''Made by CoDEmanX and Daevius''
[[Category:Call of Duty 2]]
[[Category:Technical Reference]]

Revision as of 08:15, 21 December 2008

The .d3dbsp structure, Call of Duty 2's variant on the well-known BSP format, is rather difficult to decipher. Since it's a binary file you can't simply read it. A hexadecimal editor is the best tool in this case.

I am still deciphering it myself, I will post anything I happen to get known of regarding the file format.

Be sure to read here and here before you even try to decipher it. Knowing what the technique is that BSP formatted maps use, could be handy as well.

Every number ending with an 'h' indicates its a number using the hexadecimal count system. For other numbers one can assume the decimal count system is used.

Numbers are stored in little-endian.


Header

The file starts with 2 DWORDS: the header 'IBSP' indicating this is a BSP file originally designed by ID software and the version number 4 (4h).

Then there is an array, filled with DWORD pairs, indicating the lump's offset and length respectively. The array ends with 2 empty (zero) DWORDs. Each lump that has size 0 in the list is simply not filled / not used.

 Note: there can be a difference of number of lumps per map. If a map has a leak
(no solid skybox or not everything is IN the skybox) the bsp only has 24 lumps (or even 23 if light is not
compiled). The bsp description yet only supports the 37-lumps version (a valid map).


Lump[0] texture files

Texture information is 72 bytes long per texture. The first 64 bytes are used for the texture name. Then we have an DWORD for flags, and another DWORD for content flags.

struct
{
    char texture[64];
    int  [2];
};


Lump[5] planes

Each plane is defined by 4 DWORDs, 3 for the normal vector and 1 for the offset of the origin. Planes are faces with infinite length, we suspect they have to do with the rendering system.

struct
{
    float normal[3];
    float distance;
};


Lump[8] vertexes

Every vertex is 17 DWORDs long (98 bytes). First 3 DWORDs define the position (x y and z). Next 3 DWORDs define the normal vector of the vertex (x y and z) (WHY?!), then a DWORD which defines the colour (BGR) and the opacity (A). Then 2 DWORDs which have to do with texture shifting, and 2 more DWORDs for something yet unknown. At the end we have 6 DWORDs having to do with texture alignment (rotation?).

struct
{
    float position[3];
    int   normal[3];    
    char  bgr[3];
    char  a;
    float shift[2];
    float [2];
    float [6];
};


Lump[37] entities

The entities lump is readable and stored (almost) the same way described in the .MAP file structure.

struct
{
    char entities[];
};


Web Links


Made by CoDEmanX and Daevius