DMX/Binary

From Valve Developer Community
< DMX
Revision as of 05:40, 6 October 2012 by Artfunkel (talk | contribs) (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[]; /...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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; // nested
	DmeBody*	ElementBodies[]; // in the same order as the index
};

class DmeHeader
{
	int		Type; // string dictionary index
	int		Name; // string dictionary index
	char	GUID[16];

	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.

Note.pngNote: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 attributes can either be stored inline as a null-terminated char array, or as an int index in the string dictionary. Check the dictionary first.
It's unclear what would happen if an inline string were also to form a valid dictionary index!
Elements
Element attributes are represented by an int. The value is the element's position in the element index.
Arrays
Arrays start with an int defining the number of items they contained, and are tightly-packed.
Time
Time attributes are float in memory but are stored in binary DMX as (int)(this*10000).