How To Decompile Portal 2 Models
Postby Skotty » Sat Apr 28, 2012 4:12 pm
Because there are some problems with the newer model version some of the Portal 2 models are using, older decompilers won't work with them.
The Model Decompiler
However, the most up to date decompiler can be found here:
http://www.hl2.boo.pl/applications/MdlDecompilerFixed/MDL%20Decompiler%20Fixed.rar (I also re-hosted this here)
Extract "MDL Decompiler Fixed.exe" to "Steam\steamapps\NAME\sourcesdk\bin\ep1\bin".
Yes, exactly. Episode 1, not Orangebox, not Portal 2.
Missing Model File
Now you have a decompiler for models, but it still won't work for some of Portal 2's models (i.e. the cube (metal_box.mdl)).
The older model formats have files called "modelname.dx80.vtx". In Portal 2, these don't exist anymore.
But because the decompiler needs them, you have to use a trick here.
To create the missing .dx80.vtx file, just copy the normal .vtx file of your model and rename it to "modelname.dx80.vtx". This was the first step.
Changing Version Number
New model version means another version information inside of the .mdl file itself. Now you need a hex-editor of your choice (i.e. XVI32 - again, rehosted here).
Open the "modelname.mdl" file with the hex editor and change "IDST1" at the very beginning of the file to "IDST0". This is a version number the model decompiler can work with.
Now just select that file with the model decompiler and it should work.
Have fun manipulating Portal 2 models!
Note: Animated props (i.e. the incenerator hatch) will screw some joints up and probably crash your decompiler, but the reference SMD will be generated.
Models Using Other Models
Especially player models use other, so called "animation" models as their animation source.
If you want to decompile a model linking to another model, you also have to change the version number of that animation model.
To find out what and where this animation model file is, you have to search with the hex editor in your main model's file for "ani" or "animation".
"models\player\ballbot\ballbot.mdl" links to "models\ballbot_animations.mdl"
Both files need "IDST0" instead of "IDST1", because both files will be decompiled.