DMX
Jump to navigation
Jump to search
DMX (Data Model eXtensible? Data Matrix?) is a binary file format used in newer Valve technologies. It appears to be a generic replacement for ASCII formats like SMD or VDF. Currently it has two known uses: Particle systems (.pcf
) and model source data (.dmx
).
DMX has several advantages over VDF. It is:
- Efficient, especially when storing large ints or accurate floats
- Generic, and able to store most memory structures
- Robust, since it does not have to worry about delimiters, line breaks or unclosed quote blocks
Using DMX
With DMX being a binary format, it is not practical either to infer how a given file works from reading it, or to alter one by hand. When the tools for reading/writing them aren't publicly available, this is a problem!
Models
DMX model source files are presumably generated by Valve's Maya plugin. Some editing options are available with the Source 2009 tool dmxedit
, including export to OBJ (unweighted, no animations).
[Todo]
Programming
#include "cbase.h"
#include "dmxloader/dmxloader.h"
#include "dmxloader/dmxelement.h"
CON_COMMAND(test_dmx, "Loads and interprets a DMX file")
{
DECLARE_DMX_CONTEXT();
CDmxElement* DMX = (CDmxElement*)DMXAlloc( 50000000 );
CUtlBuffer buf;
if (UnserializeDMX(args[1],"MOD",false,&DMX))
{
for (int i=0;i<DMX->AttributeCount();i++)
{
CDmxAttribute* cur = DMX->GetAttribute(i);
Msg("%s\t%i\n",cur->GetName(),cur->AttributeDataSize(cur->GetType()));
}
SerializeDMX(buf,DMX);
// write buf to file
}
else
Warning("Could not read DMX file %s\n",args[1]);
}