WDR

From GTAMods Wiki
Revision as of 20:01, 5 October 2009 by Gforce (talk | contribs) (File Format)
Jump to navigation Jump to search

WDR is the format used for map models and weapons in GTA IV.


File Format

RSC CPU section (Size found from the flags @ 0x08 of RSC file header)

-Note on RSC (24 + 8) pointer structure:

* CPU Offsets are of form [xx xx xx 50] * Data Offsets are of form [xx xx xx 60]

WDR Header (BlockSize 0x2A0)
-------------------------------------------------------------------
Offset	Size	Type	Data			Description
-------------------------------------------------------------------
0x00	4b	LONG	VTable		        (Usually 0x00695254)
0x04	4b	Offset	HeaderLength		(Usually 0x90)
0x08	4b	Offset	ShaderGroup 		(0 = no Shaders)
0x0C	4b	Offset	SkeletonData	 	(0 = no Skeleton)
0x10	4b	FLOAT	Center x
0x14	4b	FLOAT	Center y
0x18	4b	FLOAT	Center z
0x1C	4b	FLOAT	Center w
0x20	4b	FLOAT	BoundsMin x
0x24	4b	FLOAT	BoundsMin y
0x28	4b	FLOAT	BoundsMin z
0x2C	4b	FLOAT	BoundsMin w
0x30	4b	FLOAT	BoundsMax x
0x34	4b	FLOAT	BoundsMax y
0x38	4b	FLOAT	BoundsMax z
0x3C	4b	FLOAT	BoundsMax w
0x40	4b	Offset	Pointer ModelCollection	(0=Non existing)
0x44	4b	Offset	Pointer LOD models 	(0=Non existing)
0x48	4b	Offset	Pointer LOD models 	(0=Non existing)
0x4C	4b	Offset	Pointer LOD models 	(0=Non existing)
0x50	4b	FLOAT	Max Vectorx 		(Usually 9999.0)
0x54	4b	FLOAT	Max Vectory 		(Usually 9999.0)
0x58	4b	FLOAT	Max Vectorz 		(Usually 9999.0)
0x5C	4b	FLOAT	Max Vectorw 		(Usually 9999.0)
0x60	4b	LONG	ObjectCount
0x64	4b	LONG	Unknown			(Usually 0xFFFFFFFF)
0x68	4b	LONG	Unknown			(Usually 0xFFFFFFFF)
0x6C	4b	LONG	Unknown			(Usually 0xFFFFFFFF)
0x70	4b	FLOAT	Unknown
0x74	20b	LONG	Unknown 		(Usually all zeros)
0x88	8b	LONG	Unassigned data		(0xCDCDCDCDCDCDCDCD)
0x90	4b	LONG	End of Header		(Usually 0x00000000)
--------------------------------------------------------------------
ModelCollection (BlockSize 0x08)
--------------------------------------------------------------------
0x00	4b	Offset	Pointer to Model Pointer
0x04	2b	Short	Number of Pointers
0x06	2b	Short	Number of Pointers
0x08	4b	LONG	Padding                 (0xCDCDCDCD)
0x0C	4b	LONG	Padding                 (0xCDCDCDCD)
--------------------------------------------------------------------
Model (BlockSize 0x20)
--------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0x34026B00)
0x04	8b	Offset  PointerCollection<Geometrys>
0x0C	4b	Offset 	SimpleArray<Vector4>    (Unknown Vectors)
0x10	4b	Offset 	SimpleArray<Integer>    (Material Mappings)
0x14	2b	Short	Unknown1                (Usually 0)
0x16	2b	Short	Unknown2
0x18	2b	Short	Unknown3
0x1A	2b	Short	GeometryCount
0x1C	4b	LONG	Padding                 (0xCDCDCDCD)
--------------------------------------------------------------------
Geometry (BlockSize 0x50)
--------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0xF4486B00)
0x04	4b	LONG	Unknown 1		(Usually 0)
0x08	4b	LONG 	Unknown 2		(Usually 0)
0x0C	4b	Offset 	VertexBuffer
0x10	4b	LONG	Unknown 3		(Usually 0)
0x14	4b	LONG 	Unknown 4		(Usually 0)
0x18	4b	LONG	Unknown 5		(Usually 0)
0x1C	4b	Offset	IndexBuffer
0x20	4b	LONG	Unknown 6		(Usually 0)
0x24	4b	LONG 	Unknown 7		(Usually 0)
0x28	4b	LONG	Unknown 8		(Usually 0)
0x2C	4b	LONG	IndexCount
0x30	4b	LONG	FaceCount
0x34	2b	Short	VertexCount
0x36	2b	Short	PrimitiveType
0x38	4b	LONG	Unknown 9		(Usually 0)
0x3C	2b	Short	VertexStride		(36 without normal map, 52 with normal map)
0x3E	2b	Short	Unknown 10		(Usually 0)
0x40	4b	LONG	Unknown 11		(Usually 0)
0x44	4b	LONG	Unknown 12		(Usually 0)
0x48	4b	LONG	Unknown 13		(Usually 0)
0x4C	4b	LONG	Padding                 (0xCDCDCDCD)
--------------------------------------------------------------------
VertexBuffer (BlockSize 0x64)
--------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0xD8BA6B00)
0x04	2b	Short 	VertexCount
0x06	2b	Short	Unknown 1		(Usually 0)
0x08	4b	Offset	DataOffset to VertexData
0x1C	4b	LONG	VertexStride		(36 without normal map, 52 with normal map)
0x20	4b	Offset	VertexDeclarationOffset
0x24	4b	LONG	Unknown 2		(Usually 0)
0x28	4b	Offset	DataOffset to VertexData (Again)
0x2C	4b	LONG	Unknown 3		(Usually 0)
0x30	32b	LONG    Padding                 (0xCD)
--------------------------------------------------------------------
IndexBuffer (BlockSize 0x40)
--------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0x70B86B00)
0x04	4b	LONG	IndexCount
0x08	4b	Offset	DataOffset to IndexData
0x0C	4b	LONG	Unknown 1		(Usually 0)
0x10	32b	LONG    Padding                 (0xCD)
--------------------------------------------------------------------
ShaderGroupData (offset remarked in Header at 0x08) (BlockSize 0x50) 
--------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0x44166B00)
0x04	4b	Offset	TextureDictionary       (0 = no Embedded textures)
0x08	4b	Offset	Pointer to a Pointer for ShaderFX PointerCollection 
0x0C    2b      Short	Number of Pointers at Pointer for ShaderFX PointerCollection
0x0E    2b      Short	Number of Pointers at Pointer for ShaderFX PointerCollection  
0x10	48b	Zeros
0x40	4b	Offset  Pointer to SimpleCollection VertexDeclarationUsageFlags
0x44    2b      Short   Number of SimpleCollection VertexDeclarationUsageFlag entries
0x46    2b      Short   Number of SimpleCollection VertexDeclarationUsageFlag entries
0x48	4b	Offset  Pointer to SimpleCollection UnknownInts
0x4C    2b      Short   Number of SimpleCollection UnknownInt entries
0x4E    2b      Short   Number of SimpleCollection UnknownInt entries
-----------------------------------------------------------------------------------------------------
ShaderFX (offset remarked in ShaderGroupData in the Pointer to ShaderFX PointerCollection 0x08) (BlockSize 0x50) 
-----------------------------------------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0x3C226B00)
0x04	4b	LONG	BlockMapAdress
0x08	2b	Short	Unknown 1
0x0A	1b	Byte	Unknown 2
0x0B	1b	Byte	Unknown 3
0x0C	2b	Short	Unknown 4
0x0E	2b	Short	Unknown 4_1
0x10	4b	LONG	Unknown 5
0x14	4b	Offset	ShaderParamsOffsetsOffset
0x18	4b	LONG	Unknown 6
0x1C	4b	LONG	ShaderParamCount
0x20	4b	LONG	Unknown 8
0x24	4b	Offset	ShaderParamTypesOffset
0x28	4b	Hash	Unknown Hash
0x2C	4b	LONG	Unknown 9
0x30	4b	LONG	Unknown 10
0x34	4b	Offset	ShaderParamNameOffset
0x38	4b	LONG	Unknown 11
0x3C	4b	LONG	Unknown 12
0x40	4b	LONG	Unknown 13
0x44	4b	Offset	ShaderName Pointer	(Pointer to null terminated String)
0x48	4b	Offset	ShaderSPS Pointer	(Pointer to null terminated String)
0x4C	4b	LONG	Unknown 14
0x50	4b	LONG	Unknown 15
0x54	4b	LONG	Unknown 16
0x58	4b	LONG	Unknown 17 
0x5C	4b      LONG	Padding                 (0xCDCDCDCD)
--------------------------------------------------------------------
Null Terminated String (BlockSize 0x10) 
Note: If String is bigger then 0x10 it will be padded till 0x20 etc.
--------------------------------------------------------------------
0x00	String
0x??	1b	0x00	(End of String)
0x??	0xCD Padding till 0x0F
--------------------------------------------------------------------
PointerCollection (BlockSize 0x08) 
Contains pointers to the data of the given type
--------------------------------------------------------------------
0x00	4b	Offset	Offset to the Pointers
0x04	2b	Short	Number of Pointers
0x06	2b	Short	
--------------------------------------------------------------------
SimpleCollection (BlockSize 0x08) 
Contains data of the given type
--------------------------------------------------------------------
0x00	4b	Offset	Offset to the Data
0x04	2b	Short	Data Count
0x06	2b	Short	Data Size

GRAPHICS section (Size found from the flags @ 0x08 of RSC file header)

---------------------------------------------------------------------------------------
VertexData (BlockSize VertexCount*0x24 or 0x34 when the Geometry is using a normal map)
---------------------------------------------------------------------------------------
0x00	4b	FLOAT	Position x
0x04	4b	FLOAT	Position y
0x08	4b	FLOAT	Position z
0x0C	4b	FLOAT	Normal x
0x10	4b	FLOAT	Normal y
0x14	4b	FLOAT	Normal z
0x18	4b	DWORD	Color (RGBA)
0x1C	4b	FLOAT	Texcoord u
0x20	4b	FLOAT	Texcoord v
0x24	4b	FLOAT	Tangent/Bi-Normal x   // Only when there is a normal map applied to the Geometry
0x28	4b	FLOAT	Tangent/Bi-Normal y   // Only when there is a normal map applied to the Geometry
0x2C	4b	FLOAT	Tangent/Bi-Normal z   // Only when there is a normal map applied to the Geometry
0x30	4b	FLOAT	Tangent/Bi-Normal w   // Only when there is a normal map applied to the Geometry
---------------------------------------------------------------------------------
IndexData (BlockSize IndexCount*0x06)
---------------------------------------------------------------------------------
0x00	2b	Short	Vertex A
0x02	2b	Short	Vertex B
0x04	2b	Short	Vertex C
-------------------------------------------------------------------
SkeletonData	(BlockSize 64 bytes)
-------------------------------------------------------------------
0x00	4b	Offset			        
0x04	4b	Offset	
0x08	4b	Offset	
0x0C	4b	Offset	
0x10	4b	Offset	
0x14	4b	Long	
0x18	4b	Long	
0x1C	4b	Long	
0x20	4b	Long	
0x24	4b	Long	
0x28	4b	Long	
0x2C	4b	Long	
0x30	4b	Long	
0x34	4b	Long	VTable ?
0x38	4b	Long	
0x3C	4b	Long	
--------------------------------------------------------------------
Texture definition (for externally defined textures)(BlockSize 0x1C) 
--------------------------------------------------------------------
0x00	4b	LONG	VTable		        (0x5C676B)
0x04	4b	LONG	Unknown1
0x08	4b	LONG	Unknown2
0x0C	4b	LONG	Unknown3
0x10	4b	LONG	Unknown4
0x14	4b	Offset	Offset Pointer to Texture name
0x18	4b	LONG	Unknown5
0x1C	4b	LONG	Padding                 (0xCDCDCDCD)

Tools and Scripts

The following tools and scripts can be used to import & export (edit) these model files.