Convert a Model to Left 4 Dead 2 Survivor
01-Jan-2011
Latest revision: 30-May-2012
By ZeqMacaw
Inspired by the tutorial by da1barker, Custom L4D2 Character Step By Step or Custom L4D2 Character (same tutorial, different websites).
Introduction
This tutorial shows my way of converting; it is not the only way. For example, I use Autodesk Softimage Mod Tool because it is a free program, but the tutorial I based this one on explained how to use 3ds Max instead.
Note that the instructions are for 32-bit Vista. For 64-bit systems, wherever "C:\Program Files" is used, you will probably need to use "C:\Program Files (x86)".
Get the Tools
Click on name to download.
Left 4 Dead 2 (L4D2)
Obtain via Steam.
Source SDK
Obtain via Steam.
Probably need this to use some tools listed further down.
Source SDK Base 2006
Obtain via Steam.
(not sure if needed)
Source SDK Base 2007
Obtain via Steam.
(not sure if needed)
Left 4 Dead 2 Add-on Support
Obtain via Steam.
For testing addons (such as a custom survivor model) in L4D2. (Might not be needed anymore.)
Left 4 Dead 2 Authoring Tools
Obtain via Steam.
For VPK and HLMV tools.
VPK
Find on your computer: "C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\vpk.exe"
For packaging model files into a VPK file that a user can place in his L4D2 addon folder to see custom model in-game.
Half-Life Model Viewer (HLMV)
Find on your computer: "C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\hlmv.exe"
For viewing and checking certain properties of your model (with proper setup explained later) without having to load it in-game.
Autodesk Softimage Mod Tool v7.5 (32-bit) (Mod Tool)
On Autodesk's website. Search for Autodesk Softimage Mod Tool. It is the free, non-commercial version. Requires registration, i.e. name, postal address, email address, and several questions.)
For creating and editing your model.
Valve Source Add-On (for Mod Tool)
Or click inside Mod Tool: Help menu, Download menu item, Autodesk Softimage Mod Tool Add-Ons link, Valve Source Add-On link.
For importing and exporting smd files and weightmaps.
On Blender's website. Look for a Download page. Free and open source.
For converting weightmaps of original survivor models so they can be used in Mod Tool.
(You could also create and edit models with this instead of Mod Tool, but this tutorial does not cover this method.)
On Wunderboy's website.
For decompiling mdl and related model files.
For decompiling mdl and related model files.
For creating vtf (texture) files.
For extracting model (and other related) files from L4D2.
On Notepad++ website.
For editing text files and for changing values in binary files.
Setup the Tools
Install Tools Found in Steam
Open Steam.
Go to the Tools tab.
Install Source SDK.
Install Source SDK Base 2006. (Not sure if this is required.)
Install Source SDK Base 2007. (Not sure if this is required.)
Install Left 4 Dead 2 Add-on Support.
Install Left 4 Dead 2 Authoring Tools.
Setup HLMV Tool
L4D2 has its own set of SDK tools separate from other Source engine games, including its own version of HLMV.
Create a shortcut to "hlmv.exe" found (by default) in "C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\".
Move the shortcut to your "SendTo" folder (or to any other folder, such as your desktop). It should be placed somewhere convenient so you can drag-and-drop a folder onto it.
Setup VPK Tool
Create a shortcut to "vpk.exe" found (by default) in "C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\".
Move the shortcut to your "SendTo" folder (or to any other folder, such as your desktop). It should be placed somewhere convenient so you can drag-and-drop a folder onto it.
Setup Mod Tool
(Install the Valve Source Add-on.)
(Create a Mod Tool Project.)
Install Remaining Tools
Install GUI StudioMDL. (The exe file for this can be placed anywhere.)
Install MDL Decompiler. (Pay careful attention to installation instructions because it must be placed in certain folder.)
Install VTFEdit.
Install GCFScape.
Install Notepad++.
Setup the Release Folders
Create a folder that will contain the final files that will be used in the game. (This will be referred to as the "release folder".)
Within the release folder, create the folder tree: materials\models\survivors
Also within the release folder, create the folder tree: models\survivors
Create the addoninfo.txt file:
In the release folder, create a text document with this name: addoninfo.txt
Copy-paste the following block of text into the file.
"AddonInfo"
{
addonversion "1"
addontitle "New Model (Replaces Rochelle)"
addonDescription "New Model (Replaces Rochelle)"
addontagline "New Model (Replaces Rochelle)"
addonauthor "AUTHOR_NAME"
addonauthorSteamID "STEAM_ACCOUNT"
addonURL0 "http://www.mywebsite.com"
addonSteamGroupName "GROUP"
addonContent_Campaign 0
addonContent_Script 0
addonContent_Music 0
addonContent_Sound 0
addonContent_prop 0 //This Add-on provides new props,
addonContent_Prefab 0 //Provides new prefabs
addonContent_BackgroundMovie 0 //Provides a replacement for the background movie.
addonContent_Survivor "Rochelle" //Provides a new survivor model. 0=false, 1=true, String in quotes if replaces specific single character, i.e. "Francis"
addonContent_BossInfected 0 //Provides a new boss infected model. Break these out?
addonContent_CommonInfected 0 //Provides a new common infected model
addonContent_WeaponModel 0 //Provides a new appearance to existing weapons, but does not change their function
addonContent_weapon 0 //provides new weapons or new zombie killing functionality, i.e. guns, explosives, booby traps, hot tar,
addonContent_Skin 0 //0 if no new skin textures for existing models. 1 if multiple skin pack. String in quotes if specific single skin
addonContent_Spray 0 //Provides new sprays.
addonContent_Map 0 //Add-on provides a standalone map
}
Replace the text in double-quotes for the first section of fields (addonversion to addonSteamGroupName).
Replace "Rochelle" on the addonContent_Survivor line with name of the survivor your custom model replaces.
Save the file.
Setup the Source Folder
"Source" folder refers to the original files used to create the files used in L4D2; it doesn't mean "Source engine" in this tutorial. For example, the source folder will contain the smd file and other files used to create the final released mdl file.
Create a folder that will contain the original source files that will be used to create the final released files for use in-game. (This will be referred to as the "source folder". The source folder should be separate from the release folders.
Create or Get a Model
Create a Model from Scratch Using 3D Modelling Program
I have no experience modelling from scratch, so I have no guidance here. There are numerous tutorials that explain how to model humans or human-like 3d objects.
Some helpful 3D modeling overviews and tutorials:
Modeling Creation Overview (On Valve Developer Community wiki (VDC).)
Character Creation Overview (On VDC.)
Creating a Basic HL2 Character Model Using XSI (XSI aka Mod Tool. On veazie.org.)
Character Modeling (Several parts/pages on how to model a humaniod from scratch using Mod Tool aka XSI. On "Jailbreak: Source - Source SDK Development Blog".)
OR
Get a Model from a Source Engine Game
You could start out by extracting an MDL file from a Source engine game (like L4D2 or Half-Life 2).
Open GCFScape.
Go to "C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2" folder.
Open the "pak01_dir.pak" file.
Go to "models\survivors" and select all the particular survivor's files (coach, gambler, mechanic, or producer). There should be six files for each survivor.
Right-click and extract to your "extracted" folder.
Close GCFscape.
OR
Get a Model from a Website
Download a model from such sites as Garry's Mod Related Files.
Convert Model File to SMD File
Convert from MDL Format
Verify two files exist, one with extension of ".dx80.vtx" and one with ".dx90.vtx". If needed, you can copy an existing vtx file (".vtx", ".sw.vtx", ".dx80.vtx", or ".dx90.vtx") and change the copy's extension.
Open the mdl file in Notepad++. (The first four characters should be "IDST" [without the quotes]. The fifth character is usually a zero "0" [without the quotes], but can be one of several different characters.)
Change the fifth character to a comma ",".
Save (overwriting same file).
Close Notepad++.
IMPORTANT: Because of bugs in MDL Decompiler, ALWAYS restart MDL Decompiler for each decompile, whether it fails or succeeds. Not doing so will likely cause problems with the next decompile.
Open MDL Decompiler.
Uncheck the "Use Steam File Access" option at the bottom.
In the "Choose Model file" option, select mdl file.
In the "output" option, select the folder that the mdl file is in. (MDL Decompiler should default to this folder).
Click the "Extract" button.
Close the couple of windows that pop up indicating error or success.
Close MDL Decompiler.
Verify that there are new files in the folder: one or more smd files and a "mdldecompiler.qc" file.
Convert from Other Formats
(Future updates will have links to tutorials for converting from other formats.)
Planned:
Convert model from XNA Lara tool.
Import the Model into 3D Editing Tool
Import to Mod Tool
Open Mod Tool.
(Import smd file.)
Import to other 3D Editing Tools
(Other tools have plugins and menu options for importing and exporting smd files, and can be found elsewhere.)
Set the Model Materials
Extract the Weightmap for Each L4D2 Survivor
The weightmap represents how much each vertex of the mesh moves when bones move during animations. This section of the tutorial only needs to be done once for each of the four survivors.
The Valve Source Add-On for Mod Tool includes two weightmap options: Export Weightmap and Import Weightmap. These two options can save you a lot of time if your custom model is posed and positioned closely to the L4D2 survivor model it is replacing (more details about this later in the tutorial). The imported weightmap likely won't be perfect (such as lower parts of hair), but the harder-to-weight areas, such as shoulders, chest, and hips are often good enough to not need tweaking.
Extract model files from L4D2 pak file
Open GCFScape.
Go to "C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2" folder.
Open the "pak01_dir.pak" file.
Go to "models\survivors" and select all the particular survivor's files (coach, gambler, mechanic, or producer). There should be six files for each survivor.
Right-click and extract to your "extracted" folder.
Close GCFscape.
Convert SMD File To FBX File
(NOTE: What Mod Tool calls "weightmap", Blender calls "armature".)
Open Blender.
Delete any other meshes from Blender.
Import SMD file:
File > Import > Half-Life 2 Mesh (.SMD)
Select "Static Mesh...".
Select the smd file to import.
Click the "Import SMD..." button.
(Importing can take a while and can freeze the program while it is importing.)
Select the mesh.
Select the armature.
Export as Autodesk FBX (.fbx).
Enable the "Selected Objects" button.
Change Scale to 1. (This might need to be increased.)
Enable the "Rot X90" option.
Enable only the "Mesh" and "Armature" options in the list of export object options.
Disable the "Enable Animation" button.
Click "Export" button.
Select where to store the file.
Change the file name.
Click "Export FBX" button.
Close Blender.
Convert FBX File To Valve's Weightmap File
Open Mod Tool.
Import via Crosswalk > Import FBX.
In "Load Options", select "Add to scene" option.
In "Import Options", uncheck all the checkboxes.
In "Animation Options", uncheck all the checkboxes.
In "Special Options", only check the following checkboxes:
"Import skeleton elements as nulls"
"Keep XSI effectors"
"Set envelopes"
"Show the Warnings and Errors dialog box"
Click "OK" button.
(Two warnings about BindPose always appear for me, but they don't seem to cause any trouble.)
(Select the model/mesh and export the weightmap. Check "Export Fullnames".)
Close Mod Tool.
Edit the Valve Weightmap File
The weightmap file is not quite right for importing (probably because Valve Source Add-On hasn't been properly updated), so edit the file as follows.
Modify the saved weightmap file using Notepad++ (or any text editor with "Find and Replace" feature):
Find "Bip01_Pelvis." (note the period at the end) and replace with "ValveBiped." (note the period at the end). (62 occurrences)
Find "Bip01_Pelvis" and change it to, "ValveBiped.Bip01_Pelvis".
Rig the Model
(Use Mod Tool's weightmap features.)
Test the Model in HLMV
HLMV can only read from L4D2's "models" and "materials" folders, so this section explains how to handle it as smoothly as possible.
Test the Model in L4D2
If the model animates well in HLMV, test the model in an actual L4D2 game.
Create the Lobby Avatar
Create the In-Game Avatar
Create the Incapacitated Image
Create the Addon (VPK File)
Test the Addon in L4D2
After packaging the addon into a vpk file, you should test it in L4D2.
Upload
Conclusion
Once you have your first working converted model, let others know about it.