Loading textures for models first will need the textures exported from the MIA files. I’ve documented the MIA format in a previous post ( Texture Files – Shutokou Battle Online (sb-online.net) ) Each car model has an associated MIA file. So I export the textures using my utility place them in the folder but this wasn’t enough to get the textures to load in blender. So a quick Google search about loading textures with OBJ points me to another file which is needed for the texture details. This file is MTL. This file is then to be referenced in the OBJ using the mtllib attribute.

So reading up on the MTL format (here) it requires a few attributes for each material. These are material name that is specified in the OBJ (newmtl), ambient colour (Ka), diffuse colour (Kd), specular colour (Ks), specular highlights (Ns), optical density (Ni), dissolve (d), illumination (illum) and the colour texture file (map_Kd). The Object3 has these values named as such (although I’m not 100% sure if they are completely accurate). So I add the ability to generate a MTL file along with the OBJ. The syntax for these changes are:

python mmdl2obj.py -m mmdlfile.mmdl -o objfile.obj -mtl mtlfile.mtl

I prefix the map_Kd values with \textures\ so that I can keep the textures in a subfolder and then add .png as a suffix. Models like the course have loads of textures so it’s best I can keep it organised. I used my MIA manager util to export all textures and place them into a subfolder to the model called “textures”. Load the model in Blender and:

Nothing. The colour doesn’t seem right either. But turns out I initially had the dissolve value after the RGB values in the Object3 structure. Moving it to after the Ka fixed that. But still no texture. Then discord to the rescue. I just need to change the viewport colour to texture also changing the ligthing to MatCap brightens things up a bit also:

The textures then appear. However Things aren’t quite right. The textures are upside down and the car is left hand drive not right hand drive as it should.

So turns out I need to invert the X vertices value and the V value for the textures. This has a side affect in that the normals are then inside the model instead of outside. It isn’t as simple as inverting these values. Instead we just need to reverse the order in that the faces are loaded. Still pretty simple. Instead of 1/1/1 2/2/2 3/3/3 I need to make it 3/3/3 2/2/2 1/1/1. With those changes I get the model as expected:

Now I want to see if we can load at least part of the course. The course is made up of many MMDL’s. A simple line in command prompt can be used to run the mmdl2obj.py against the parts. As the parts all use the same material names of “one-object” I’ve added a -u switch to mmdl2obj.py which prefixes the file name to all materials in the file. So to run it against many course files, as they are numbered it makes it simple:

for /L %V IN (0,1,9) DO python mmdl2obj.py -m PC_000%V.mmdl -o PC_000%V.obj -mtl PC_000%V.mtl -u
for /L %V IN (10,1,99) DO python mmdl2obj.py -m PC_00%V.mmdl -o PC_00%V.obj -mtl PC_00%V.mtl -u

This will convert the first 100 pieces (providing they are all in the same folder. The textures needed are buil.mia and course.mia. There are some more but those will be the majority. Export them all into a “textures” sub-folder where the obj’s are. You then need to add the “Wavefront Batch” import addin in blender to import them all.

Blender appears to have an issue loading the course parts. Spamming / on the numberpad gets them to appear intermittently. That’s an issue with Blender or more likely user error but it kind of works at least.

If you are interested in giving it a go or contributing check out the github: tofuman0/mmdl-processing: A collection of python scripts that can be used to read, process and convert MMDL model format used in SBOL (github.com)

Categories: Game Assets