- Getting the models
- Setting up Crowbar
- Batch script
- VPK and steampipe
- Common QC commands
- Common Errors
Part 1: Getting modelsDecompiling a model isn't hard, but to start off, you'll need to files to decompile first, if you've downloaded a model replacement mod and they're not in a VPK, you'll already have these files, and you don't need GCFScape (see next paragraph), otherwise you'll need to know the locations of the GCF or VPK archives.
If you've downloaded a mod, you can look through the files of the archive until you'll stumble upon a set of files with the extensions
.phy. Several of these are required to decompile a model, for the sake of simplicity it's safe to say it's easier to just use them all (if you're missing
.dx90.vtx and rename the extension appropriately). Unpack them to someplace easy to find if they're still trapped in their archive. Take note of their location (i.e. keep the folder open) afterwards, you're going to need it for step 2.
If you don't have the models, which is the case for editing default models, open the VPK/GCF archive with GCFScape.VPK archives are in
common\\[game]\\[game abbreviation], you'll want to open
\\[game abbreviation]_pak_dir.vpk most of the time, the others are usually seemingly empty. The GCF archives are in your
steamapps folder, if you can't find a
models folder, try a different archive, if you can't find what you're looking for try thinking outside the box or search the tree systematically;
Select the files with the extensions
.phy and put them in a folder (preferably a folder on your desktop, but not directly on your desktop, if you don't have
.dx90.vtx and rename the extension to make it fit), open the folder and open crowbar.
Setting up CrowbarWith the window containing your model files still open somewhere, browse to the folder containing Crowbar and open it. Drag the
.mdl file onto the Crowbar window and tick the right boxes. If you're looking to replace a model from scratch, you'll want to have
QC file enabled at least as well as
Reference mesh SMD file for reference (otherwise applying your model is going to be a lot of guess work). For Counter Strike: Source (and a few other games) you'll also want
Bone animation SMD files, which contains the animations needed that you can either replace with your own (in which case it serves as reference timelines), or keep intact to preview animations.
You could also untick
QC file if all you want is the
.smd files for use in other mods.
ExtractionClick decompile. If everything's going alright, it should work without a hitch and you now have decompiled model files, along with a
.qc file, and some animation(s) file(s) and a physmodel SMD, whatever you told Crowbar to give you; check the destination folder if that really is the case.
Batch script compilerMy preferred way that's nice and fast is through the use of a
.bat file, or a Windows batch script. Open notepad (or something alike) and paste this in it:
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\\\[game]\\bin\\studiomdl.exe" -game "C:\\Program Files (x86)\\Steam\\steamapps\\\\[name]\\\\[game]\\\\[game abbreviation]" %1
Alternatively for older games:
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\sourceSDK\\bin\\orangebox\\bin\\studiomdl.exe" -game "C:\\Program Files (x86)\\Steam\\steamapps\\common\\\\[game]\\\\[game abbreviation]" %1
To use this properly, replace
\\[game abbreviation] with the proper names, if you're on a 32-bit windows machine, remove the (x86) bit; if you installed Steam elsewhere, go ahead and change that too. Then pause statement makes the script wait for input before ending execution, which is useful for finding errors if you have them. After you've saved in the same folder as your
compiler.bat or something, simply double-click it and let the magic happen. After you're done with it, you can put it in a different folder where you can use it again for quick recycling.
%1 part means you can drop your
.qc file onto your
.bat and it'll take it as argument, alternatively you can rename that bit to match your
.qc, in case you want to compile a batch of
.qc files. Also make sure it's for the right engine, as it is now it'll use the game's tools, so if you're getting jiggy with an older mod, use ep1 instead, use source2006 for BMS, you can get these by downloading the proper SDK Base from the tools section of your library.
To decompile with Crowbar, drag the
.qc file into the window or onto
crowbar.exe. you'll probably have to set up your games first, in the boxes you see after choosing
setup games, you need to put the paths to
gameinfo.txt in the first one and to
studiomdl.exe in the second, these are usually in
C:\\Program Files (x86)\\Steam\\steamapps\\common\\[game name]\\[game abbreviation]\\ganeinfo.txt and
C:\\Program Files (x86)\\Steam\\steamapps\\common\\[game name]\\bin\\studiomdl.exe respectively.
The 3D model editor program Blender, along with the proper plug-ins, can also compile any model directly, which is useful for making fine adjustments to the model directly when something wrong's been spotted in the model viewer and it's become a bit of a nuisance to keep feeding the
.bat file. First you enter an
Engine Path, which is
C:\\Program Files (x86)\\Steam\\steamapps\\common\\[game name]\\bin, in the event of mods, that game name is
SourceSDK\\bin\\[mod engine], in the end it should point to the folder containing a
resourcecompiler.exe for Source 2. After that you have to give it a game to compile for, for base games this path is usually
C:\\Program Files (x86)\\Steam\\steamapps\\common\\[game name]\\[game abbreviation], which is the directory containing a
gameinfo.txt file; for mods this is instead in
C:\\Program Files (x86)\\Steam\\steamapps\\sourcemods\\[game name]\\[game abbreviation].
Now it's time to feed a QC file, which can be relative to the
.blend, then you can compile. it's more of a front-end, which means you'll have to export the model yourself every time before change can be noticed, but this button is just a few pixels away.
Wallworm for 3DSMax
for 3DSMax users, there's WallWorm, a nifty tool that will compile your model without having to do much of anything except having the model itself; it creates a QC file and the textures for you.
VPK and steampipeYou can turn your mod into an add-on by turning the folder you so aptly named something sensible into a
.vpk archive of its own, this can be done by simply dropping that folder onto
vpk.exe, this program is in
\\[game name]\\bin, after which you can safely delete the folder. The process can also be done in reverse to get the folder back without having to open it with GCFScape
Common QC commands
$modelname: the name of the model itself, starts relative to
root/models and must end with
.mdl (remember that the custom folder in your
custom folder is also a root).
- A neat trick will make you compile directly in a custom folder where applicable, namely by prepending the path with
..\\custom\\[mod folder name]\\models; the
.. bit tells the compiler "Go up a folder", which is
root, from there it goes into the custom folder.
- $model/$body: the name of the mesh and the
.smd that contains it in that order; models with facial animations require
$body is recommended.
$cd: changes the directory where the
.smd files are, one is usually given during decompile, but if you place the
.qc in the same folder as all source files, this can and should be removed.
- $cdmaterials: the directory where the
.vmt files are to be found by the model, starts relative to
root\\materials and shouldn't contain the actual material name as those are already stored in the
.smd files themselves; more can be added if need be.
- $sequence/$animation: animations your mesh might have, every model needs at least one. $animation is more extended, though they can be used in conjunction.
- $collisionmodel: contains the collision data, a simplified mesh that represents the boundaries of where the model can touch the world/another prop. Can contain several options enclosed in curly-brackets, the most common of which is
$mass, which are used for models with holes and props that can be pushed respectively.
- $texturegroup: for models with multiple skins, most extensively used in Team Fortress 2 for team coloring (tutorial here), but can be used for any prop that'll have a different look and even for replacing a model by hiding one mesh and showing another.
leaked modelThis happens when the QC points to a file that doesn't exist. Either the file has the wrong name or is a different folder entirely
bbox set errorThis means the
mdldecompiler.qc file came across a
$hbox statement that doesn't comply with the model, namely the bone it's referring to doesn't exist in the model. To fix it, simply remove the offending line, the compiler usually states which bone to pick.
animationsAnimations can be completely broken on default
v_model weapons during decompile and sometimes there's not much you can do about the animations themselves to make a quick fix, but there is a possibility that there is.
Open the offending animation with your favorite plain-text editor and look for values at around 1000 or above (or -1000 and below), take note of the bone number that's affected (the first number of the line, it's usually the root bone causing this) and look for another line with nominal numbers (usually around 0) at the same bone, if you can't find any, use a different animation file, if you can't find any in those, it's probably faster to simply ignore the animations and remove them, you won't be needing them for the next best thing.
The next best thing is to edit the
mdldecompile.qc file to make use of the original animations, this theoretically gives better results than the method above, but will clutter your folders with dependency files. If you haven't already, open the
mdldecompiler.qc file, remove every line mentioning
$animation with extreme prejudice and put in their stead the following:
Change the path to where you want it to be, it's usually best to make this the same as where you put your end result, change the name to something sensible, such as what you put in
_anims after it.
To make this work you'll need to do some more stuff after compiling, namely get a copy of the
.mdl file you decompiled (i.e. has the animations), append the name of the file with
_anims and put it in the same folder as your final
.mdl. it's important to note this can be done after compiling since
$includemodel doesn't actually include the model during compiling but rather make a dependency on that file existing.
For CS:S (and maybe some others too) it could happen your gun will be invisible when doing this, it's not actually gone, just rotated. To fix this, add a
rotate 90 statement in every
$sequence anywhere after the
.smd; if that still doesn't work try -90 instead.
Access ViolationsThis could literally be anything, but it's always something in your QC file; try removing lines one by one to see which one is the cause.
Q_AppendSlash cannot be found in vstdlib.dllInstall your decompiler properly, read the readme, if your decompiler isn't in
sourcesdk\\bin\\ep1\\bin, try putting it there; if that doesn't work, launch the SDK.
Black and magenta checkered modelsThis isn't really in the scope of de/recompiling, but basically it means your model can't find the right
.vmt(s), or the
.vmt can't find the
.vtf file(s). The former can be caused by having incorrect material names on the
.smd, or an incorrect
$cdmaterials that doesn't point in exactly the right direction. The latter is the same, but in the