• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

MDL format datablocks

Status
Not open for further replies.
Level 3
Joined
Dec 30, 2007
Messages
48
You might know me from orbiting around thehelper.net, wc3c.net and the hiveworkshop.com. I have ambigious plan to write exporter script for Blender 3D. That will take ages due to real life responsibilities. Ever changing Blender has its roll in it too -- they are moving to new API and Python 3.
Meanwhile I have come to conclusion that I can separate my project into smaller chapters or tasks. One would be making python script to generate template MDL file. Second task to feed that script with Blender model data.

I have aquired my MDL knowledge from: MDL/MDX - Warcraft III Model Format Specifications by Jimmy "Nub" Campbell

Here is basic MDL file:
Code:
// 'DeX Version: 0.185m
Version {
	FormatVersion 800,
}
Model "Plane" {
	NumGeosets 1,
	NumBones 1,
	BlendTime 150,
	MinimumExtent { -36.1232, -36.5024, 0.0 },
	MaximumExtent { 36.7632, 36.384, 0.0001 },
	BoundsRadius 51.7236,
}
Textures 1 {
	Bitmap {
		Image "Textures\White.blp",
	}
}
Materials 1 {
	Material {
		Layer {
			FilterMode None,
			static TextureID 0,
		}
	}
}
Geoset {
	Vertices 4 {
		{ -36.1232, -36.5024, 0.0 },
		{ 36.7632, -36.5024, 0.0 },
		{ -36.1232, 36.384, 0.0 },
		{ 36.7632, 36.384, 0.0 },
	}
	Normals 4 {
		{ 0.0, 0.0, 1.0 },
		{ 0.0, 0.0, 1.0 },
		{ 0.0, 0.0, 1.0 },
		{ 0.0, 0.0, 1.0 },
	}
	TVertices 4 {
		{ 0.000499517, 0.9995 },
		{ 0.9995, 0.999501 },
		{ 0.000499755, 0.000499487 },
		{ 0.999501, 0.000499725 },
	}
	VertexGroup {
		0,
		0,
		0,
		0,
	}
	Faces 1 6 {
		Triangles {
			{ 2, 0, 3, 1, 3, 0 },
		}
	}
	Groups 1 1 {
		Matrices { 0 },
	}
	MinimumExtent { -36.1232, -36.5024, 0.0 },
	MaximumExtent { 36.7632, 36.384, 0.0001 },
	BoundsRadius 51.7236,
	MaterialID 0,
	SelectionGroup 0,
}
Bone "default_bone01" {
	ObjectId 0,
	GeosetId 0,
	GeosetAnimId None,
}
PivotPoints 1 {
	{ 0.0, 0.0, 0.0 },
}

My questions are:
1. What are VertexGroups? How they are linked to other data?
2. What is Faces datablock? How they are linked to other data?
3. What is Groups datablock? What are Matrices? How they are linked to other data?


I have assumptions:
Code:
	VertexGroup {
		0, = vertex with index 0 = { -36.1232, -36.5024, 0.0 }
		0, = vertex with index 1 = { 36.7632, -36.5024, 0.0 }
		0, = vertex with index 2 = { -36.1232, 36.384, 0.0 }
		0, = vertex with index 3 = { 36.7632, 36.384, 0.0 }
	}
About previous code all vertices belong to same VertexGroup numbered with 0 (zero). I have seen how you can write there different numbers that would bake those vertices to belong different VertexGroups?
Code:
	VertexGroup {
		1, = vertex with index 0 = { -36.1232, -36.5024, 0.0 }
		2, = vertex with index 1 = { 36.7632, -36.5024, 0.0 }
		3, = vertex with index 2 = { -36.1232, 36.384, 0.0 }
		4, = vertex with index 3 = { 36.7632, 36.384, 0.0 }
	}
or even:
Code:
	VertexGroup {
		1, = vertex with index 0 = { -36.1232, -36.5024, 0.0 }
		1, = vertex with index 1 = { 36.7632, -36.5024, 0.0 }
		0, = vertex with index 2 = { -36.1232, 36.384, 0.0 }
		0, = vertex with index 3 = { 36.7632, 36.384, 0.0 }
	}
Last one would have two different vertices groups, but where are that data used?

Faces datablock is interesting, Jimmy writes:
Code:
// Faces is a strange construct, the first number is how many groups there
//  are, and the second is how many numbers there are total. <VALUES> can
//  either be a single short or a list of shorts such as { <short>, <short>, <short>... }
//  the length of <VALUES> seems to be <long_cnt>/<long_grps>
//  This is perhaps a way to define different shaped primitives, with the values
//  in PTYP being primitive type flags. Since only groups of type 4 have been
//  identified in any MDX files, it seems to function as a grouping artifact
//  used only in their development. The only occurances of more than one group
//  have been in MDX files exported by the Max Art Tools. (thanks nicoli_s)
As I have observed:
Code:
	Faces 1 6 {
		Triangles {
			{ 2, 0, 3, 1, 3, 0 },
		}
2 = vertex with index 2 = { -36.1232, 36.384, 0.0 }
0 = vertex with index 0 = { -36.1232, -36.5024, 0.0 }
3 = vertex with index 3 = { 36.7632, 36.384, 0.0 }

Now numbers 2, 0 and 3 would make one Face, they are like one block in sequence of Faces.

1 = vertex with index 1 = { 36.7632, -36.5024, 0.0 }
3 = vertex with index 3 = { 36.7632, 36.384, 0.0 }
0 = vertex with index 0 = { -36.1232, -36.5024, 0.0 }

Now numbers 1, 3 and 0 would make second Face, they are like one block in sequence of Faces.

Makes sense because usually plane consist of two faces (or any cube side)

If I would like to add new Face to same model (I reuse already defined vertices and understand they are on same Z height and visually does not make much sense to have):
Code:
	Faces 1 9 {
		Triangles {
			{ 2, 0, 3, 1, 3, 0, 3, 2, 1 },
		}
Because I added 3 more entries number 6 in Face 1 6 became 9, numbers I added were:
Code:
, 3, 2, 1 },
Is that so simple? I am currently trying to understand Geoset part of MDL file.
 
Level 23
Joined
Mar 29, 2004
Messages
1,979
VertexGroup values link to Matrices. The VertexGroup goes along with the Vertex/TVertex at the same index in the list, thus assigning it to a group.

Matrices link to bones (by ObjectID). If there is more than one bone ID in the matrix, then the movement of the assigned vertices is weighted equally between each bone's movements (so you can fake a different weighting scheme by putting the same objectID in more than once).

The faces collossus is in groups of three, again vertex indices, as you noted. I think you can have trianglestrip instead of faces, but we reckoned that's just a manifestation of ribbon emitter technology rather than anything useful.
 
Status
Not open for further replies.
Top