Porting GoldSrc content to Source

From Valve Developer Community
Jump to navigation Jump to search
English (en)日本語 (ja)Русский (ru)Translate (Translate)
Merge-arrows.png
It has been suggested that this article or section be merged into Converting Textures. (Discuss)

Porting a Goldsource model to the Source engine is a short process. For best results, have all original source content ready for the model: original 3d package file, textures, and .QC file. SMD files may also be useful if the original 3d package file is unavailable.

For the most part, porting models is straightforward: Set the VPROJECT properly, convert old textures to VTF format, tweak .QC file to include new Source syntax, and then compile the new content into a new Source model file.

Set VPROJECT

Main article:  Game Directory

The VPROJECT variable is referenced by several Source SDK tools: basically, it directs applications where to find or place compiled models (.MDL) and materials (.VTF). Studiomdl and Vtex both use VPROJECT to place compiled models and materials in the correct directory. Half-Life Model Viewer (HLMV) uses VPROJECT to find model materials. To set the VPROJECT (Current Game), use the Source SDK launcher or VConfig.exe.

Convert old textures to new materials

See also:  Material system

In the GoldSrc engine, .BMP textures designed for Models were compiled into the .MDL file, while the other .BMP textures are stored in the .WAD file. However in the Source engine, developers export textures as .VTF files, which are simply referenced and not actually compiled into the .MDL file.

Originally, in the preliminary release of the Source SDK, developers were confined to using the included command-line exporter Vtex to compile materials. Since then, a variety of community produced tools provide Windows-friendly GUIs and interfaces, batch conversions, and texture previewing. VTFedit is highly recommended; though there are also other tools available. This tutorial will assume that the user is using Vtex.

Main article:  Creating a Material

First, convert all old texture files to .TGA format, using Photoshop or a similar image editing application.

  1. Create a shortcut to vtex.exe on your desktop. Vtex.exe is located in the SourceSDK\bin directory.
  2. Right-click the shortcut and select the "Properties" option.
  3. In the "Target" box, add -mkdir -shader vertexlitgeneric after vtex.exe with a space between them. Click OK.

Use this shortcut when converting new materials by dragging each .TGA file onto the desktop shortcut itself. The argument "-mkdir" will automatically create the materialsrc directory. The argument -shader VertexLitGeneric tells Vtex to automatically make a new .VMT that points to the .VTF as the diffuse texture.

Note.pngNote:The VertexLitGeneric shader is only used for models; it should not be used for sprites or brushes. Check the Materials documentation for more info.

Export .SMD files

If the original 3D model file is lost, decompile with Crowbar Crowbar.

Modify .QC file

Main article:  Qc

While old .QC files will work with the new Studiomdl, there have been syntax changes for Source models to compile correctly.

  • $modelname now works in conjunction with VPROJECT and automatically assumes a directory output location of VPROJECT + a 'models' directory. For example: C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models. So if $modelname were set to "player\myplayer.mdl", Studiomdl will compile the model and write it to C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models\player\myplayer.mdl.
  • Replace $cdtexture with $cdmaterials. $cdmaterials also uses VPROJECT and assumes the output directory to be VPROJECT + 'materials' directory. For example: C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials. Break the material directory tree up based on context - in this case, a model. Keeping the same example as in the $modelname step above, set $cdmaterials to "models\player" so that the model will look for materials in the directory C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials\models\player.

Create a Collision Model (Physbox)

A "collision model" is the simplified mesh that defines how the model will interact with the world when it is being physically simulated. This document will not cover the details of creating a physbox. While Studiomdl will create a physics hull if one is not specified, the result will be extremely simple. It will not "vacuum seal" the model; it will simply connect all the furthest points of the model together directly. To demonstrate, imagine looking down on a model and that it is shaped like a plus sign.

The most correct collision hull would resemble the plus sign.

Phys demo2.jpg

The automatically generated collision hull would connect all the most extended parts directly.

Phys demo3.jpg

In some cases, it is acceptable if the object is insignificant or does not interact with the player or the game world. However, if the example object were a revolving door, then this physbox would be unacceptable.

Compile the Model

Main article:  Compiling Models

The actual process of compiling hasn't changed outside of Studiomdl using VPROJECT. To associate .QC files with Studiomdl for double-click compiling:

  1. Open a Windows Explorer. (Windows Key + E)
  2. At the top of the window, click "Tools", then "Folder Options...".
  3. Click the "File Types" tab then scroll down to QC. If you do not have a QC extension in your list, you can add it by hitting the "New" button below the list, and enter "QC" in the box. Hit "OK" to enter the extension into the list.
  4. Click the QC extension. It should become highlighted.
  5. In the "Details for 'QC' extension" area of the "Folder Options" panel, click the "Change..." button to the right of the text "Opens with:".
  6. Click the "Browse..." button at the bottom right of the "Open With" panel.
  7. Browse to the file "studiomdl.exe" in the SDK tools. Click the "Open" button.
  8. Make sure that "studiomdl.exe" is highlighted in the "Open With" panel. Click the "OK" button.
  9. Close the "Folder Options" panel with the "Close button.

Check the Model with the Half-Life Model Viewer

Find the Half-Life Model Viewer in the "Bin" directory with the rest of the Source SDK tools, and open the model. Some common problems:

  • A black and pink checkerboard texture: the materials are not in the location specified by the .QC file or the materials did not compile correctly (you can check that with hammer for example).
  • Incorrect collision hull: select the "Render" tab and click the "Physics Model" checkbox to view the model's collision hull.

Mapping

Hammer 4.x has backwards compatibility for both .map files and .rmf files. Attempting to open .map files in Hammer 4 can sometimes result in the application freezing or crashing; if this happens, open it in Hammer 3.5 or JACK first, save as RMF/VMF, then open in Hammer 4.

See also