MDL: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Intermediate save of what I have so far.)
Line 2: Line 2:


== File format ==
== File format ==
Some details of the file format may be gleaned from the source code in Valve's <code>studio.h</code>, specifically the struct <code>studiohdr_t</code>. The early header defines a series of offsets and lengths for various sub-sections within the file, along with some key scalar information. The MDL also contains the names of materials ([[VMT]]) which are used as the numerically-defined swappable skins.
Some details of the file format may be gleaned from the source code in Valve's <code>studio.h</code>, specifically the struct <code>studiohdr_t</code>. The early header defines a series of offsets and lengths for various sub-sections within the file, along with some key scalar information. The MDL also contains the names of materials ([[VMT]]) which are used as the numerically-defined swappable skins.  
 
=== Main header ===
 
<source lang="cpp">struct studiohdr_t
{
int id;            // Model format ID, such as "IDST" (0x49 0x44 0x53 0x54)
int version;        // Format version number, such as 48 (0x30,0x00,0x00,0x00)
char[64]        name;          // The internal name of the model, padding with null bytes.
                                        // Typically "my_model.mdl" will have an internal name of "my_model"
int         dataLength; // ??
 
        // A vector is 12 bytes, three 4-byte float-values in a row.
        Vector          eyeposition;    // Position of player viewpoint relative to model origin
        Vector          illumposition;  // ?? Presumably the point used for lighting when per-vertex lighting is not enabled.
        Vector          hull_min;      // Corner of model hull box with the least X/Y/Z values
        Vector          hull_max;      // Opposite corner of model hull box
        Vector          view_bbmin;
        Vector          view_bbmax;
 
        int            flags;          // ??
       
        // After this point, the header contains many references to offsets within the MDL file and the number of items at those offsets.
 
        int            bone_count      // Number of mstudiobone_t structs   
        int            bone_offset    // Offset of first mstudiobone_t struct
 
        int            bonecontroller_count      // Number of mstudiobonecontroller_t structs   
        int            bonecontroller_offset    // Offset of first mstudiobonecontroller_t struct
}</source>
 
{{TODO|This header information is incomplete.}}
 


== See also ==
== See also ==

Revision as of 20:57, 20 August 2010

MDL is the extension for Source's proprietary model format. It defines the structure of the model along with animation, bounding box, hit box, material, mesh and LOD information. It does not, however, contain all the information needed for the model. Additional data is stored in PHY, ANI, VTX and VVD files, and sometimes, usually for shared animations, other .mdl files.

File format

Some details of the file format may be gleaned from the source code in Valve's studio.h, specifically the struct studiohdr_t. The early header defines a series of offsets and lengths for various sub-sections within the file, along with some key scalar information. The MDL also contains the names of materials (VMT) which are used as the numerically-defined swappable skins.

Main header

struct studiohdr_t
{
	int		id;             // Model format ID, such as "IDST" (0x49 0x44 0x53 0x54)
	int		version;        // Format version number, such as 48 (0x30,0x00,0x00,0x00)
	char[64]        name;           // The internal name of the model, padding with null bytes.
                                        // Typically "my_model.mdl" will have an internal name of "my_model"
	int	        dataLength;	// ??

        // A vector is 12 bytes, three 4-byte float-values in a row.
        Vector          eyeposition;    // Position of player viewpoint relative to model origin
        Vector          illumposition;  // ?? Presumably the point used for lighting when per-vertex lighting is not enabled.
        Vector          hull_min;       // Corner of model hull box with the least X/Y/Z values
        Vector          hull_max;       // Opposite corner of model hull box
        Vector          view_bbmin;
        Vector          view_bbmax;

        int             flags;          // ??
        
        // After this point, the header contains many references to offsets within the MDL file and the number of items at those offsets.

        int             bone_count      // Number of mstudiobone_t structs     
        int             bone_offset     // Offset of first mstudiobone_t struct

        int             bonecontroller_count      // Number of mstudiobonecontroller_t structs     
        int             bonecontroller_offset     // Offset of first mstudiobonecontroller_t struct
}
Todo: This header information is incomplete.


See also