Porting Goldsource content to Source
Porting your current Goldsource .mdl to the Source engine is a short process. For this process, I’m going to assume that you have all the original source content for the model. I’m referring to the original 3d package file, textures and .qc file at the bare minimum. If you have the .smd files, this could save you some time but not in every case, and if you have the original 3d source, then you can always re-export new .smd’s. If you do not have the source content, don’t loose hope. See the end of this document for instructions on how to decompile your .mdl file then start from the beginning.
Step 1. VPROJECT
The first thing to take care of is your VPROJECT environment variable. This variable is referenced by a handful of Source tools, 3 of which you will use to port your models. Studiomdl and Vtex both use VPROJECT to know where to place your compiled models and materials respectively. Half-Live Model Viewer (HLMV) uses VPROJECT to find the materials your model uses. If you have already set your VPROJECT, skip to step 2.
- To set your VPROJECT, first right-
Step 2. Convert old textures to new materials
In Goldsource, .bmp textures were built right into the .mdl. However in Source, we now author our source files (diffuse, specular, bumpmaps, etc) as .tga files then use the tool Vtex to convert the .tga into a .vtf, which is referenced by the .mdl but not compiled into it. In addition to .vtf’s, there are .vmt files. These files are just text files that define the attributes of your material. The primary things in the .vmt are the pointers to the different versions of the texture, namely the diffuse, specular, and bump. However there are also other arguments that can be set. For more information, see the Materials documentation in the SDK.
Before we compile any .tga’s, I should point out that you should create a ‘materialsrc’ and ‘materials’ directory inside your mod directory. For example c:\hl2\mymod\materialsrc and c:\hl2\mymod\materials. The ‘materialsrc’ directory is where you should keep all of your original source content (your .tga’s). The materials directory is where Vtex will output all your .vmt’s and .vtf’s to. Of note is that if you create a subdirectory in the ‘materialsrc’ directory and also have that directory mirrored in your ‘materials’ directory, when you compile a .tga from that directory with Vtex it will automatically put the .vmt and/or .vtf into that directory. So for example if you make both c:\hl2\mymod\materialsrc\player and c:\hl2\mymod\materials\player, when you run Vtex on a file inside the materialsrc\player directory, the .vmt/.vtf will be exported into the materials\player directory. If you are not using the –mkdir Vtex argument, and the directories are not mirrored, you will get an error when using Vtex so make sure you have equivalent directories if you run into a problem.
I’d also like to preface with a few tool tips in reference to Vtex that I use to make my life a little easier. The first is a shortcut to Vtex that will create a .vmt for you, the second is a quick way to re-compile a .tga assuming you already have a .vmt for the material.
Tip #1 Shortcut for Creating NEW materials
- Create a shortcut to vtex.exe on your desktop. Vtex.exe is located in your SourceSDK\bin directory.
- Right-Click the shortcut and select the ‘properties’ option.
- Click OK.
You should use this shortcut whenever you need to convert a texture to a material that you have never converted before. The argument “--
NOTE: The argument “-
Tip #2 TGA to VTF right-click shortcut
- Open a Windows Explorer window (Windows key + E).
- Go to Tools > Folder options.
- Click TGA so that it is highlighted.
- Click in the little box next to “Use DDE".
- Hit OK on all the panels to accept the changes.
You can now right-
Now to convert your textures, we can use our new tools to save us some typing in a DOS window.
- Save all your .bmp’s as .tga’s with your favorite image editing application into their appropriate materialsrc directory.
- Drag your .tga onto the new Vtex desktop shortcut you’ve created.
- Do this for all the textures for your model.
NOTE: For a much more in depth explanation of materials and their options, see the Materials documentation.
Step 3. Tweak the .qc file
For the most part old .qc files will work with the new Studiomdl, however there have been a few syntax changes that you will need to implement in order for the model to build correctly.
Step 4. Collision Model (aka Physbox)
A "Collision Model" (aka "Collision Hull," "Physics Hull," or "Physbox") 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, but I would like to quickly discuss if you need to create one by hand or have Studiomdl create one for you.
To demonstrate this, imagine looking down on your model and that it is shaped like a +…
You’ve deemed that it must have a correct physbox because it is going to be seen frequently reacting with the world and/or player, thus needs to bounce and spin correctly. So you want your physbox to resemble something like this, the red lines…
However if you were to let Studiomdl create the physbox for you, it would create a mesh that connected all the most extended parts directly. Like this…
In some cases, that’s ok. If the object is insignificant, or is rarely used in some dark corner, etc. However if this example object were a revolving door, then this physbox would be unacceptable. For more information, see the "Physics" section of the modeling documentation.
Step 5. Run Studiomdl to compile the model.
The actual process of compiling hasn’t changed outside of Studiomdl using your VPROJECT. The following steps can make the job a little easier though by associating all .qc files with Studiomdl so that whenever you double-click them, they will automatically be compiled. If this isn’t something you would like, then skip it and run Studiomdl by any method you prefer. See the Modeling documentation for more information on Studiomdl.
To associate .qc files with Studiomdl for double-click compiling:
- Open a Windows Explorer. (Windows Key + E)
- Click the QC extension. It should become highlighted.
You should now be able to compile your model as a Source model by simply double-clicking the models .qc file.
Step 6. Check your new source .mdl with Half-Life Model Viewer
To make sure everything is working correctly, you can run the new Half-
Some problems you might run into:
- If your model has a black and pink texture, it’s because the materials are not in the location the .qc has pointed the model to look for them in.
That should do it. If you’re still having problems, try going through the Modeling documentation to see if there are any issues you might need to take care of.
P.S. I’ve Lost My Original Source…
If you’ve lost your original source, in the coming weeks Softimage will be releasing a tool with which you can import your .smd directly for editing. One way to get a hold of your textures for converting to materials is to use the Goldsource version of HLMV and extracting the textures from the Texture tab. If all of these options fail you, maybe starting from scratch isn’t such a bad idea after all.