This is an example using the ninja suit.pmg in the archive. If you examine it in a hex editor as you read along, it will all make sense.
Starting at the first byte, the first 10 bytes are important to defining the file, the first 6 telling you what kind of file it is, and what version.
For instance the included PMG has the following bytes "70 6D 67 00 02 01". This tells you that it's "pmg-2.1".
The immediately following two bytes are usually relevant file information, for instance, these two are "D2 11", which is Little Endian for 11D2. This number, after the uniform 2 zero bytes, will take you directly to the end of the data for that segment.
I'm not entirely sure what most of the data is for in this segment, but I'll note down what I DO know.
After the initial D2 11 and following two zero bytes, you can see the name for the PMG, which takes up 128 bytes. In some PMGs, it seems to contain floating point values, but they don't seem important.
The 05 you see here is for SOMETHING, and it's relevant, (any higher and it crashes the PMG viewer, any lower and it doesn't display fingers/hands or at 0, anything). If anyone works out exactly WHAT it's for, please let me know. I'm assuming it's a four byte value, as the viewer crashes with data in the following three bytes.
The next 64 bytes have no value in any PMG I've examined so far, so I guess we can assume for now that this is filler.
The next byte seems to be related to the 05 from earlier, in some PMGs, like for pets, it's equal to the number of every part in the PMG (and the earlier value is 01, probably in regards to what I assume is the PMG equivalent to COM), and if the value of both is greater than the number of parts + 1, it crashes the viewer.
I've tried editing my ninja suit to be 01 and 14, but the only values it accepts are 01 and 13, which don't show all the body parts. Again, if anyone works out what the deal is with these, please, let me know, as I need this information to finish my 3DS Max plugin.
In the provided PMG, if you scroll down to 0x176 (the second "body") you'll see that there's 32 bytes from "body" to the next value, 01, which is followed by a seperating double zero byte from six bytes.
The first four I'm not certain of the function of (I've not gone and gotten myself a Ninja suit, or modified a PMG of something I actually have, so I'm not entirely sure if the client CARES about the values in these bytes), but the following two are a direct reference to the segment of data for that portion of the file
(search EA 05, the only two occurances you'll find, are the one you started at, and at the start of the actual information for that part), and as such, are required even by the PMG viewer.
Some data in files is completely ignored by the client, these values may be treated the same way (There's apparently Korean in the files, but I can't say whether it makes sense or not).
As you can see, some of the data here is obvious, like "male_cloth01_bss_body__" (Defining the texture for that part).
None of this data is particularly relevant for someone making a custom PMG for the game, as the actual visual data starts from 11D2 (Observant people will notice something here), from the point "pm!-1.7". As you might have already guessed, this version information is going to be a recurring theme.
To my knowledge, PMG files contain either 2.0 or 1.7 pm! data. I'm only explaining 1.7 here, as I've not really looked looked at any 2.0 data, but it should follow the same conventions as the 1.7 data, with minor changes. (If that's not the case, feel free to post with your findings.)
So, you've finally made your way to the part of the file containing the actual visual information. As you can see, it's broken up into 20 parts, each for a different body part.
There's always 10 bytes from the 70 to the second 0 byte, which is followed by the name of the part you're going to attach this segment of the PMG to, in this case, "body".
From the initial byte containing 62 (or b), there's 32 bytes that are reserved for the name of the body part.
The next 128 bytes contain the name of the PMG part (Open the PMG in the PMG viewer, click one of the parts, and you'll see what I mean).
Again, another 32 bytes for the part containing "body", (
) and then followed by 32 bytes of zero value (
), which is followed by ANOTHER 32 bytes of zero data (
Not sure what caused that white patch).
The converter source I've checked suggests there might be data at these points, but I have yet to see any, personally, but for the sake of completeness, there you go.
Here you see the value "c2", which is the colour channel for this segment. This takes up 32 bytes (Seriously..?) so, just skip those empty bytes again.
And now, it's time for the good crap.
Frame Matrixes.
These are all floating point values, this particular one starts with four 0 bytes, and contains 16 x 4 byte groups. So, the next 64 bytes are all related to the current frame matrix, which is the Minor Matrix.
The minor matrix isn't really relevant for our exported file, at least, it's commented out in all the .x files (I know.) I've seen so far, simply being included for the sake of completeness it seems.
I'm still decyphering parts of the Java PMG editor at present, so I may find out something interesting about it at a later stage. (It's probable that all commented out frames/mesh data are related to joint data, as the MQO converter skips those, and has broken joints.)
Another frame transform matrix, this time, the Major Matrix.
16 x 4 again, this one isn't commented out, and is pretty hilarious to mess with (try changing an 00 00 80 3F to 00 00 00 40 and loading the PMG in a viewer xD)
The following 12 bytes define the number of parts, in this case, 1.
The next 32 bytes contain the texture of the PMG, "male_cloth01_c", and a crapload of zero bytes.
(no idea what's going on with the white patches..)
The next 116 bytes are simply a repeat of the previous information (
), which is followed 8 bytes later by a matrix the converter lovingly refers to as "What Matrix", implying that the creator didn't know what it's for. This particular matrix is 15 groups of 4 bytes (According to the converter source anyway, I suspect it includes the 40 00 00 00, due to the fact that every other matrix is 64 bytes), and not necessary to export the PMG visual data, for editing. It's possibly joint data, however.
Following on from this, the next 192 bytes are the Mesh Normals for the frame, but for some reason, the other 134 bytes are commented out in the .X file.
Even the PMG/MQO converter has bytes that the other converter comments out.
From 1A56, we have several bits of data, combined.
The first three 4 byte values are Mesh Vertices, the next 3 are the Mesh Normals, followed by Infinity in float format. The next two 4 byte floats are Mesh texture co-ordinates.
And repeat, 28 times.
The last 192 bytes, [s]I have literally no clue about, other than they're likely floating point values (00 00 80 3f = 1)[/s] are possibly Face Size data, from reviewing the converter output.
And after that, you can see that another part of the PMG file.
Congratulations on managing to read that wall of text!