Tutorial - How to convert models to OC player models.

Archived Source Engine and Obsidian Tutorials.
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Tutorial - How to convert models to OC player models.

Post by fug4life »

Here I will try and go through converting a model to Obsidian to work as a player model. I'm no pro at this and have only really learnt what I know through trial & error, but I'm willing to share what I know.
I'm not good at tutorials so I'll add pictures and more info afterwards and strive to improve it as much as possible.

-------------------------------------------------------------------------------------

Things you will need
(these are the programs I use, but you can use others):

1). Source Software Development Kit (SDK).
Can be found in your steam tools tab

2). GCFScape (Enables you to browse/extract the Game Cache Files (GCFs).
http://nemesis.thewavelength.net/index.php?p=26

3). Model Decompiler
http://www.chaosincarnate.net/cannonfod ... mpiler.php

4). GUI Studio Compiler
http://www.wunderboy.org/apps/guistudiomdl2.php

Extra programs that will be very useful are:

1). Hex Editor XVI32
http://www.chmaas.handshake.de/delphi/f ... /xvi32.htm

2). NotePad + +
http://notepad-plus.sourceforge.net/uk/site.htm

(Also Win Merge is a good program for comparing files).

4). VTF Edit/Lib
http://nemesis.thewavelength.net/index.php?c=178

To make sure there are VGUI images, so the model can be chosen from the selection menu you will need some sort of image editing program, personally I use Paint Shop Pro (Yeah I bought it), most people use Photo Shop. I believe you can aslo make do with just Microsoft Paint and Paint.net.

To install the above programs you should really follow the directions given by the program authors.

-------------------------------------------------------------------------------------
Last edited by fug4life on Wed Nov 04, 2009 12:43 pm, edited 2 times in total.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

-------------------------------------------------------------------------------------

Getting Started

For this tutorial I will convert the CounterStrike:Source Hostages.

Create two empty folders on your desktop, name one something like: Models and the other: Models_d.

The Models folder is where you can keep all the models you are working on and the Models_d is where you will decomplie one model to work on (Basically its best to work on one model at a time).

Now we need to extract the models to: desktop/Models folder using GCFScape.
Basically to do this go to your Steam\steamapps directory and open the Counter Strike Source Shared GCF, browse to models\Characters look for the files starting with this name: Hostage_01 (Normally around 6 files).
Hold shift, click on the first and click on the last so you highlight the files you want. Then right click and select extract to your desktop models folder.

Next we need to extract the materials the Hostages use so again in the same GCF, browse to materials\models\Hostages and we will need all the files here (because only hostage files are in here I'm just going to extract the whole folder), so right click extract, though this time were going to extract these straight into its correct location within your obsidian directory. So you will need to extract to: obsidian\materials\models\player

Now browse to your: obsidian\materials\models\player folder and look for the Hostages folder you extracted. Open the Hostages folder and you'll find all the material files. We need now to open each .VMT file in notepad and correct the directory paths written within to match their new directory
(The VTF files can be left alone for now).

So here is the pupil_l.vmt before:

Code: Select all

"Eyeball"
{
	"$basetexture" "models/hostages/pupil_l"
}
You'll need to correct the directory to this

Code: Select all

"Eyeball"
{
	"$basetexture" "models/player/hostages/pupil_l"
}
So basically I've added: /player. You'll need to do this for each directory path written in each .VMT file.

Ok, now back to our model in our desktop/models folder. We will now need to open your Model Decompiler to decompile to your desktop/models_d folder.

So once you have Model Decompiler open choose where your model is located and pick the .mdl file and then decompile/extract to you desktop/Models_d folder.

Next look in the models_d folder and you should see all your extracted files. We are only really interested in the file called: mdldecompiler.qc

Open this file in notepad and now we'll start to convert to obsidian.

At the top change this:

Code: Select all

$modelname "Characters\Hostage_01.mdl"
To this:

Code: Select all

$modelname "player\Hostage_01.mdl"
About Halfway down change this:

Code: Select all

$cdmaterials "models\Hostages\"
To this:

Code: Select all

$cdmaterials "models\player\Hostages\"

A little further down change this:

Code: Select all

$includemodel "Humans/male_shared.mdl"
$includemodel "Humans/male_gestures.mdl"
$includemodel "Humans/male_postures.mdl"
To this:

Code: Select all

$includemodel "player/male_shared.mdl"
$includemodel "player/male_ss.mdl"
$includemodel "player/male_gestures.mdl"
$includemodel "player/male_postures.mdl"
(Note if your model is closer to a female then change all the male to female like so: "player/female_shared.mdl").

For this particular model I think that is all we need to do for now.

Save all your changes!

And now lets compile!

Open GUI Studio Model compiling program, make sure it is set up for OrangeBox and Obsidian Conflict. Select the: mdldecompiler.qc
and compile. That's all for the compile process.

Check how the model looks in your SDK model viewer (set up with obsidian).
Load the model. Next load an oc only weapon (w_healer.mdl). Now in the sequence tab click where it says ragdoll and pick a sequence like: run_healer. Whilst you are here make a screenshot (You'll need it for your VGUI later).

This particular model has facemap issues see pick below:

Image

To fix this we need to go back to the materials folder and edit the facemap material VTF (this model in particular uses the: art_facemap.VTF).
We need to use the VTF Edit program to open the art_facemap.VTF file.
Once in the program and file is open, under the 'Image' tab is a list of check boxes, we need to un-check (un-tick). The: Clamp S and the Clamp T parameters. Save the file and check back in SDK Model Viewer by 'refreshing' the model and you'll see the face is now fixed.

Almost finished.

Next browse to your: obsidian/models/player folder and create a new text document called: Hostage_01.txt and inside add this:

Code: Select all

ModelSettings
{
	//Use this option to choose a base script to use instead.
	"usefile"	"none"

	//base model rig to use. Use either Male_01 or Female_01 for best results.
	"basemodel"	"Male_01"

	//Voice Sound 0=none, 1=male, 2=female, 3=combine
	"voice"		"1"

	//Footstep Sound 1=shoe, 2=combine boots
	"footsteps"	"1"

	//Gibs, 1 = generic human, 2 = generic alien, 3 = human rebel ragdoll gibs, 4 = Ragdoll only
	"Gibs"		"4"
}
(If you had a female or combine related model you could change one or two settings above).

Ok, now to be able to select the model in game you need to create a VGUI image for the model so player can select it. I will go through the process of making one later for now we will just use an exsisting one as a 'placeholder', why? because I want to go check my model in game before I go any further!

So to use a place holder go to your obsidian/materials/VGUI/playermodels/player folder.
copy the .VMT and .VTF file from an exsisting player (I'm going to use Gordon.vmt and Gordon.vtf). paste them and rename them to:
Hostage_01.vmt and Hostage_01.vtf. Open the Hostage_01.vmt in notepad and correct the directory path so it now looks like this:

Code: Select all

UnlitGeneric
{
// Original shader: BaseTimesVertexColorAlphaBlendNoOverbright
	"$translucent" "1"
	"$basetexture"	"vgui\playermodels\player\Hostage_01"
	"$vertexcolor" "1"
	"$vertexalpha" "1"
	"$no_fullbright" "1"
	"$ignorez"	"1"
	"$decalscale" "0.250"

}
(So basically we are just temporarily borrowing Gordon's picture so I can select Hostage_01 ingame and test the model before I go anyfurther).

Go in game select the model from options/multiplayer pick your model (Hostage_01) and check it by going in console typing: sv_cheats 1 and then: thirdperson and also: cam_idealyaw 90.
Just to make sure he runs and shoots ok and holds all the weapons (for all weapons: impulse 101 in console). The glitching on the animations is just the view mode, ignore them.

That's it model converted, compiled and in game.

Image

-------------------------------------------------------------------------------------
Last edited by fug4life on Wed Nov 04, 2009 1:46 pm, edited 5 times in total.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

-------------------------------------------------------------------------------------

The only thing left to do is give the model its own VGUI image. This is where the paint programs come into use, however I'm sure methods vary, they will also have some similarities depending on which paint program you use.

Unfortunately currently I can only describe the method I use in Paint Shop Pro (Though I'll paste what Sonic said to me about how he does it, afterwards with paint and paint.net).

You will also need to download and install a VTF Plugin for paintshop pro beforehand (Goole for now I'll find a link later).

So, Open Paint Shop Pro and open the screenshot (.tga file) you took in SDK Model Viewer earlier.
(Prefebably you want the model holding an oc weapon and you can use centre view to get the model where you want it.
To look around in SDK Model Viewer use: Right mouse click - zoom in/out
Left mouse click to rotate. Hold shift and use left click mouse clickto move the model up/down/left/right).

Also in Paint Shop Pro it helps to add a grid (view/grid, size dosen't matter)it just helps when working.

So lets move on to converting/working on the screenshot.

First we will use the Crop tool to cut the picture just so that we have the top half of the body. Make sure you use free form and have the box size that you are cropping set to 256x200, position in the centre of the top half of the body (showing the head, chest and shoulders), and then crop.

Now, click layers and select new mask layer/show all.

Now you will see the picture has a mask-raster 1 layer, right click and select delete and then yes.

Now select the Magic Wand tool set up with something like mode = replace
matchmode = RGB value tolerance = 1 use all layers and use contiguous also use Anti-alias and select outside from dropdown box.
Click on the background on the image and not the model to use the Magic Wand.
(Baically you want to delete the back ground and not the model itself).
So if the the whole box and around the model is selected, its ok to delete.

Once the background is deleted, with the Magic Wand tool still open change the matchmode to = All opaque and this time click on the model in the image and it should change the Magic Wand from around the edges and around the model to actually now just around the model only.

Now click layers select new mask layer/form image, make sure source opacity is checked and everything else is unchecked, click ok.

Now we are going to cut the highlighted model onto a new image. So with the Magic Wand still highlighting around the model on the image change to the Pan tool and right click on the highlighted model and select: copy merged.

Now go to File and create a new image with these properties:

width =256 pixels
height =256 pixels
resolution =72,000 pixels/inch

Choose Rastor Background
image depth =RGB - 8bits/channel

And check the Transparent box.

Now to paste your copied image onto your new image, so, right click on your new image and paste as a new selection. Position into the top left hand corner as much as possible and then just left click.

Now we need to give an alpha channel so go to selections select load/save selection and choose save selection to alpha channel and clcik ok/save in the pop-up.

Finally now click File and save copy as and name it Hostage_01.png using the .PNG file format and press yes to the pop-up. (this is so you have a nice image to upload to the forums).

Now click File and save copy as again and this time name it Hostage_01.vtf using the .VTF file format and press yes/ok to the pop-up.

Now here we are using the VTF plugin. Set the properties as:
Template = Compressed Texture With Alpha
Format = DXT5 (Common Format)
Mipmap Filter = Box
Sharpen Filter = Sharpen Soft

check/tick Mipmaps and Thumbnail

And from the list just make sure Eight Bit Alpha (Format Specific) and Nice Filter are both checked/ticked. Everything else should be unchecked/unticked, then press ok.

Thats it you now have your Hostage_01.vtf to add to your obsidian/materials/VGUI/playermodels/player directory, just overwrite the old Gordon.vtf we used as a place holder earlier.

FINISHED.


Here's the .PNG image uploaded for forum use:

Image

Don't forget to read my Tips and Tricks post below this for lots more info and help.

I'll tidy this tutorial up and add pictures over the next coming days.

-------------------------------------------------------------------------------------
Last edited by fug4life on Wed Nov 04, 2009 1:42 pm, edited 3 times in total.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

-------------------------------------------------------------------------------------

Tips, Tricks, Hints and other Helpful info

(Other people are welcome to contribute to this in with thier own experiences).

Firstly, I've only converted exsisting models that I knew were ragdolled/rigged for hl2. You should stick to that for now, other wise you had better start to learn rigging and modeling.

Converting models is not easy as many models have different properties, which means recompiling them can be troublesome (different bones etc). Though if your willing to spend some time and have enough patience to experiment and see what works, you will be rewarded in most cases.

Reading the errors in GUI Studio Model as you compile will be a big help in diagnosing whats causing the problem
(Normally a .qc line number is given in brackets next to the error).
To find the line number quickly I use the program NotePad ++ to open the .qc file to see which line it is.

Do not be affraid to experiment and delete lines from the .qc file for trail and error purposes when compiling.

-------------------------------------------------------------------------------------

Here's how to get around some of the troubles I have encountered!

Can't get your model to decompile, get unable to load model message?

Use the Hex Editor XVI32 I mentioned above to open the .mdl file and in the first line where you have this:

Code: Select all

IDST. 
Overwrite the fullstop (.) (or whatever other character is given after the IDST) to this a comma(,):

Code: Select all

IDST,
Compiling Troubles and Errors
^Coming soon I'll post some examples of how by chance I fixed some of the more common errors I come across (stuff like missing eye textures, too many lods or shadow lods, how to get it so it compiles the right .smds for you, how to fix half eye lid closed, fix/delete unkown hboxs like r_toe0 <----that sort of stuff).

-------------------------------------------------------------------------------------

So how to use MS Paint and Paint.net to make the VGUIs?

I don't know (I don't have Paint installed) Though Sonic told me how he does it so i'll paste what he said.

Pose picture in model viewer > alt+ prtscrn > paste into paint > crop into 256 x 200 at first then so that deletes the bottom part of the picture otherwise it overhangs in the vgui box, then increase the bottom part to 256 so that it is 256x 256, with the picture in the top left corner > then copy and paste into Paint.net > use the magicwand to get rid of the background and then zoom in and remove any other bits (always best to use a bright colour not matched to the model) > save one version of the model using the model name as a .png and then another version ofthe picture as a .tga @ 32 bit > then put up the preview picture the .png version for people to see ^_^ > i have a desktop shortcut to VTFEdit, so i can drag my .tga file into it and it loads the file, agree to the set up conditions and save the file as the name of the model and your done =D
-------------------------------------------------------------------------------------
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
shiftey
npc_combinegunship
npc_combinegunship
Posts: 705
Joined: Thu Oct 09, 2008 4:45 pm
Contact:

Post by shiftey »

Best post in a LONGGG time. Thanks fug. ;)
User avatar
Tallfire
prop_physics
prop_physics
Posts: 127
Joined: Mon Sep 28, 2009 4:10 am

Post by Tallfire »

Thanks alot. I'll be sure to try to figure this out.
Gary
npc_advisor
npc_advisor
Posts: 1125
Joined: Sun Nov 09, 2008 7:21 am
Location: USA, FL
Contact:

Post by Gary »

This is great! Very nice and well written.
Axel_m3sh
npc_combine_elite
npc_combine_elite
Posts: 469
Joined: Wed Nov 05, 2008 5:52 am
Location: lolwut L0C4tI0n?
Contact:

Post by Axel_m3sh »

We all love you fug lol, thanks for the guide
Gary
npc_advisor
npc_advisor
Posts: 1125
Joined: Sun Nov 09, 2008 7:21 am
Location: USA, FL
Contact:

Post by Gary »

I had problems finding this tutorial when I tried looking for it. I recommend we move it to the "Tutorials Archive". Making it easier to find.
User avatar
Datastream
Donator
Donator
Posts: 870
Joined: Thu Dec 24, 2009 1:24 pm

Post by Datastream »

mdldecompiler.exe won't start even though I put it in sourcesdk\bin.

It gives me the error that it can't locate the entrypoint of procedure Q_AppendSlash in vstdlib.dll.

Should I put the decompiler in sourcesdk\bin\ep1\bin\?

[edit]
Fixed it by putting it in that map.
But when I try to extract a gmod model it says it cannot load the model. Why?
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

Download the hex editor I mentioned above, open the .mdl file and if it has a fullstop (.) after IDST <---- near the begining of the text replace that with a comma (,) save and now try it.

This wont always be the case but if its an orange box compiled model, it should sort your troubles.

Also keep any originals that do compile, because once compiled to orange box you may not be able to work on the one you've compiled and may have to re extract from the original.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
User avatar
Datastream
Donator
Donator
Posts: 870
Joined: Thu Dec 24, 2009 1:24 pm

Post by Datastream »

In the model I see this: IDST0 ,MZ(R)alyx.mdl

Do I change the . before .mdl to a ,?


Changed the 0 to a , and it worked! I have no idea why it's a 0 but whatever. It worked now.
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

Sweet, I must remember that!
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
User avatar
Datastream
Donator
Donator
Posts: 870
Joined: Thu Dec 24, 2009 1:24 pm

Post by Datastream »

Another problem:

When I tried recompiling my zerosuit model I got from garrysmod.
It said this:

Code: Select all

Working on "mdldecompiler.qc"
SMD MODEL C:\Documents and Settings\%name%\Bureaublad\Models_d/Samlyx.smd
VTA MODEL C:\Documents and Settings\%name%\Bureaublad\Models_d/mdldecompiler_expressions.vta
ERROR: c:\documents and settings\%name%\bureaublad\models_d\mdldecompiler.qc(41): - can't find eyeball texture "eyeball_r" on model
ERROR: Aborted Processing on 'player\Zerosuit.mdl'
I don't know why it's saying it can't find the eyeball_r on the model. How do I fix this? I did all you said I had to do in the .qc file.
Except that I saw other $includemodel too.
These in fact:

Code: Select all

$includemodel "alyx_animations.mdl"
$includemodel "alyx_postures.mdl"
$includemodel "alyx_gestures.mdl"
$includemodel "player/f_anm.mdl"
$includemodel "player/f_gst.mdl"
$includemodel "player/f_pst.mdl"
$includemodel "player/f_shd.mdl"
$includemodel "player/f_ss.mdl"
$includemodel "player/cs_fix.mdl"
$includemodel "player/global_include.mdl"
These are not in the player folder.
And I think even if I do fix the eyeball_r problem the eyeball_l problem will pop up since it's similar.

Here is the .qc code for the eyeball_r and eyeball_l:

Code: Select all

     eyeball righteye ValveBiped.Bip01_Head1 -1.300 -3.100 65.160 eyeball_r 1.000  3.100 Fit_Nsam_pony 1.300
     eyeball lefteye ValveBiped.Bip01_Head1 1.300 -3.100 65.160 eyeball_l 1.000  -3.100 Fit_Nsam_pony 1.300
P.S.: I got the model here: http://www.garrysmod.org/downloads/?a=view&id=46715

It's supposed to be a replacement for alyx in ep2.[/code]
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

Erm, isnt that already an oc player model, I'm sure i've seen it.

Anyhow to fix the eyes:


First, I suspect you have two $cdmaterial commands, one you change to point to the models materials and another that points to somehting like humans\male.

The problem is gmod has different structure for some of its files, than oc.
So you probably need to change to obsidian.

So you need the path to be something like $cdmaterials "models\player\male"

^you should find the eye the qc. is looking for on compile.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
Post Reply