Difference between revisions of "Porting Goldsource content to Source"

From Valve Developer Community
Jump to: navigation, search
(updated paths, SMD import information)
m (Fixed broken links)
 
(16 intermediate revisions by 12 users not shown)
Line 1: Line 1:
[[Category:Modeling]]
+
{{otherlang2
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.
+
|jp=Porting_Goldsource_content_to_Source:jp
 
+
|ru=Porting_Goldsource_content_to_Source:ru
=Overview=
+
}}
 
+
{{mergeto|Converting Textures}}
 
  
=Step 1. VPROJECT=
+
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|.QC]] file. [[SMD]] files may also be useful if the original 3d package file is unavailable.
  
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.
+
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.
  
To set your VPROJECT('''Current Game'''), you can use Source SDK launcher or [[The Game Directory#Using VConfig to set the game directory|VConfig.exe]].
+
=Set VPROJECT=
  
=Step 2. Convert old textures to new materials=
+
{{main|Game Directory}}
  
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 [[:category:Material System|Material System]] documentation in the SDK.
+
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 [[The Game Directory#Using VConfig to set the game directory|VConfig.exe]].
  
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 <code>C:\MyMod\materialsrc</code> and <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials</code>. 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 <code>C:\MyMod\materialsrc\player</code> and <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials\player</code>, 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.
+
=Convert old textures to new materials=
  
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.
+
{{seealso|[[Material system]]}}
  
Tip #1 Shortcut for Creating NEW materials
+
In the Goldsource engine, .BMP textures were compiled into the .MDL file. However in the Source engine, developers export textures as .VTF files, which are simply referenced and not actually compiled into the .MDL file.
  
# Create a shortcut to vtex.exe on your desktop. Vtex.exe is located in your SourceSDK\bin directory.
+
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|VTFedit]] is highly recommended; though there are also [[VTF#Utilities|other tools available]]. This tutorial will assume that the user is using Vtex.
# Right-Click the shortcut and select the ‘properties’ option.
 
# In the -.exe with a space between them.
 
# Click OK.
 
  
You should use this shortcut whenever you need to convert a
+
{{main|Creating a Material}}
  
. It should not be used for sprites and similar content. Check the [[:category:Material System|Materials]] documentation for more info.
+
First, convert all old texture files to .TGA format, using Photoshop or a similar image editing application.  
  
Tip #2 TGA to VTF right-click shortcut
+
# Create a shortcut to vtex.exe on your desktop. Vtex.exe is located in the SourceSDK\bin directory.
 +
# Right-click the shortcut and select the "Properties" option.
 +
# In the "Target" box, add <code>-mkdir -shader vertexlitgeneric</code> after vtex.exe with a space between them. Click OK.
  
# Open a Windows Explorer window (Windows key + E).
+
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 <code>-shader VertexLitGeneric</code> tells Vtex to automatically make a new .VMT that points to the .VTF as the diffuse texture.
# Go to Tools > Folder options.
 
.
 
# Click TGA so that it is highlighted.
 
# Click the .
 
# You should now see the
 
 
 
directory wherever you have installed SourceSDK. For example <codeC:\Program Files\Valve\Steam\SteamApps\username\sourcesdk\bin</code>)
 
# The “Application used to .exe "%1"".
 
# Click in the little box next to “Use DDE".
 
# In the .
 
 
# Hit OK on all the panels to accept the changes.
 
  
You can now right-click on any .tga file that you have an existing .vmt for and select the for when you make changes to a texture you have previously compiled.
+
{{note|The VertexLitGeneric shader is only used for models; it should not be used for sprites or brushes. Check the [[:category:Material System|Materials]] documentation for more info.}}
  
Now to convert your textures, we can use our new tools to save us some typing in a DOS window.
+
=Export .SMD files=
  
# Save all your .bmp’s as .tga’s with your favorite image editing application into their appropriate materialsrc directory.
+
{{seealso|[[Model Creation Overview#.SMD_files|Model Creation Overview]]}}
# 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 [[:category:Material System|Materials]] documentation.
+
If the original 3D model file is lost, use an SMD plug-in (e.g. Valve Addon for Softimage|XSI) and import the .smd directly for editing.
  
=Step 3. Tweak the .qc file=
+
=Modify .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.
+
{{main|Qc}}
  
* $modelname now works in conjunction with your VPROJECT and automatically assumes a directory output location of your VPROJECT + a ‘models’ directory. For example <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models</code>. will compile the model and write it to <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models\player\myplayer.mdl</code>. Of note is that Studiomdl will not make directories for you, nor does it have a –mkdir argument so you will have to make sure the directory that you’re writing to already exits before you start the compile.
+
While old .QC files will work with the new Studiomdl, there have been syntax changes for Source models to compile correctly.
.
 
  
=Step 4. Collision Model (aka Physbox)=
+
* <code>$modelname</code> now works in conjunction with VPROJECT and automatically assumes a directory output location of VPROJECT + a 'models' directory. For example: <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models</code>. So if <code>$modelname</code> were set to "player\myplayer.mdl", Studiomdl will compile the model and write it to <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models\player\myplayer.mdl</code>.
 +
* Replace <code>$cdtexture</code> with <code>$cdmaterials</code>. <code>$cdmaterials</code> also uses VPROJECT and assumes the output directory to be VPROJECT + 'materials' directory. For example: <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials</code>. Break the material directory tree up based on context - in this case, a model. Keeping the same example as in the <code>$modelname</code> step above, set <code>$cdmaterials</code> to "models\player" so that the model will look for materials in the directory <code>C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials\models\player</code>.
  
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.
+
=Create a Collision Model (Physbox)=
  
Studiomdl will create a physics hull for you if you do not specify one, however it will do a quick and
+
{{seealso|[[Physics and Ragdolls]]}}
  
To demonstrate this, imagine looking down on your model and that it is shaped like a +…
+
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.
  
[[Image:Phys demo3.jpg|Phys demo3.jpg]]
+
The most correct collision hull would resemble the plus sign.
 
 
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…
 
  
 
[[Image:Phys_demo2.jpg]]
 
[[Image:Phys_demo2.jpg]]
  
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…
+
The automatically generated collision hull would connect all the most extended parts directly.
  
 
[[Image:Phys_demo3.jpg]]
 
[[Image:Phys_demo3.jpg]]
  
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.
+
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.  
  
=Step 5. Run Studiomdl to compile the model.=
+
=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 [[:category:Modeling|Modeling]] documentation for more information on Studiomdl.
+
{{main|Compiling Models}}
  
To associate .qc files with Studiomdl for double-click compiling:
+
The actual process of compiling hasn't changed outside of Studiomdl using VPROJECT. To associate .QC files with Studiomdl for double-click compiling:
  
 
# Open a Windows Explorer. (Windows Key + E)
 
# Open a Windows Explorer. (Windows Key + E)
# At the top of the window, click , then .
+
# At the top of the window, click "Tools", then "Folder Options...".
# Click the tab then scroll down to QC. If you do not have a QC extension in your list, you can add it by hitting the button below the list, and enter in the box. Hit to enter the extension into the list.
+
# 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.
 
# Click the QC extension. It should become highlighted.
 
# Click the QC extension. It should become highlighted.
# In the “Details for area of the panel, click the button to the right of the text “Opens with:.
+
# In the "Details for 'QC' extension" area of the "Folder Options" panel, click the "Change..." button to the right of the text "Opens with:".
# Click the button at the bottom right of the panel.
+
# Click the "Browse..." button at the bottom right of the "Open With" panel.
# Browse to the file “compile_qc.in the SDK tools. Click the button.
+
# Browse to the file "studiomdl.exe" in the SDK tools. Click the "Open" button.
# Make sure that is highlighted in the panel. Click the button.
+
# Make sure that "studiomdl.exe" is highlighted in the "Open With" panel. Click the "OK" button.
# Close the panel with the button.
+
# Close the "Folder Options" panel with the "Close button.
  
You should now be able to compile your model as a Source model by simply double-clicking the models .qc file.
+
=Check the Model with the Half-Life Model Viewer=
  
=Step 6. Check your new source .mdl with 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:
  
To make sure everything is working correctly, you can run the new Half-Life Model Viewer to view your new model. HLMV can be found in the the rest of the tools. Go to File>Load Model option at the top of HLMV and browse to the location of your model .
+
* 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.
  
Some problems you might run into:
+
=Mapping=
  
* 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.
+
Hammer 4.1 has backwards compatibility for both .map files and .rmf files.
..
 
  
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.
+
[[Category:Modeling]]
 
 
=P.S. I’ve Lost My Original Source…=
 
 
 
If you’ve lost your original source, you can use SMD importer for your 3D package(e.g. Valve Addon for Softimage|XSI) and 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.
 

Latest revision as of 20:43, 5 November 2013

Русский 日本語


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 Goldsource engine, .BMP textures were compiled into the .MDL 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: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

See also: Model Creation Overview

If the original 3D model file is lost, use an SMD plug-in (e.g. Valve Addon for Softimage|XSI) and import the .smd directly for editing.

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)

See also: Physics and Ragdolls

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.1 has backwards compatibility for both .map files and .rmf files.