Mapmaking & Modding Help and ChatIf you have questions or answers on how to do things while making maps or modding StarCraft II, WarCraft III and StarCraft.
The model files in SC2 use a .m3 extension, which unfortunantly like the .mdx in Warcraft 3 are not human readable... well almost. Looking at some of the simpler models with a hex editor, you can clearly identify where all the verticies and faces of the models are defined. This file doesn't seem to be compressed like .mdx, so it probably is in the native format that the engine reads.
The textures don't use Blizzard's proprietary .blp format, but rather .dds: a known format with plugins readily available (photoshop) to import/convert.
It shouldn't be too much work to come up with an importer. If someone with more skill wants to help me work on a way to import UV data or to write an importer/converter (exporter might take more time...), PM me.
Well I seemed to have hit a block. This format doesn't nicely isolate all the verticies, UV, and normals into separate sections like it did in .mdx. In fact, I can't even find where the verticies are... On the bright side, the face data is very cleanly defined.
The section that defines the verts,tv,normals comes in blocks like these
Code:
1E C5 50 3D DD DB A5 3E 09 A1 C2 3E FF 00 00 00 00 00 00 00 37 B6 D9 00 7E 00 EA 01 C0 58 E6 FF
47 E1 B0 BB DD BF B6 3E 52 A8 61 3E FF 00 00 00 00 00 00 00 17 C9 7F 00 41 00 EA 01 71 8C FE FF
B8 02 A3 BE 5C 9A B6 BD 75 F5 6A 3E FF 00 00 00 00 00 00 00 17 C9 7F 00 41 00 CB 02 8E 79 FE FF
The pattern is [12] FF 7*00 [3] 00 [7] FF. This is true for all models. (and the fourth offset in [7], the one that is 01, 01, 02, seems to serve a special purpose too).
There are exactly 3x as many of these blocks as there are verticies (inferred from the face data), so I'm guessing each one defines one spacial coordinate. The issue I'm having is that not a single float gives a value in the typical range of a vert ~[-1000,-1][1,1000]. The values in [12] resolve to 3 floats that are strictly <|0|, but never too small (probably normals).
No float, taken at any offset gives you a reasonable number for a vert coordinate and there is no other place in the model (looking at the simplest models here) that can contain this information, so it has to be here. In fact the only values that always resolve to floats within a reasonable range (no insane exponents) are the ones in the first 12 bytes of each block.
Scratch that, each block is one vertex (# of blocks actually equalled the number of verticies), although the values still don't make any sense. For different models, the values in the first 12 bytes do exceed |1| as floats, and there is just not enough space to store them as doubles.
Nice, Teal. Those aren't animated or anything, are they?
No, only the mesh. Animations would take the longest time to decipher. Heck I'm struggling trying to find where the UV coordinates are (anyone know if they are allowed to be negative?).
No, only the mesh. Animations would take the longest time to decipher. Heck I'm struggling trying to find where the UV coordinates are (anyone know if they are allowed to be negative?).
Depends on the game engine. For some it's fine, for others bad shit happens if they try to do that. (Obviously I have no idea which kind the SC2 engine is.) But yes, it is possible in a general sense for mesh UVs to go into negative numbered coordinates.