Go Back   TF2Maps.net > Discussion > Mapping & Tutorials > Tutorials

Notices

Reply
 
Thread Tools

[Tutorial] The complete guide to decompiling and recompiling models!
Old 08-20-2009, 07:47 AM   #1
Psy
What sick man sends babies to fight me?
 
Psy's Avatar
 
Psy is offline
Posts: 1,461
Thanks: 489
Thanked: 874
Default [Tutorial] The complete guide to decompiling and recompiling models!

In chat theres always people asking how to reskin models. It's something that's quite difficult to explain in chat due to it being quite a laborious process so here's the complete guide on how to decompile and recompile a model with new skins!

The Process

The process is quite simple. Here's a simple list.
  1. Extract the model
  2. Hex edit it
  3. Decompile it
  4. Edit it's QC
  5. Recompile it
  6. DONE!

So that's the process in it's simplest form.

For this tutorial we will recompile one of the props_mining rocks with a new name.

What you need

Tools

TIP: Place GUIStudioMDL in the 'sourcesdk/bin/orangebox/bin/' folder and MDLDecompiler in the 'sourcesdk/bin/ep1/bin' folder and create shortcuts for both of them on the desktop so they're easier to get to.


Step 1: Extract the model

First off, load up GCFScape then open up 'team fortress 2 content.gcf' which can be found in the 'steam/steamapps/' folder. Then you can navigate to the models using the menu or you could simply search for the model we are looking for. To do this choose Edit > Find then type 'rock001'.

Now you'll have a list of files like so.



You will see a whole bunch of files with the name 'rock001' and all these files are neccesary to successfully recompile it.

Select them all then right-click and choose [i]'Extract...'/i]. Place them any place you like and that's that!


Step 2: Hex edit the model

Cannonfodder's MDLDecompiler was coded for use with EP1 models but models in the Orangebox engine use a different model version which the decompiler cannot understand but - do not fret! - there is a simple way around this which requires the ever useful Notepad++.

Now, open it up then load up 'rock001.mdl' and what you'll get is a lovely bunch of seemingly random characters as shown below.



What you need to do is change the 5th character to a comma (,) like so.

TIP: Not all models will have the character '0' for the 5th byte but you still perform the exact same edit.



Save up and you're ready to decompile.


Step 3: Decompile the model

Open up Cannonfodder's MDLDecompiler and you'll be presented with this.



First of all, make sure you untick 'Use Steam File Access...' else you'll most likely get some error message about it being unable to access a Steam app.

It's fairly straightforward what you have to do. Choose where the model file is (rock001.mdl) and choose where you want the decompiled version to go. Once this is done hit the big magic button labeled 'Extract'.

Upon the completion of this process you should end up with the following files in the folder destination you set earlier.




Step 3: Edit the .QC

Open up Notepad++ if you already haven't and open the 'mdldecompiler.qc' file in the folder with the decompiled files and here's what you should see.



If you're not familiar with .QC files then here's a quick run down of the most important properties.
  • $cd this points to the location of the files to decompile
  • $modelname this is the name of the model once it is compiled
  • $model 'body this points to the location of the SMD which is the model itself
  • $cdmaterials this points to the location of the model's texture(s)
  • $sequence this defines the animations of the model and even if is static it will have an 'idle' animation
  • $collisionmodel this points to the collision model obviously
  • $scale this property can be used to scale models up or down. Useful for recompiling props for skybox usage
  • For more commands visit this VDC page.

For this tutorial we are simply going to recompile the model with a different name. To do this simply edit '$modelname' to '$modelname "props_recompiled\rock001_recompile.mdl"'.

Write '$staticprop' so that it is registered as a prop_static and heed this warning...

TIP: Recompiled models with $staticprop are always rotated -270 degrees around the Z axis. To fix this add the property '$origin 0 0 0 270' within the QC.

Now you should (hopefully) have something like this.



Save and open up GUIStudioMDL.


Step 4: Recompile the model

First you may notice if you haven't run GUIStudioMDL is this warning.



Do not fear! All you need to do is click 'OK' and when you're in the program go to Config > Set Orange Box Tools Path and point to 'sourcesdk\bin\orangebox\bin' (lots of bin folders as you can see)

Once set up, choose the 'Orange Box' radio button and on the left-side you'll see a drop-down list with all the games you own running the Orangebox engine.



Now, click File and open up the file 'mdldecompiler.qc' found in the folder.

Before you compile go to your 'tf/models/' folder (make one if you don't have one) and create the folder 'props_recompiled'.

With that done and out of the way click the magic button labeled 'Compile' and with any luck it shall start to compile the model. You should end up with the final line saying 'Completed "mdldecompiler.qc'.


Step 5: Checking the result!

Pop on over to your 'tf/models/props_recompiled' folder and you should see the following.



Can it be true? Has it worked? There is only one way to find out. To the Source SDK!

Open up the Model Viewer then load up your new model under 'props_recompiled\rock001_recompile'.



Ta-da! It's complete and by ticking the 'Physics Model' checkbox we can tell that even the collision model is there!
__________________
Lighthouse | Nightfall | Converge | Overwatch | My Portfolio

Last edited by Psy; 08-25-2009 at 08:30 AM..
  Reply With Quote
The Following 19 Users Say Thank You to Psy For This Useful Post:

Old 08-20-2009, 07:49 AM   #2
Owlruler
Mark of Owl Approval
 
Owlruler's Avatar
 
Owlruler is offline
Posts: 896
Thanks: 39
Thanked: 246

Thanks!
__________________
I am a bad person, please attack me with various Owl-related insults.
  Reply With Quote

Old 08-20-2009, 07:50 AM   #3
Mick-a-nator
Veteran Member
 
Mick-a-nator's Avatar
 
Mick-a-nator is offline
Posts: 519
Thanks: 100
Thanked: 228
Blog Entries: 1

Cheers, I think I'll be needing this soon.
__________________
Want to start modelling in Blender for TF2? Read this first!
  Reply With Quote

Old 08-20-2009, 11:44 AM   #4
Mick-a-nator
Veteran Member
 
Mick-a-nator's Avatar
 
Mick-a-nator is offline
Posts: 519
Thanks: 100
Thanked: 228
Blog Entries: 1

Hmmm, I get an error when trying to use MDLdecompiler (its in the right place and is the latest version) which says "The procedure entry point Q_AppendSlash could not be located in the dynamic link library vstdlib.dll." What do I do to fix that?

EDIT: FIXED! just moved MDLCompiler.exe to the ep1 bin folder, try that anyone who also gets this message
NOTE: Putting it in the half-life 2 bin folder doesn't work either, ep1 bin appears to be the only solution.
__________________
Want to start modelling in Blender for TF2? Read this first!

Last edited by Mick-a-nator; 08-20-2009 at 11:56 AM..
  Reply With Quote
The Following User Says Thank You to Mick-a-nator For This Useful Post:

Old 08-20-2009, 12:01 PM   #5
Psy
What sick man sends babies to fight me?
 
Psy's Avatar
 
Psy is offline
Posts: 1,461
Thanks: 489
Thanked: 874

Thanks. I've updated the post to reflect where MDLDecompiler should really go.
__________________
Lighthouse | Nightfall | Converge | Overwatch | My Portfolio
  Reply With Quote

Old 08-20-2009, 12:07 PM   #6
The Political Gamer
Hey look its the guy who posts too much!
 
The Political Gamer's Avatar
 
The Political Gamer is offline
Posts: 3,899
Thanks: 2,810
Thanked: 1,275
Blog Entries: 16

Thanks man!
__________________


My other maps: ctf_assembly | cp_trestle | pl_uphill | cp_grinder |
Quote:
Originally Posted by midget31394 View Post
I'm going to kill you slowly.
  Reply With Quote

Old 08-20-2009, 12:22 PM   #7
Joodude
Mappers gonna Map
 
Joodude's Avatar
 
Joodude is offline
Posts: 684
Thanks: 722
Thanked: 328

How would you go about giving a model another skin?
__________________
Quote:
Jake | TF2maps.net: HOLY CRAP MEATBALL SUB IS THE NEW UNLOCK
Jake | TF2maps.net: BURN SPY'S EYES WITH MELTING CHEESE
  Reply With Quote

Old 08-20-2009, 12:23 PM   #8
A Boojum Snark
Toraipoddodezain Mazahabado
 
A Boojum Snark's Avatar
 
A Boojum Snark is offline
Posts: 3,364
Thanks: 100
Thanked: 3,249

You can also get syntax highlighting for Source stuff in Notepad++ with this. But the main reason I link to it is the bit at the bottom: you can compile the model directly through N++
__________________
(>^_^)>---[] Mapper Kirby says you must get:
Ultimate Mapping Resource Pack!
  Reply With Quote

Old 08-20-2009, 12:31 PM   #9
Psy
What sick man sends babies to fight me?
 
Psy's Avatar
 
Psy is offline
Posts: 1,461
Thanks: 489
Thanked: 874

Quote:
Originally Posted by Joodude View Post
How would you go about giving a model another skin?
Point to the where the new texture is under $cdmaterials.
__________________
Lighthouse | Nightfall | Converge | Overwatch | My Portfolio
  Reply With Quote

Old 08-20-2009, 12:32 PM   #10
Rexy
July 4th December 2010
 
Rexy's Avatar
 
Rexy is offline
Posts: 1,034
Thanks: 514
Thanked: 998

For those of you afraid of hex editing, there's a much more simple process to be had by using Crafty (nem's tools) which will spit out .obj files for your 3D software to read.
  Reply With Quote
Reply

Tags
decompile, models, recompile, reskin

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -5. The time now is 04:53 PM.

© 2008 Valve, the Valve logo, Team Fortress 2, the Team Fortress 2 Logo, Steam, the Steam logo, Source,
the Source logo, and Valve Source are trademarks and /or registered trademarks of Valve Corporation
in the United States and other countries.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management by RedTyger