DMX/Binary: Difference between revisions
< DMX
Jump to navigation
Jump to search
(Created page with "<source lang=cpp> class BinaryDMX_v5 { char* header = "<!-- dmx encoding binary 5 format %s %i -->\n"; int nStrings; // number of strings in StringDict char* StringDict[]; /...") |
No edit summary |
||
Line 1: | Line 1: | ||
== Version 5 == | |||
<source lang=cpp> | <source lang=cpp> | ||
class BinaryDMX_v5 | class BinaryDMX_v5 | ||
Line 9: | Line 11: | ||
int nElements; // number of elements in the entire data model | int nElements; // number of elements in the entire data model | ||
DmeHeader | DmeHeader ElementIndex; // the root element | ||
DmeBody | DmeBody ElementBodies[]; // in the same order as the nested index | ||
}; | }; | ||
Line 17: | Line 19: | ||
int Type; // string dictionary index | int Type; // string dictionary index | ||
int Name; // string dictionary index | int Name; // string dictionary index | ||
char GUID[16]; | char GUID[16]; // little-endian | ||
DmeHeader | DmeHeader SubElems[]; // skip elements which already have an index entry | ||
}; | }; | ||
Line 25: | Line 27: | ||
{ | { | ||
int nAttributes; | int nAttributes; | ||
DmeAttribute | DmeAttribute Attributes[]; | ||
}; | }; | ||
Line 47: | Line 49: | ||
; Strings | ; Strings | ||
: String | : String values are stored as an <code>int</code> index in the string dictionary. String ''array'' values are stored inline as a null-terminated <code>char</code> array. | ||
; Elements | ; Elements | ||
: Element | : Element values are represented by an <code>int</code>. The value is the element's position in the element index. -1 means "no value". | ||
; Arrays | ; Arrays | ||
: Arrays start with an <code>int</code> defining the number of items they contained | : Arrays start with an <code>int</code> defining the number of items they contained and are tightly-packed. | ||
; Time | ; Time | ||
: Time | : Time values are <code>float</code> in memory but are stored in binary DMX as <code>(int)(this*10000)</code>. | ||
== Version 2 == | |||
As 5, except: | |||
* String dictionary length and indices are <code>short</code> | |||
* String array values are stored in the dictionary too | |||
== Binary_v2 == | |||
This is a very early version of binary DMX, which can be found in some of the SDK's sample TF2 animations (those exported in April 2007). It is ''not'' the same as the "real" version 2 (above). | |||
Known differences from 5 are: | |||
* Header is <code><nowiki><!-- DMXVersion binary_v2 --></nowiki></code> | |||
* There is no string dictionary; everything is inline | |||
* <code>Color</code> is <code>char[4]</code> | |||
[[Category:File formats]] | [[Category:File formats]] |
Revision as of 09:08, 5 November 2012
Version 5
class BinaryDMX_v5
{
char* header = "<!-- dmx encoding binary 5 format %s %i -->\n";
int nStrings; // number of strings in StringDict
char* StringDict[]; // null-terminated, tightly packed
int nElements; // number of elements in the entire data model
DmeHeader ElementIndex; // the root element
DmeBody ElementBodies[]; // in the same order as the nested index
};
class DmeHeader
{
int Type; // string dictionary index
int Name; // string dictionary index
char GUID[16]; // little-endian
DmeHeader SubElems[]; // skip elements which already have an index entry
};
class DmeBody
{
int nAttributes;
DmeAttribute Attributes[];
};
class DmAttribute
{
int Name; // string dictionary index
char AttributeType; // see below
void* Value; // see below
};
Attribute Types
Check DmAttributeType_t
in public/datamodel/dmattributetypes.h
to get the index of each attribute type.

DmAttributeType_t
changes over time, so make sure that you're looking at the right version! Use Alien Swarm for binary v5.Attribute Values
Most values are stored in their native binary format (check tier0 for the layout of the fancier types). Exceptions are:
- Strings
- String values are stored as an
int
index in the string dictionary. String array values are stored inline as a null-terminatedchar
array. - Elements
- Element values are represented by an
int
. The value is the element's position in the element index. -1 means "no value". - Arrays
- Arrays start with an
int
defining the number of items they contained and are tightly-packed. - Time
- Time values are
float
in memory but are stored in binary DMX as(int)(this*10000)
.
Version 2
As 5, except:
- String dictionary length and indices are
short
- String array values are stored in the dictionary too
Binary_v2
This is a very early version of binary DMX, which can be found in some of the SDK's sample TF2 animations (those exported in April 2007). It is not the same as the "real" version 2 (above).
Known differences from 5 are:
- Header is
<!-- DMXVersion binary_v2 -->
- There is no string dictionary; everything is inline
Color
ischar[4]