Please or Register to create posts and topics.

How To Decompile Portal 2 Models

Page 1 of 3Next

This Tutorial is for CannonFodders old MDL Decompiler. Don't use it anymore! Instead use Crowbar!

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

Download MDL Decompiler (Fixed Version) here: http://www.erikszeug.de/files/Programmi ... 20Fixed.7z
Included are all .dlls of old SourceSDK, so you don't need it. It's a "stand-alone" version now.

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).
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".

For example:
"modelsplayerballbotballbot.mdl" links to "modelsballbot_animations.mdl"
Both files need "IDST0" instead of "IDST1", because both files will be decompiled.

Useful info! Although StudioCompiler has been working great for me so far. Its only problem is that it expects subfolders to exist in the extract location for the various SMDs. (Extract, read error message, create requested folder, extract again, new error message, etc...)

Still bookmarking this thread in case I run into problems in the future :P

Sendificate series: Sendificate | A Beam Too Far | Airtime | 302
Other Portal 2 maps: Medusa Glare
Portal 1 maps: Try Anything Twice | Manic Mechanic

Studio Compiler is a bit older and works very instable on my Win7 64 Bit OS.

It's still surprising you even got that somewhat working on win7.
But very useful thread skotty :thumbup: I should totally find some time to look into this stuff!

Skotty wrote:
Studio Compiler is a bit older and works very instable on my Win7 64 Bit OS.

Weird... I also have win7 x64 and the only problem I have is that trial and error thing with the folders. I haven't decompiled huge numbers of models though, so I may have been lucky so far...

Sendificate series: Sendificate | A Beam Too Far | Airtime | 302
Other Portal 2 maps: Medusa Glare
Portal 1 maps: Try Anything Twice | Manic Mechanic
Skotty wrote:
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/MdlD ... 0Fixed.rar

Extract "MDL Decompiler Fixed.exe" to "SteamsteamappsNAMEsourcesdkbinep1bin".
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).
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.

Thank you so much for making this. I kept trying to decompile the mdl files of Atlas and P-body to use in some animations, but I couldn't figure out what the .dx80.vtx file was. I kept seeing the .dx90.vtx file, but not the one it was looking for. It was very confusing. So thanks for explaining how to do this.

With that said, I'm still having a problem. I followed your directions to the letter, but I keep getting the same problem. The smd is created, but it's named ballbot_lod0.dmx.smd and there's another file named mdldecompiler.qc. Both files are 0 bytes. I tried to load the smd, despite it being 0 bytes, into 3Ds Max 2012 just to see what will happen. Naturally, 3Ds Max crashes. Is there something I'm missing? How do I get just the smd file with actual data? I really want to make custom animation on them. Help please?

Edit: Never mind, I fixed it. I'm not really sure what the problem was though. But what I did was exit the mdldecompiler, delete the dx80.vtx file, copy the original .vtx file again, and rename it back to the dx80.vtx. Then I opened the dcompiler again and it worked fine. I was able to load the smd into 3Ds Max with no problem. Of course part of his right arm is missing for some reason. But that's an easy fix. Thanks for all your help. :)

This model uses another model as source for it's animations. This additional one gets decompiled, too.
It uses "modelsballbot_animations.mdl".

Open this file and replace it's "IDST1" to "IDST0", too, and it works (tested).

Ah, OK, thanks. I'll take a look at that model too and see how it's different from the ballbot.mdl. Thanks. :)

I know this is a little old, but i have been looking on adding my own custom characters into portal 2 while keeping chell's animatinos. I realize there is information on adding one in half life 2 and other games.
My questions are:
*is it possible in portal 2;
*and if so, i have tried this: get your model, attach it to a standard valve biped that i see
floating around the internet, and put $includmodel "player_animations.mdl" into the .qc file.

I am sure i am missing something.
Any help would be appreciated.

I think those models have their own animations.

Page 1 of 3Next