Compiling a model: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(desktop shortcut for studiomdl and first person edit)
Line 5: Line 5:


Follow these steps to export a model from [[XSI]] and compile it with the Source SDK tools:
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 <code>modelsrc</code> directory for the game you're compiling for.
# Export the .SMD files somewhere under the SDK's <code>modelsrc</code> directory for the game being compiled for.
#: For example, for a Counter-Strike Source model:
#: For example, for a Counter-Strike Source model:
#: <code>C:\Program Files\Steam\SteamApps\username\sourcesdk_content\cstrike\modelsrc</code>
#: <code>C:\Program Files\Steam\SteamApps\username\sourcesdk_content\cstrike\modelsrc</code>
Line 11: Line 11:
#: <code>C:\Program Files\Valve\Steam\SteamApps\username\sourcesdk_content\cstrike\modelsrc</code>
#: <code>C:\Program Files\Valve\Steam\SteamApps\username\sourcesdk_content\cstrike\modelsrc</code>
#: Where <i>username</i> is your Steam Login name.
#: Where <i>username</i> is your Steam Login name.
# Create a [[Qc|.QC]] file in the same place as your .SMD files. You can refer to the QC files that are already in the <code>sourcesdk_content\cstrike\modelsrc</code> directory for examples.
# Create a [[Qc|.QC]] file in the same place as the .SMD files. Refer to the QC files that are already in the <code>sourcesdk_content\cstrike\modelsrc</code> directory for examples.
# Make sure you have the proper '''Current Game''' selected on the '''SDK Launcher''' panel (eg. Counter-Strike: Source).
# Ensure the proper '''Current Game''' is selected on the '''SDK Launcher''' panel (eg. Counter-Strike: Source).
# Run <code>studiomdl.exe</code> on your .QC file. To do this, open a Windows command prompt, and type:
# Run <code>studiomdl.exe</code> on the .QC file. To do this, open a Windows command prompt, and type:
#: <code>cd "%sourcesdk%"</code>
#: <code>cd "%sourcesdk%"</code>
#: <code>bin\studiomdl ..\sourcesdk_content\cstrike\modelsrc\mymodel.qc</code>
#: <code>bin\studiomdl ..\sourcesdk_content\cstrike\modelsrc\mymodel.qc</code>
#: <br>
#: <br>
#: {{note|This makes use of an environment variable called "sourcesdk" to simplify things. This environment variable is created upon installation of the Source SDK.}}
#: {{note|This makes use of an environment variable called "sourcesdk" to simplify things. This environment variable is created upon installation of the Source SDK.}}
# If there are no errors with the .QC file or your .SMD files, then you will have a .MDL file in the location specified by the <code>$modelname</code> key in the .QC file.
# As an alternative to running <code>studiomdl.exe</code> in a command prompt window, a desktop shortcut to <code>studiomdl.exe</code> can be created. Model .QC files can then be "dragged-and-dropped" from a Windows Explorer window to the desktop shortcut to perform the compiling.
# You can now run '''[[Half-Life Model Viewer|Model Viewer]]''' in the '''SDK launcher''' and open your model file.
#: Open Windows Explorer, navigate to the <code>..sourcesdk\bin</code> folder, right-click on <code>studiomdl.exe</code> and select <code>Send To.. Desktop (create shortcut)</code>.
#: <br>
#: {{note| <b>Disadvantage of the shortcut method</b> - It is difficult to view errors reported by <code>studiomdl.exe</code> during 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 <code>studiomdl.exe</code> reports error(s) during the compile process.}}
# 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 <code>$modelname</code> key in the .QC file.
# '''[[Half-Life Model Viewer|Model Viewer]]''' can now be run in the '''SDK launcher''' to open and view the model file.


== Placing models ==
== Placing models ==

Revision as of 07:53, 26 June 2006

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:

  1. Export the .SMD files somewhere under the SDK's modelsrc directory for the game being compiled for.
    For example, for a Counter-Strike Source model:
    C:\Program Files\Steam\SteamApps\username\sourcesdk_content\cstrike\modelsrc
    or
    C:\Program Files\Valve\Steam\SteamApps\username\sourcesdk_content\cstrike\modelsrc
    Where username is your Steam Login name.
  2. 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\modelsrc directory for examples.
  3. Ensure the proper Current Game is selected on the SDK Launcher panel (eg. Counter-Strike: Source).
  4. Run studiomdl.exe on the .QC file. To do this, open a Windows command prompt, and type:
    cd "%sourcesdk%"
    bin\studiomdl ..\sourcesdk_content\cstrike\modelsrc\mymodel.qc

    Note.pngNote:This makes use of an environment variable called "sourcesdk" to simplify things. This environment variable is created upon installation of the Source SDK.
  5. As an alternative to running studiomdl.exe in a command prompt window, a desktop shortcut to studiomdl.exe can 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\bin folder, right-click on studiomdl.exe and select Send To.. Desktop (create shortcut).

    Note.pngNote: Disadvantage of the shortcut method - It is difficult to view errors reported by studiomdl.exe during 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.exe reports error(s) during the compile process.
  6. 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 $modelname key in the .QC file.
  7. Model Viewer can now be run in the SDK launcher to open and view the model file.

Placing models

You can place a model with the Hammer level editor to see it inside the game.

To place a compiled model in Hammer:

  1. Open the Hammer Editor from the SDK Launcher.
  2. Add a prop entity with the Entity Tool (prop_static, prop_dynamic or prop_physics_multiplayer, depending on your model type). In the Object Properties 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.

Sample Models

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 Male_Animations_sdk/WeaponsAnims_Shared_sdk.qci.

That file contains a $weightlist pelvisonly line identical to a line in the included file male_shared_XSI_sdk.qci.

  • In the Male_Animations_sdk folder, make a copy of the WeaponsAnims_Shared_sdk.qci file.
  • Rename the copy to WeaponsAnims_Shared_sdk_X.qci (or other unique name).
  • Edit the WeaponsAnims_Shared_sdk_X.qci file and comment out the $weightlist line
"//$weightlist pelvisonly ..."
  • Open for editing the file male_06_sdk.qc.
  • 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.qc file.
  • Recompile male_06_sdk.qc to determine if the error was corrected.

See also