ADT/v18

From wowdev
Jump to navigation Jump to search

Retrived from; http://wowdev.org/wiki/index.php/ADT


ADT Files

ADT files contain terrain and object information for map tiles. They have a chunked structure just like the WDT files.

A map tile is split up into 16x16 = 256 map chunks. (not the same as file chunks, although each map chunk will have its own file chunk :) ) So there will be a few initial data chunks to specify textures, objects, models, etc. followed by 256 MCNK (mapchunk) chunks :) Each MCNK chunk has a small header of its own, and additional chunks within its data block, following the same id-size-data format.


MHDR chunk

struct SMAreaHeader // 03-29-2005 By ObscuR
{
/*000h*/  UINT32 pad;
/*004h*/  UINT32 offsInfo;		
/*008h*/  UINT32 offsTex;		
/*00Ch*/  UINT32 offsModels;		
/*010h*/  UINT32 offsModelsIds;		
/*014h*/  UINT32 offsMapObejcts;		
/*018h*/  UINT32 offsMapObejctsIds;		
/*01Ch*/  UINT32 offsDoodsDef;		
/*020h*/  UINT32 offsObjectsDef;	
/*024h*/  UINT32 pad1;	
/*028h*/  UINT32 pad2;		
/*02Ch*/  UINT32 pad3;	
/*030h*/  UINT32 pad4;		
/*034h*/  UINT32 pad5;		
/*038h*/  UINT32 pad6;		
/*03Ch*/  UINT32 pad7;	
/*040h*/
};

Header chunk. Contains offsets (relative to 0x14) for some other chunks that appear in the file. Since the file follows a well-defined structure, this is redundant information.

MCIN chunk

Index for MCNK chunks. Contains 256 records of 16 bytes, which have the following format:


Offset	Type		Description
0x0	uint32		MCNK chunk absolute offset
0x4	uint32		MCNK size in bytes
0x8	8 bytes		0


struct SMChunkInfo // 03-29-2005 By ObscuR
{
/*000h*/  UINT32 offset;
/*004h*/  UINT32 size;		
/*008h*/  UINT32 flags;		
/*00Ch*/  UINT32 asyncId;;		
/*010h*/  		
};

This is also redundant information but kind of convenient.

MTEX chunk

List of textures used by the terrain in this map tile. A contiguous block of zero-terminated strings, that are complete filenames with paths. The textures will later be identified by their position in this list.


MMDX chunk

List of filenames for M2 models that appear in this map tile. A contiguous block of zero-terminated strings.


MMID chunk

Lists the relative offsets of string beginnings in the above MMDX chunk. (sort of redundant) One 32-bit integer per offset.


MWMO chunk

List of filenames for WMOs (world map objects) that appear in this map tile. A contiguous block of zero-terminated strings.


MWID chunk

Lists the relative offsets of string beginnings in the above MWID chunk. (again, redundant) One 32-bit integer per offset.


MDDF chunk

Placement information for doodads (M2 models). 36 bytes per model instance.

Offset 	Type 	Description
0x00 	uint32 	ID (index in the MMDX list)
0x04 	uint32 	unique identifier for this instance
0x08 	3 floats 	Position (X,Y,Z)
0x14 	3 floats 	Orientation (A,B,C)
0x20 	uint32 	scale factor * 1024
struct SMDoodadDef // 03-31-2005 By ObscuR
{
/*000h*/  UINT32 nameId;
/*004h*/  UINT32 uniqueId;		
/*008h*/  float pos[3];		
/*00Ch*/ 
/*010h*/ 
/*014h*/  float rot[3];		
/*018h*/  		
/*01Ch*/  		
/*020h*/  UINT16 flags;	
/*022h*/  UINT16 scale;
/*024h*/  
};

The instance information specifies the actual M2 model to use, its absolute position and orientation within the world. The orientation is defined by rotations (in degrees) about the 3 axes as such (this order of operations is for OpenGL, so the transformations "actually" happen in reverse):

  1. Rotate around the Y axis by B-90
  2. Rotate around the Z axis by -A
  3. Rotate around the X axis by C 

Finally the scale factor is given by an integer, multiplied by 1024. So the model needs to be scaled by scale/1024. I wonder why they didn't just use a float.