DMX/Binary: Difference between revisions

From Valve Developer Community
< DMX
Jump to navigation Jump to search
No edit summary
(stub elements)
Line 51: Line 51:
: 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.
: 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 values are represented by an <code>int</code>. The value is the element's position in the element index. -1 means "no value".
: Element values are represented by an <code>int</code>. The value is the element's position in the element index.
:* <code>-1</code> means "no value"
:* <code>-2</code> followed by an ASCII GUID (yes, ASCII!) means a "stub element" which exists but was excluded from the DMX
; Arrays
; Arrays
: Arrays start with an <code>int</code> defining the number of items they contained and are tightly-packed.
: Arrays start with an <code>int</code> defining the number of items they contained and are tightly-packed.
Line 66: Line 68:
* String values and Element names are inline
* String values and Element names are inline
* The attribute type <code>Time</code> does not exist
* The attribute type <code>Time</code> does not exist
* Stub Elements do not exist


== Version 2 ==
== Version 2 ==

Revision as of 07:37, 3 July 2013

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.

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 values are stored as an int index in the string dictionary. String array values are stored inline as a null-terminated char array.
Elements
Element values are represented by an int. The value is the element's position in the element index.
  • -1 means "no value"
  • -2 followed by an ASCII GUID (yes, ASCII!) means a "stub element" which exists but was excluded from the DMX
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).
Color
Color values are int in memory but stored in binary DMX as char[4].

Version 3

As 5, except:

  • String dictionary length and indices are short
  • String values and Element names are inline
  • The attribute type Time does not exist
  • Stub Elements do not exist

Version 2

Changes from 3 unknown.

Version 1

As 2, except:

  • There is no string dictionary

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