bmt2xml
A while ago someone asked about reading bml and bmt files, some form of binary XML files used by Need for Speed: Shift for material information and probably other things as well.
File Format
- BLMY
- 4 bytes: name (BLMY)
- 4 bytes integer: 7 (Number of entries in block list?)
- 4 bytes integer: total file size
- 4 bytes integer: ??? (Always 0)
- Blocks List
- 4 bytes: name (HEAD/ELMT/ATTR/COLL/NUMB/BOOL/STRS)
- 4 bytes integer: Data length in bytes
- 4 bytes integer: Data start offset in file
- 4 bytes integer: ??? (Always 0)
- ...
- HEAD Data
- 4 bytes integer: Number of Elements
- 4 bytes integer: Number of Attributes
- 4 bytes integer: Number of COLL
- 4 bytes integer: Number of Numbers
- 4 bytes integer: Number of Strings
- 4 bytes integer: Number of Booleans
- 4 bytes integer: ??? (Seems to always be number of elements-1; Number of child elements? Could also be index of the root-element)
- ELMT Data
- 4 bytes integer: Name (Resource ID or hash?)
- 4 bytes integer: First attribute (attribute number)
- 4 bytes integer: Number of attributes
- 4 bytes integer: Number of child elements
- 4 bytes integer: First child element (element number)
- 4 bytes integer: Next sibling (element number)
- 4 bytes integer: Number element of same type (element number)
- ...
- ATTR Data
- 4 bytes integer: Name (Resource ID or hash?)
- 4 bytes integer: type (0=numb, 1=bool, 2=strs)
- 4 bytes integer: value (offset or index)
- 4 bytes integer: Number of values
- 4 bytes integer: Next attribute of the same kind (attribute number)
- ...
- COLL Data
- 4 bytes integer: Name (Resource ID or hash?)
- 4 bytes integer: ?
(if Name is same as of root element this seems to be same as the number of child elements) - 4 bytes integer: ? (1 or 0)
- 4 bytes integer: ? (Always -1)
- ...
- NUMB Data
- float array
- BOOL Data
- Bit field
- STRS Data
- Strings
bmt2xml tool
Building bmt2xml
# git clone http://git.pappkartong.se/bmt2xml.git # cd bmt2xml # make
Using bmt2xml
# ./bmt2xml file.bmt
Example:
# ./bmt2xml autograss_laguna.bmt <material name="Autograss" shader="Render\Shaders\grass_billboard.fx" technique="Grass" cull="EBFCT_NONE" fog="false" antialias="1" numparams="10"> <shaderparam name="fadeDistances" type="EPT_VEC2"> <value v="0 100" /> </shaderparam> <shaderparam name="cornerHeights" type="EPT_VEC4"> <value v="0 0 0 0" /> </shaderparam> <shaderparam name="subPageWidths" type="EPT_VEC4"> <value v="1 0.9 0.9 0.9" /> </shaderparam> <shaderparam name="subPageHeights" type="EPT_VEC4"> <value v="0.28 0.25 0.23 0.23" /> </shaderparam> <shaderparam name="boxWorldCoordsSize" type="EPT_F32"> <value v="16" /> </shaderparam> <shaderparam name="diffuseTexture" type="EPT_TEXTURE"> <type t="ET_STANDARD" /> <value v="Effects\Particles\Textures\Autograss_Laguna.dds" /> </shaderparam> <shaderparam name="maxAnimatedVertDisplacement" type="EPT_F32"> <value v="0.25" /> </shaderparam> <shaderparam name="transmissiveMult" type="EPT_VEC4"> <value v="0.8 1 0.2 1" /> </shaderparam> <depthparams> <enabled e="true" /> <writeenabled w="true" /> </depthparams> <alphatestparams> <enabled e="true" /> <value v="128" /> <function f="ETF_GREATER_THAN_OR_EQUAL" /> </alphatestparams> <alphablendparams> <enabled e="false" /> </alphablendparams> <define name="AUTOGRASS" /> </material>
TODO
- Figure out what COLL is
- Cleanup
- Add command line options for outfile etc.
Download
The source code for bmt2xml.
Clone the git repository
git: # git clone http://git.pappkartong.se/bmt2xml.git
Note: This is a git repository, you need git to use it.
Download using gitweb
Or download the current head bmt2xml-master-*.tar.gz using gitweb.
Uptime: 166 days, 13 hours, 8 minutes