M2/.skin: Difference between revisions

From wowdev
Jump to navigation Jump to search
m (Yes, you are. But your biography should be on your user-site. :) Go on, edit. Yes, its a bit misleading to be titled nTriangles.)
Line 56: Line 56:


==Texture units==
==Texture units==
*'''nTextureUnits blocks of 0x16 bytes per record.'''  
*'''nTextureUnits blocks of 0x18 bytes per record.'''  
More specifically, textures for each texture unit. Based on the current submesh number, one or two of these are used to determine the texture(s) to bind.
More specifically, textures for each texture unit. Based on the current submesh number, one or two of these are used to determine the texture(s) to bind.



Revision as of 19:52, 15 January 2009

Okay, there is no ofsViews anymore in M2-files, but we still got nViews at 4 so there has to be a place where this information is stored. This is when the .skin-files come to the light. They got added in WotLK and are in the same folder as the M2s. They are named like Modelname0x.skin, where Modelname is the same name as the model has and x is a digit from 0 to 3 representing each View / LOD. They are in the same structure as the ofsViews-block has been, just with all offsets now being relative to the .skin-files of course. The vertices are still in the M2 itself since they are the same for all views.

There is a C .h file here: M2/WotLK/.skin/header

The files are made up in several blocks. First is a header:

Header

Offset	Type 	Name		Description
0x00	uint32	ID		SKIN
0x04	uint32	nIndices		
0x08	uint32	ofsIndices	Indices used in this View.
0x0C	uint32	nTriangles		
0x10	uint32	ofsTriangles	The triangles made with them.
0x14	uint32	nProperties		
0x18	uint32	ofsProperties	Properties of the vertices.
0x1C	uint32	nSubmeshes		
0x20	uint32	ofsSubmeshes	Submeshes (Geosets) of this View.
0x24	uint32	nTextureUnits		
0x28	uint32	ofsTextureUnits	Texture Units.
0x2C	uint32	LOD		LOD distance or something else

Indices

  • nIndices 16-bit unsigned shorts, specifing vertices from the global vertex list for later use.
Offset	Type 	Name		Description
0x00	uint16	Vertex		The vertex in the global vertex list.

Triangles

  • nTriangles entries of each 3 unsigned shorts. They refer to indices in the list above.
Offset	Type 	Name		Description
0x00	uint16	Indices[3]	Three indices which make up a triangle.

I believe (empirically tested) that nTriangles is actually not the number of triangles in the list, but the number of vertexes in the triangle list. That is, the actual number of triangles in the list is actually nTriangles / 3. I discovered this when a test application I've been writing attempted to read past the end of the file when not first dividing the number of triangles to read by 3.

Vertex properties

  • nProperties entries of some kind.
Offset	Type 	Name		Description
0x00	uint32	Properties	Usually 0? Purpose unknown.

Submeshes

  • nSubmeshes entries of 48 bytes defining submeshes.
Offset	Type 	Name		Description
0x00 	uint32	ID		Mesh part ID, see below.
0x04 	uint16	StartVertex	Starting vertex number.
0x06 	uint16	nVertices	Number of vertices.
0x08 	uint16	StartTriangle	Starting triangle index (that's 3* the number of triangles drawn so far).
0x0A 	uint16	nTriangles	Number of triangle indices.
0x0C 	uint16	nBones		Number of elements in the bone lookup table.
0x0E 	uint16	StartBones	Starting index in the bone lookup table.
0x10 	uint16	Unknown		
0x12 	uint16	RootBone	Not sure.
0x14 	float	Position[3]	Some Vector. Not sure about it being the Position.
0x20 	float	Floats[4]	New Floats since BC.

Mesh part ID: for character models, each hairstyle/thick armor/etc is present in the mesh, so to render a character with a specific set of looks, some of the submeshes should be ommitted based on this ID.

Reference to the bone lookup table: the base number seems to increase per LOD, and the numbers in the bone lookup table, in turn, point to bone-indices at ofsBones.

Texture units

  • nTextureUnits blocks of 0x18 bytes per record.

More specifically, textures for each texture unit. Based on the current submesh number, one or two of these are used to determine the texture(s) to bind.

Offset	Type 	Name		Description
0x00 	uint16	Flags		Usually 16 for static textures, and 0 for animated textures.
0x02 	uint16	RenderOrder	Used in skyboxes to ditch the need for depth buffering.
0x04 	uint16	SubmeshIndex	A duplicate entry of a submesh from the list above.
0x06 	uint16	SubmeshIndex2	
0x08 	int16	ColorIndex	A Color out of the Colors-Block or -1 if none.
0x0A 	uint16	RenderFlags	The renderflags used on this texture-unit.
0x0C 	uint16	TexUnitNumber	Index into the texture unit lookup table.
0x0E 	uint16	Unknown		Always 1.
0x10 	uint16	Texture		The texture to use. That list at ofsTextures
0x12 	uint16	TexUnitNumber2	Duplicate of TexUnitNumber.
0x14 	uint16	Transparency	Index into transparency lookup table.
0x16 	uint16	TextureAnim	Was a index into the texture animation lookup table. 

TextureAnim: This should be 0 now since somehow the block disappeared. Maybe it will come back. We will see then.