How To Decompile Portal 2 Models

Avatar
Skotty
671 Posts
Posted Apr 28, 2012
### 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:
"models\player\ballbot\ballbot.mdl" links to "models\ballbot_animations.mdl"
Both files need "IDST0" instead of "IDST1", because both files will be decompiled.

Advertisement
Registered users don't see ads! Register now!
Avatar
HMW
806 Posts
Posted Apr 29, 2012
Replied 17 hours later
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

Avatar
Skotty
671 Posts
Posted Apr 29, 2012
Replied 3 hours later
Studio Compiler is a bit older and works very instable on my Win7 64 Bit OS.
Avatar
Lpfreaky90
2,842 Posts
Posted Apr 29, 2012
Replied 28 minutes later
It's still surprising you even got that somewhat working on win7.
But very useful thread skotty I should totally find some time to look into this stuff!
Avatar
HMW
806 Posts
Posted Apr 30, 2012
Replied 19 hours later

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

Avatar
Zorro3k6
4 Posts
Posted Dec 29, 2012
Replied 7 months later

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

Avatar
Skotty
671 Posts
Posted Dec 29, 2012
Replied 1 hour later
This model uses another model as source for it's animations. This additional one gets decompiled, too.
It uses "models\ballbot_animations.mdl".

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

Avatar
Zorro3k6
4 Posts
Posted Dec 29, 2012
Replied 9 minutes later
Ah, OK, thanks. I'll take a look at that model too and see how it's different from the ballbot.mdl. Thanks.
Avatar
boctroy
51 Posts
Posted Aug 09, 2013
Replied 7 months later
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.

Avatar
Gemarakup
1,183 Posts
Posted Aug 10, 2013
Replied 21 hours later
I think those models have their own animations.
Avatar
boctroy
51 Posts
Posted Aug 10, 2013
Replied 4 hours later
From what i understand the models are separate from the animation. The models have a set of bones which the animation file reads and moves the bones accordingly.
Avatar
Skotty
671 Posts
Posted Aug 11, 2013
Replied 14 hours later
$includmodel "player_animations.mdl" means it uses animations from that file, yes. If your own model has the same bone structure and naming as chells/the one this player_animations.mdl uses, your model will have all animations from there, too.
Avatar
boctroy
51 Posts
Posted Aug 11, 2013
Replied 5 hours later
Thanks for the reply.
Now to test things out, I decompiled chell, then recompiled her, looked into the model viewed and she had the list of sequences however she did not animate when I selected one. Is there something I am missing?
Avatar
FelixGriffin
2,680 Posts
Posted Aug 11, 2013
Replied 3 hours later
Joints tend to get horribly screwed up when you decompile Portal 2 models. I wouldn't recommend it for something you want to animate.
Avatar
boctroy
51 Posts
Posted Aug 11, 2013
Replied 1 hour later
OK. So if I use the valve bipeds that I downloaded, I have to use the player_animations.MDL file that is unique to that biped set. Or grab chells biped set and attach that to my model.
Am I correct?
Avatar
FelixGriffin
2,680 Posts
Posted Aug 11, 2013
Replied 3 hours later
I'm not sure if it will work, but you can try. I don't know if Portal 2 uses the standard biped joint arrangement.
Avatar
Skotty
671 Posts
Posted Aug 12, 2013
Replied 9 hours later
You don't even have to decompile the model. Just take a look on the Chell model via ModelViewer and make sure what names it's bones have.
Avatar
boctroy
51 Posts
Posted Aug 12, 2013
Replied 10 hours later
Alsome!! thanks, my model is working. But when i pick up a portal gun it moves along the ground with the player. I think i read a post on this a while back, but does anyone know how to fix this.
Avatar
Skotty
671 Posts
Posted Aug 12, 2013
Replied 33 minutes later
You need to declare an attachment bone/point for weapons. They have a given name, just take a look on Chell's model.
Advertisement
Registered users don't see ads! Register now!
Avatar
boctroy
51 Posts
Posted Aug 17, 2013
Replied 4 days later
Do you know if it is possible to let me play as my model in co-op so that the other computer can see me playing as my model. I don't think it is possible without it being a my own custom hammer map.
Any advise would be appreciated.