You are on page 1of 22

Source Engine View-model Implementation

By Caleb Sewell

*Note* This is for EDUCATIONAL use only! I do not condone using models from existing
games. This is used ONLY as an example for the purpose of teaching a topic.

Introduction
In this tutorial, I will be covering how to implement a custom weapon model along with its
texture into the Source Engine (specifically for Halfife 2 Deathmatch), although I believe the
process is all the same for any source engine product. I will be using Autodesk Softimage Mod
tool 7.5 along with a few programs that I will list below.

Programs You Will Need

Autodesk Softimage Mod Tool 7.5


http://usa.autodesk.com/adsk/servlet/pc/item?id=13571257&siteID=123112

Valve Source Addon


http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=13525256&linkID=12544121
(This Is a .xsiaddon file. To install, simply load up Autodesk Softimage Mod Tool 7.5 and click
File > Addon > Install. Browse to the addon file and click install. You will be asked to restart.
This will give you the ValveSource option in your Menu bar.

VTFEdit
http://nemesis.thewavelength.net/index.php?c=178

GCFScape
http://nemesis.thewavelength.net/index.php?p=26

GUI StudioMDL
http://www.wunderboy.org/apps/guistudiomdl2.php

WoW Model Viewer


http://code.google.com/p/wowmodelviewer/downloads/list
(This is ONLY if you want to put a model from World of Warcraft into the Source Mod)

Creating a New Mod


I am not going into detail on this because I am simply going to replace the existing Halflife 2
Deathmatch pistol with the World of Warcraft Icecrown Rifle. You don’t HAVE to make a mod
for this but I want to create my own so that it doesn’t replace the gun in the actual game, only
in my mod.

Getting the Gun Ready


The first thing we want to do is load up Autodesk Softimage Mod Tool 7.5 and set up a project. I
will assume you have no working knowledge of the program, so you will see screenshots of how
to do this to go along with the text.
To create a new project, you will want to click File > New Project.
I just set the Location to my C:\ drive so that the folder can be easily picked up and moved to
another computer without any directory issues. The C drive name is fairly standard.
Screenshot 1:

Once you create this folder you will get a project directory which looks like the following.
Screenshot 2:

The next thing you will want to do is to find the weapon model out of WoW Model Viewer that
you want to put into the game. I chose “firearm_2h_rifle_icecrownraid_d_01.m2”. Now you
want to export a .obj file. You can do this by selecting File > Export Model > Wavefront OBJ….
You want to export the files into the projects Models folder that we created previously. This
directory is as follows “C:\WowWeaponTutorial\Models”.
I named the file “IceCrown_Rifle”
Screenshot 3:
Next, you want to import the .obj file into your scene of the newly created project. To do this
you simply go to File > Import > Obj file and direct it to the following location:
“C:\WowWeaponTutorial\Models”. Use the default settings this gives you such as in the
screenshot below.
Screenshot 4:

Now you should see the model in the viewport. From here you can press the “S” shortcut to
pan around using your mouse and zoom in so that you can see the full model in detail. Next, we
want to set the viewport to “textured” so that we can see how it looks and make sure that it
has mapped the texture properly. To do this you click at the top right section of the viewport
and check textured as shown in the screenshot below.
Screenshot 5:

Next we need to make sure that there is only one object here. If there is more than one, we
need to either delete the other objects or merge them together so to do this we need to click
object and then translate it up and delete unwanted pieces. When you translate it up, you will
find one piece that we don’t need for the gun model. Therefore we will click object again and
select the unwanted piece and press the delete key. Then our gun model is ready to go.
Screenshot 6:

Linking the Gun to the Arm Biped

Next we have to merge the arm bipeds to the gun. Thankfully Valve supplies us with the proper
bone structure. You can find this .xsi scene file in the following directory:
“C:\Program
Files\Steam\steamapps\username\sourcesdk_content\hl2\modelsrc\weapons\v_hands\scenes”
The way we merge this file is we go to File > Merge.
Then we need to browse to the directory above and select the “Hands_reference” file.
Screenshot 7:

Now as u can see, you might not see the hands right away. This is because the hands are way
above you in the scene because the gun is incredibly small in comparison to the arms. So now
we much zoom out, again by pressing the “S” shortcut. After u can see both the hands as well
as the arms, we must select the gun model and scale it to a proper size.
Screenshot 8:

Mine was this size, but we can change it to fit as needed in the next step.
Now, we need to rotate the gun to fit it to his arm before we can begin to merge and animate
it. You will see exactly what I mean from the next screenshot below. If your rotation bars look
all screwed up and not in the right place, make sure you click on global or local rotation as you
will also see in the next screenshot.
Screenshot 9:

Enveloping the Gun to the Hand Bone

The next step is a little bit tricky. We need to envelop the gun model to the hand bone so that it
moves wherever the hang goes. This requires a bit of tweaking to the biped structure. So first
press hotkey “8” to go into your scene explorer. Next expand Hands_reference > Valve Biped
and double click on “unselectable_objects.” Now you want to change Selectability to “Allow
selecting members.”
Next, expand “unselectable_objects” in the scene explorer and find the
“ValveBiped.Bip01_R_Hand.” This is the hand bone of the right hand. Double click it. Change
the Bone Display Icon to “Standard.”
Screenshot 10:

Once you have finished this, the tweaking is done and we can envelope our gun mesh to the
bone. The best way to do this is to zoon in on the right hand as close as u can and change the
viewport to Wireframe mode. You can access this in the same place that you chose “Textured”
in Screenshot 5.
Once you are zoomed in, and in wireframe mode, you want to click Object and select your gun
mesh. Then at the top menu, you want to select Animate > Envelop > Set Envelope. If you get a
popup about “Envelop Construction Mode,” select yes. It will then tell you to pick a session. You
then click on the bone in the hand which looks like a long stretched diamond. Once you select
the bone, you right click. You will then get another popup about selecting the number of
skeleton objects. Change it to one and press Enter. You now have the object enveloped and you
can feel free to go back to textured view.
Screenshot 11:

Merging Gun Mesh to Arm Mesh

Every weapon model has to be one complete solid mesh. There can be nothing separate of this
mesh. Therefore we must create a mesh merge. First we need to select both the gun mesh as
well as the mesh of the arm. To select the mesh of the arm you must first open your scene
explorer by again pressing the “8” hotkey. Expand Hands_reference > ValveBiped and click on
“mesh.” Now that you have the arms mesh selected. Simply hold down ctrl and select the gun
mesh.
Now to merge the meshes we must select at the top menu Model > Polymesh > Merge.
When you get the menu, set the Tolerance to 0, then click both Merge Buttons, and lastly click
Delete. This delete will delete the old instance of the mesh and give us only the new one.
Screenshot 12:

Now is a great time to save your t-pose as a scene file by clicking File > Save As. This will save
the scene to your scenes folder inside your project. Now we move on to the most annoying part
of all in my opinion, Animation!

Creating the Animation Files

I am now going to show you how to create a Reference file, Idle Animation, and a Firing
Animation.
To start off we will make the Reference .smd file. All animation files are saved as a .smd.
First, we need to set up a split view to make it easier. The Hands_Reference scene we merged
in has a first person camera so we can see how it will look in game as we position it. There is
only one catch, NEVER MOVE ANYTHING INSIDE THE CAMERA VIEW!!!. I cannot stress that
enough. There is no undoing this. Whatever you do, do not pan around or zoom in and out of
the camera view. Only manipulate the user view. The following screenshot will show how to set
up split-view.
Screenshot 13:

The next step is a really difficult process to explain so I will do this as easy as I can. There are
several pieces of the model in which u can rotate and translate to make the arms do different
things. The next screenshot will show you which of these you can manipulate until you get the
position you want.
The animations I will be making will be 30 frames per second, so at the bottom set your frames
to 29 (0-29). The screenshot below shows the bones you can manipulate to get it in place.
Screenshot 14:

Now we just want to manipulate the bones I have shown you by transforming them with
rotation or translation into the position the gun and arms should rest. Remember if your
rotation or translation lines look odd, make sure you are in global or local transformation. The
next screenshot I will show you how I set the arms in place. Here is how mine turned out.
Screenshot 15:
Now is the time where we will go ahead and export our reference model. The reference file
simply tells the engine where all the vertices as well as the textures are located. We export this
via our ValveSource menu at the top. Click ValveSource > Export SMD. You want to export it to
the following location since we will be replacing the Pistol with this model:
“C:\Program Files\Steam\steamapps\username\sourcesdk_content\hl2\modelsrc\weapons\v_pistol”
I gave it the name “Wowgun_reference” for consistency. You want to make sure you have the following
options selected as the screenshot indicates. This is going to be a Model .smd file.
Screenshot 16:

Now we move on to making an Idle animation. I am simply going to key frame the gun moving up and
back down very slightly. To do this, I selected the spheres that are around the wrists. They control
translation of the hands. Make sure that you have set your number of key frames to 29. When at key
frame 1 and both hand controllers are selected, click the key icon at the bottom. Next, move to key
frame and do exactly the same thing. Once you are done move to key frame 14, and simply translate the
gun up or down a bit to give it a slight motion. Now you have an Idle animation, but you just need to
export it now. You export the same way except you need to change the File type to Skeletal Animation
rather than a Model .SMD as you will see in the next screenshot. Export it to the same location with the
name” Wowgun_Idle”
Screenshot 17:

It is a good idea to save each one of these scenes individually so you can go back and tweak them if they
do not look as expected when you get them in the game.
Now we must make our last animation which is the firing animation. To do this, we will do the
exact same process as the idle, except I am just going to make the gun kick up a little bit higher
this time. You also will export it the exact same way to the exact same location but under the
name “Wowgun_Fire.”

Creating the VTF’s and VMT’s (texture files)

Now we need to create the proper texture files from the .tga file given for the UV map of the
WoW gun. To do this, Open up VTFEdit.
Click File > Import.
Select the “IceCrown_Rifle_5.tga” from the Models folder of your project location and open it.
Leave all default options the same at the next screen.
Screenshot 18:

Next you need to create a directory like the following:


“C:\Program
Files\Steam\username\SourceMods\wowweapontutorial\materials\models\weapons\v_wowgun”
If you do not have the folders you need to create them. You should have all but the
“v_wowgun” folder.
This is the folder in which you will place your texture files.
Leave all the flags in VTFEdit as default.
Next, in VTFEdit click File > Save As and place the .vtf file in the directory above. Call it
“IceCrown_Rifle_5.”
Next click Tools > Create VMT File,
Make sure that the Base Texture 1 is the location of the texture above. It is generally set there
as default. Go to the Options tab and change the shader to “VertexlitGeneric” and uncheck
Translucent.
Create the VMT file in the exact same location as the other file you just saved. Also make sure
that the names of both files are 100% identically the same.
Screenshot 19:

Next we need to get the default texture of the hands models from the stored location of the
Valve’s halflife 2 Deathmath files in the .gcf files. To do this we need to open up GCFScape. Click
File > Open and navigate to “C:\Program Files\Steam\steamapps” and select “source 2007 shared
materials.gcf”
Expand out the following: hl2 > materials > Models > Weapons > V_hand. Select
v_hand_sheet.vmt, v_hand_sheet.vtf, and v_hand_sheet_normal.vtf. Right click them and
extract them to a safe place. You then need to move the files you just extracted into the
directory where your “IceCrown_Rifle_5” textures files are located.
Screenshot 20:

Creating the Script (.qc) File

The viewmodel works in response to how the script file is written. So what we are going to do is
go into the directory where we saved our SMD files and find the Pistol’s QC file. We will rename
the original one to something we can revert back to later if we want. Copy that QC file, and
paste it right back into the same folder. There is no need to change the name of the new QC file
so I wil just leave it as it is “V_Pistol.”
Next, Open up the QC file in notepad.
You should Edit the QC file as shown below in the next screenshot.
!!!IMPORTANT!!! EVERYTHING is case sensitive. Not just the texture names and directories,
but everything in the scripts!!!
Screenshot 21:

When you have finished editing to match this, save the script.

Changing the Weapon Script (.txt) File

Next we need to change a line or two in the “weapon_pistol.txt” file in our mod folder. We can
find this in the following directory:
“C:\Program Files\Steam\steamapps\SourceMods\wowweapontutorial\scripts”
Edit the script as follows in the screenshot:
Screenshot 22:

Compiling the Model (the final stage)

Now all we need to do is compile the QC file. Compiling this will create the necessary .mdl files
needed for the model to show up.
To do this, open up GUI StudioMDL. If you get a popup telling you to set up your directories,
refer to the download page of the program which will explain exactly how to do the initial
setup.
Click File > Load QC File.
Browse to the QC file that you recently edited.
Then under Target Mod of “GameInfo” path, click Add and Browse to the following location:
“C:\Program Files\Steam\steamapps\SourceMods\wowweapontutorial” and click the “GameInfo” file
and select Open.
Leave all default Compiler options the way they are. They should all be unchecked.
Next hit Compile (steam must be opened to compile).
Screenshot 23:

Trying Your New Gun!!!

Now is what you have been waiting for, to see how your gun looks. Restart steam and Launch
your mod. Navigate to the Pistol in your weapons list and see if you now have a WoW Rifle in
the place of the pistol. Below is my final product. You can always go back to your files if you
saved them to tweak them in anyway that you like. You can also make reloads, drawing, etc.,
animations and set them up in the QC file. Now hopefully you have a working knowledge of the
process and can take it as far as you like. Enjoy!
Screenshot 24:

You might also like