Peeking further into MascotCapsule formats
29 Dec 2018
About a year ago, I began to look into adding emulation of MascotCapsule Micro3D API to freej2me. As it turns out, all implementations we can get our hands on are buried deep in native code (supposedly a pure-Java implementation exists… somewhere), the media formats used are undocumented, the company pretends it never exited and so on – nothing new in the world of emulation. We know what the API looks like, and can more or less guess how to re-implement it, but what has been a complete mystery are the proprietary media formats used to store models, textures and animations.
Fortunately, I had saved the vendor’s public documentation and tools before they were removed from their website. This allowed some fuzzing of the converter, which ultimately proved insufficient, and IDA was brought in.
MBAC is the format that describes polygonal models as implemented by the
It uses several kinds of value packing to maximize efficiency. We don’t yet have full understanding of all the fields, but it’s enough to dump geometry and texture mapping. Interestingly enough, a MBAC file doesn’t actually tell you which texture belongs to it. When loading the Figure in game, you have to manually bind a texture through the
In practice, while Galaxy of Fire has 46 different MBAC models, it only uses 5 textures for all of them and they’re plain old BMP images. No fancy encoding, no funky color spaces, no swizzling of texture coordinates! I’m not sure whether I should rejoice or be disappointed.
MTRA files (
com.mascotcapsule.micro3d.v3.ActionTable) contain animation data for Figures.
A MTRA will contain data for each bone (aka “segment”) in the corresponding MBAC. In the simplest case, this will be just one byte that says “the transformation matrix for this bone at any given time is identity”. In more complex cases, you have the usual bunch of keyframes for translation, rotation and scaling. If you know how glTF does animation, the principle is the same. The data model in binary MTRA corresponds directly to the source TRA format, for which we fortunately have documentation.
Although MTRA files don’t use bit-level packing like MBAC, it’s still pretty difficult to guess what is going on just from looking with an hex editor; remember, there are no floats to help you find your way, everything is done in fixed point.
I quickly gave up at trying to correlate several files and find a structure. The temptation of looking under the hood of the converter was strong. MTRA files are generated by the same tool as MBAC files, so I wasn’t starting entirely from scratch. As it turned out though, few functions and data structures are shared between the two code paths and the split between parsing and encoding is much more blurry than in the case of MBAC processing.
There are still mysteries to be solved, such as the 16-byte binary string in the MTRA header. But I’ve had enough for a while.
The next step will be to document this mess and then make a small script that will go over a directory of MBAC files and render a nice gallery of previews. That should be fun.
Bonus: When playing around with offline rendering, I found myself teleported on board a Vossk cruiser. Crap!