Compiling a model
This article explains how to use the Source SDK tool
studiomdl.exe, located in the
sourcesdk/bin directory. Studiomdl is used to compile source .SMD files exported from a modeling package, combined with a .QC script file, into a .MDL file that can be used by the engine.
Exporting and Compiling Models
Follow these steps to export a model from XSI and compile it with the Source SDK tools:
- Export the .SMD files somewhere under the SDK's
modelsrcdirectory for the game being compiled for.
- For example, for a Counter-Strike Source model:
- Where username is your Steam Login name.
- Create a .QC file in the same place as the .SMD files. Refer to the QC files that are already in the
sourcesdk_content\cstrike\modelsrcdirectory for examples.
- Ensure the proper Current Game is selected on the SDK Launcher panel (eg. Counter-Strike: Source).
studiomdl.exeon the .QC file. To do this, open a Windows command prompt, and type:
bin\studiomdl -game <YourGameDir> ..\sourcesdk_content\cstrike\modelsrc\mymodel.qc
- Note:This makes use of an environment variable called "sourcesdk" to simplify things. This environment variable is created upon installation of the Source SDK.
- As an alternative to running
studiomdl.exein a command prompt window, a desktop shortcut to
studiomdl.execan be created. Model .QC files can then be "dragged-and-dropped" from a Windows Explorer window to the desktop shortcut to perform the compiling.
- Open Windows Explorer, navigate to the
..sourcesdk\binfolder, right-click on
Send To.. Desktop (create shortcut).
- Note: Disadvantage of the shortcut method - It is difficult to view errors reported by
studiomdl.exeduring the compile process using the shortcut method as the compile window will close immediately after the error is reported. If the model does not appear to compile correctly, use the command prompt window method to determine if
studiomdl.exereports error(s) during the compile process.
- Open Windows Explorer, navigate to the
- If there are no errors with the .QC file or the .SMD files, a .MDL file will be created in the location specified by the
$modelnamekey in the .QC file.
- Model Viewer can now be run in the SDK launcher to open and view the model file.
A model can be placed in a map with the Hammer level editor to see it inside the game.
To place a compiled model in Hammer:
- Open the Hammer Editor from the SDK Launcher.
- Add an entity with the Entity Tool (
generic_actordepending on the model type and game). In the Object Properties or World Model property for the entity, browse the model tree to view and place the model. See the Hammer documentation for information on how to use the Entity Tool.
There are a number of Counter-Strike: Source and Half-Life 2 sample models in the
sourcesdk_content directory that you can refer to for examples. They are compiled in the same way as models you create yourself. For example, you can type these commands at a command prompt to compile the lamp holder sample:
cd "%sourcesdk%" bin\studiomdl ..\sourcesdk_content\cstrike\modelsrc\lamp\it_lampholder1.qc
Sample Models Compile Errors
If studiomdl displays the error: duplicate weightlist pelvisonly when compiling the
male_06_sdk model, the problem may be the inclusion of the file
That file contains a
$weightlist pelvisonly line identical to a line in the included file
- In the
Male_Animations_sdkfolder, make a copy of the
- Rename the copy to
WeaponsAnims_Shared_sdk_X.qci(or other unique name).
- Edit the
WeaponsAnims_Shared_sdk_X.qcifile and comment out the $weightlist line by inserting
//at the beginning of the line.
//$weightlist pelvisonly ...
- Open for editing the file
- Change the line $include "../male_animations_sdk/WeaponAnims_shared_sdk.qci" to
$include "../male_animations_sdk/WeaponAnims_shared_sdk_X.qci" //(or as otherwise renamed above)
- Save the
male_06_sdk.qcto determine if the error was corrected.
* WARNING: (4768124) : ERROR: 'EXCEPTION_ACCESS_VIOLATION' (assert: 1)
This is caused by having the
$shadowlod's curlybracket in the same line as the command. Change: