# Identifying mesh format from initial bytes

I have a file containing mesh data whose blocks seem to start with DWORDS like:

0x1 0x1 0x3100026f 0x1 0x30000112

or

0x1 0x1 0x310007b2 0x1 0x30000112

or

0x10000006 0x3 0x310001f6 0x310001f6 0x310001f6

They don't look like .x binaries. Any other ideas?

UPDATE:

Here's more: 00000001 00000001 3100026F 00000001 30000112 000000C7 BD869270 3F0372D4 00000000 BD41F15F 3F11A611 3F522E05 3E40EF5A 3E17CDF8 3E40993C BF504FBD 3F0CCC2A BF78001B BE654B6A 3DDA7965 BD80EB99 3F003679 3C0BDAE1 BD3DD880 3F112A76 3F528732 3E8EFD04 3E185DD8 3E3984B8 BF48A923 3F180DA9 BF7854DC BE6599AE 3DBF7319 BCD7235C 3F041CCC 00000000 BF52314E 3F12223D 00000000 3F727B04 3C22FD80 3E29BCD1 3F7C0367 3D6FCD12 3E70A826 BCE91707 BF78B921 BCD7235C 3F008C87 3C28E0F6 BF6B36D8 3BD28E32 3ECA109F 3F4AEA89 3D894EC0 BE18A98D 3F7CC7A8 3D57AE4B 3E48D2F6 B46C577B 3F7B0753 BE3DBAC2 3EF41E67

It looks like some of these are almost certainly floats and others are almost certainly not. And it appears (not shown here) that after a long list of valid floats, there is a long list of DWORDS that aren't valid floats. A list of vertices followed by some table of indices?

• This is really pushing the limits of game dev questions imo. – Kaj Aug 11 '10 at 0:49
• Seems like a perfect game dev question to me. I wish I had an answer for you. – Gregory Avery-Weir Aug 11 '10 at 2:20
• Okay, if it is deemed gamedev, let's do it (didn't mean to be that harsh). It could be any format. A stripped official format or a custom format. Do you have any pointers on where you got it? Looking at the file it is (oftentimes) possible to reverse at least part by looking for repeating patterns, and after that for numbers (often ints, depending on what era game we're talking) that are a multiple of the repeat count. It's worth a shot. – Kaj Aug 11 '10 at 4:18
• Where did you get the file from? What is the name/extension of the file? – JasonD Aug 11 '10 at 6:06
• This question is rather useless as we are not told where the file is from. – jacmoe Aug 11 '10 at 21:24

## 5 Answers

At least part of it looks like a variabe-length list of the format: (number of entities) [(entity ID) times the number]:

00000001 3100026f 00000001 30000112


-> two lists of 1 entity each

00000003 310001f6 310001f6 310001f6


-> one list of 3 entities

What those might mean, though? No idea. It doesn't look like a floating-point number (at least not an IEEE-754 one). It would be some unpractically (for a 3D artist) small numbers, on the order of 1E-9. It's more likely something like a bunch of flags and/or IDs. EDIT: Or byte offsets into the file, for that matter.

EDIT: So far, the format looks like follows (guessing some info):

[amount of sub-models]:uint_32
[amount of data for first (unknown) block]:uint_32
[unknown data]:array of uint_32
[amount of data in the second (unknown) block]:uint_32
[unknown data]:array of uint_32
[amount of vertices]:uint_32
[vertex data]:array of vertex_data


vertex_data looks like follows:

[position]:vector3 of float
[normal]:vector3 of float, normalised
[UV_mapping]:vector2 of float, in the range [0.0f ... 1.0f]
[first unknown normal]:vector3 of float, normalised
[second unknown normal]:vector3 of float, normalised

• Very nice observation! And yes, I'd venture to guess it's indeed an ID with flags encoded. – Kaj Aug 12 '10 at 21:00
• Byte offsets seem unlikely in this case unless it's a 1 gig file, and due to the duplicate nature. IDs + flags would seem more likely imo. But without the complete file there's too little to observe. – Kaj Aug 12 '10 at 22:26
• I meant it as something like ... struct entity { uint8_t flags; /* usually 0x30 or 0x31 */ uint8_t padding; uint16_t offset_into_the_file; } – Martin Sojka Aug 13 '10 at 0:34
• let me look at more of the file and see if that pattern continues. Nice observation indeed! – James Tauber Sep 1 '10 at 11:32

If you have a system running Linux (or Cygwin) you can try the 'file' command on it, if its relatively common it should show up.

You say you found a long list of valid vertices? Draw them in point form; if they resemble a model, then chances are your correct.

From that you could then count how many vertices there are, and then from that count, search the binary for anywhere that count might pop up. This could allow you to find the header which then describes said vertices (ID, count etc).

From this information you could then extrapolate other headers and find similar patterns, and maybe distinguish some more valid data.

Food for thought.

If you think it's a standard file format, then I suggest you just quickly rename the file to different mesh formats and double-click until you get one right. This is assuming you have a 3D editor installed, of course. You might just go down the Wikipedia List of 3D graphics file formats; start with the common ones like blend, max, 3ds, ma, mb, ac, wings, md2, md3...

Also please don't forget to mention what the answer is when you find it, in case by chance someone else has the same question!

But really, either you try all the different formats, or we have to create sample files in each format and open them with a hex editor and look at their headers. I certainly can't find a place that lists all of the 3D format headers. The only one I know off the top of my head is that a Milkshape 3D file starts with the characters "MS3D000000", so yours is not a MS3D file.

It's very possible that this is just a custom format that is not standard. Since most games strip out a lot of unimportant information in their content pipelines, it's entirely possible that the game in question is just rigged to read these files directly with no need of watermarks in the headers.

If that is the case, one way to detect the file format is to reverse engineer the format, process it as the game would and validate that you get sane results during the processing.

00000001 00000001 3100026f 00000001 30000112
or
00000001 00000001 310007b2 00000001 30000112
or
10000006 00000003 310001f6 310001f6 310001f6


If you'd like to reverse engineer this format, you'll need more than just the first 5 dwords. I myself can already see some possible patterns in here, but there is no way to tell whether my conclusions are correct without more data from the file or fiddling with the bytes and trying to load it in the game to see what happens.