Thursday, October 8, 2009

weight mapping for characters: a how-to guide

What this covers
 

This post will cover how to fix weight maps for Half-Life 2 characters after you've extracted them, as described in the previous how-to post. The XSI import is broken, so you have to do a bit of work before you can create animations!

So far, you've extracted all the textures and models from a .mdl file. Now, we'll import them into XSI and fix the weight maps so that you can animate. This process would also work for tweaking your weight map after you've rigged a character from Poser or some other source.

You will need

A decompiled model and its textures
XSI Mod Tool 6.01
XSI Valve Source Plugin
Patience!

How it's done

Importing a model

1) This is the easy part. Drop down on the ValveSource menu in XSI and choose "Import SMD..." and a dialogue box will come up. Navigate to your SMD file (you probably want to choose the one that is a reference model), and choose the folder that all your textures are in. Check off "Import textures" so that you can get an accurate view of how your model will look. Make sure your textures are all in .bmp format or the importer won't be able to find them. Click OK, and your model will import!



2) Some quick key commands that will help you: press 'z' for the zoom and pan tool (middle and right click zooms, left click and drag pans), and 'o' for the orbit tool, which lets you move the camera around in the user view panel. Go ahead and use the 'z' tool so you can see your whole character in the User view. Now we'll turn on a couple shading options so that we can see them better.

3)  First, on the top right menu for the viewport, click "Constant" for the shading option.


Then, under the eyeball menu, make sure that both "Weight Points" and "Weight Maps" are checked off.


When you do that, and select the object, you'll get a multicolored model:



All these colors represent how the joints of this character affect the vertices around them. For example, look at the bright red on the right toe (to your left!) of the character. Everywhere that bright red is will be affected by the joint that is associated with the right toe.

4) Let's modify a joint. It'll be easier if we use Project Explorer. Press '8' to bring up an explorer window. Go ahead and switch to an orthographic view--I'm going to use right side. (You can do this by using the drop-down menu at the upper left of the viewport: click and change from 'User' to 'Right'.). Reposition using the 'z' tool so that you can see the whole model again.




5) See all those little multicolored plus marks? Those are your character's joints. It's kind of hard to tell which belongs where since we have no sense of depth, but using the Explorer we can narrow them down.The character's left leg is the one closest to it, so I'm going to show you one of the joints associated with that. There's a little star looking thing in the Explorer that says 'Bip01_Pelvis'. Click on it to expand that tree. When you find Bip01_L_Thigh, click on it, and you'll see that joint highlighted in white.

6) So, let's say I'm trying to get my character in a sitting position. I would want to rotate the thigh so that her leg is at a near 90 degree angle to her torso. I choose the rotation button ('r' on your right panel) and I rotate about the y-axis (green) by clicking and dragging around it.



7) Something's obviously wrong. See how those points near the back of her calf are incorrectly positioned? If you look around in the user view using 'o' to rotate around, you'll also see that her knee has caved in and her waist is doing some strange things too. This is because the weight map isn't working correctly. The thigh joint is inappropriately affecting those points, so we need to fix them. Translation isn't the answer because the animation for this character won't be saved on the basis of each point's location, but only on the basis of how those joints have moved.

Fixing the weight map: Smoothing things out

There are several ways of fixing the weight map, but before we go to tweaking individual sections and points, there's a way to automate a good bit of that process.

1) Switch back to user view and weightmap shading (as described in the first step of this tutorial). I'm also going to put her leg back to normal position, but you don't have to. Now, click Animate > Envelope > Smooth Envelope Weights.

2) A dialogue box with a little graph pops up. Now, to be quite honest with you, I only understand on a very basic level what this graph does. In my definition, it modifies how the weights are distributed for the points. There's also sliders for Neighborhood Depth and Distance Profile Scaling. All of these settings together determine how points are weighted. Now, it's your job to play with those settings until the weights are mostly right.

If you click the "?" button in that dialogue box it will tell you a bit about how the graph works. If you look up the help file for "Smooth EnvelopeWeight Operator Property Editor" then it will tell you a bit about each of those attributes. The summary is that for each point, the weight is calculated as a weighted average of what's going on in the points near to it. Changing the neighborhood depth changes the amount of nearest points it takes into account. I don't really understand what the distance profile scaling is. The distance effect profile is a graph of a function that determines how the weighting works when calculating the average.

I'm sure there's a scientific method for doing this, but because I don't understand it, I opt more for art than science. Look at the picture of the weight mapped model now. See how it's all splotchy? In the splotchy areas, that means that multiple joints are affecting those areas. For example, check out my character's face:z


So, you can see that it's mostly blue, but it has these pink and yellow splotches. That means that those points are affected by something different than the "blue" joint. If I sift through my joint tree enough, noting that the joint colors correspond to the weight colors, I find that the Head1 joint is blue (that makes sense!), the Neck1 joint is yellow, and who even knows what that pink color represents!

For all those points on the face, it makes sense for the position and orientation of the head joint to influence them, but not the neck joint. Now, note that the head joint is still related to the neck joint, and what's not what we're editing. We're just editing how points relate to joints, not how joints relate to each other.

3) So, the way I edit visually is to play with the parameters until the model doesn't look so splotchy. This indicates to me that the points that are near to each other are influenced by the same joint(s) and not a strange combination of joints. You kind of want clearly separated colors with smooth transitions between them.

In this case, I set the neighborhood depth to 5 and the distance profile scaling to 25. This leaves me with a much smoother, more coherent model. All the blue points are together. Colored points are grouped with similarly colored points (although colors are reused). Colors transition smoothly but there's clear definition between body parts. I'm pretty happy with this so I go ahead and exit out of that dialogue box.


4) If I go back to an orthographic view (or really, however you prefer) and try my movement again, you'll see I get a much cleaner look!



5) You might want to go ahead and save this model in the state it's in now just in case you mess something up down the road. Assuming all your weights are correct (which they may or may not be) this could turn into your "reference pose", which is the standard pose that your character takes with all the correct weights. I'd recommend saving it in XSI proprietary format so that you won't run into strange problems importing it later if you do mess up. There's something weird about having to save these in a proper location. If you saeve them in C:\Softimage\XSI_6.01_Mod_Tool\Addons\ModTool_Database\Scenes it works out for me.

Fixing the weight map: Tweaking points

Play around with your joints a little. You'll see that they're mostly working like they should. However, you may run into some points that are still doing some strange things that you'll want to tweak a bit. I'd suggest going through and rotating each of the joints to see if there's anything that looks strange when you do. Now, of course things will look strange if you rotate the joints beyond what your own body would do. Rotate them within normal bounds, though, and everything should look okay.

My model's looking pretty good right now, but I'll step you through the correction process. Let's say that for some reason your weighting is wrong and points are being misplaced from your hand when you move some joint that shouldn't affect your hand (say, your neck or something).

1) Select the object, then drag a box around the points that are affected. Right now, I'm dragging a box around the hand.  All the points inside that box will turn red to indicate they are selected.


2)Go to Animate > Envelope > Edit Weights... A dialogue box will appear.


This dialogue box holds a whole lot of animation. There is a row for each vertex selected (each is numbered in the leftmost column) and a column for each "deformer" or joint that affects those set of points. If a box is highlighted in purple, that means that the point is affected by that joint.

2) An easy way to get rid of improper weighting is to look at those column names (mouse over and pause to see a tooltip with the full name) and see if there are any that shouldn't be there. For example, I've selected the left hand, so it's reasonable for me to expect all five fingers to be there, and the hand, and maybe the wrist. Even the neck and the back might affect the way my hand is positioned a little. However, if I see something like the character's right foot, I know that's incorrect.

Find the columns that shouldn't be there. Select the whole column by clicking on its header. Adjust the weights to be equal to 0 for that column by using the slider just above the chart, and chosing a mode: Abs sets the weights to what you slide on the slider, Add adds or subtracts what you choose on the slider, and Add % modifies the weight by what percentage you slide on the slider. You also want to make sure "Normalize" is selected because it's necessary for the weights for any one joint to add up to 100%. That way, as you adjust a point, the extra percentage is given to other joints. Here, I've reduced the Neck's influence to 0 over my hand as an example



Do this for each column.  You can also use this dialogue box to tweak point by point, or decrease (instead of eliminate) the influence of a joint on a point.

3) Again, it's a mostly visual check to see whether this worked or not. An alternative check besides trying animation is to investigate each of the joints and check which point they influence. To do this, keep the weight editor window open and press '8' to open the explorer. Zoom out to see the character's full body. Now, select any given joint, and the points it affects will be highlighted in white. For example, I've selected the right upper arm in this screenshot.



Like I said, my weighting looks pretty good, so all those points look like they're ones that could be affected by upper arm movement. But, if there was a stray point or two, I could single it out from there and change its weighting using the Weight Editor.

Another method: Weight Painting

Another method of changing weightmaps is painting them, which is a bit more visual and possibly more intuitive.

1) Press 'w' to get the weight paintbrush, then press Ctrl + w to get the Brush Properties box.


2) I really don't understand how to pick which "color" or joint to paint with from here, and I can't find good documentation on it, but the idea is that you can then paint on the weights that you want to change, whether it's adding weight, replacing with a new weight, or smoothing out the nearby weights.

That's pretty much it for weightmapping! After you get a good weightmap be sure to save a copy, then you can begin animating. The next tutorial I write will probably be about that!

For now, I'm saving everything in XSI proprietary format so that import/export is not an issue. Later on, I'll also be writing about getting things back out to .smd format and compiling them into a usable model for the Source Engine.




Wednesday, September 23, 2009

When you use the child hair in poser. It will look like a white wire mesh, but when you render her, the hair will look like it is suppose to. It is just something poser does to DAZ opjects.

Monday, September 21, 2009

extracting Source characters and textures: a how-to guide

What this covers


This guide will  go through the process of getting files for a Source SDK character that can be edited in a modeling program and an image editing program. The process for non-character objects would be similar.
 
You will need

VTFEdit
GCFScape
MDLDecompiler (drop this .exe into C:\Program Files\Steam\steamapps\\sourcesdk\bin\ep1\bin


How it's done



Extracting from GCFs
First, a little background information. All of the Steam game assets are found in GCF (Game Cache Files) files that relate to each of the games. They're all packaged together like that so that the game assets aren't changed when you're working with your own files. You have to extract out your own copy to edit and use.

1) Install GCFscape and in the installer choose to have it associated with GCF files.

2) Navigate to where the GCF files are stored.On my computer (and probably yours too) it's on C:\Program Files\Steam\steamapps.




3) We have to open up two different GCF files to get what we need: one for the .mdl files, which hold the character's structure and animations, and one for the .vta files, which hold the character's texture information. First, we look for the .mdl file. In my case, I'm exporting the female_02 model. So, double-click on "source models.gcf" and GCFscape will come up with an explorer pane. You can find all kinds of assets in there, but I'm going to navigate to hl2/models/humans/Group02 to get my model. Over in the right pane, select all the items prefixed with Female_02, right click, and select "Extract".



4) It'll ask you where you'd like to put it. Pick a folder. I made one on my desktop.

5) Now, we're going to repeat nearly the same process, except for the textures. Open "source materials.gcf", go to hl2/materials/Models/Humans/Female/Group02. Grab and export all the files in that folder to the same folder you put the other stuff in. Those are only the faces for all the females, so you'll also need to get their clothes, eyes, and mouths. These are found a folder up in hl2/materials/Models/Humans/Female/. Select all the files in that folder, and export them as well.

You're done extracting from the GCF file!

Decompiling the model
Now, we want to decompile the model from the .mdl file into some .smd files so we can import them into XSI Mod Tool, or Maya, or whatever other modeling program we're using.

1) Open up MDLDecompiler. It's annoying because you can't browse to the model; you have to copy and paste its location. So, find it in Windows Explorer, copy and paste the address bar, plus the name of the file. Then, you can browse to find the output directory. Make sure all three of the lower checkboxes are unchecked.


2) Click the "Extract" button. If all goes well, a couple dialog boxes will tell you that you've loaded the model, and then that you've completed dumping the model. You're done! If you look in the folder that you dumped it to, you'll find a bunch of .smd files, which are animations and models. You'll find a .qc file, which is code written in Quake C that defines the model and its animations. Then, you'll find one or more .vta files,which define facial animations. We're not opening any of those files yet.

You can edit the SMD files in Maya, given the correct plugins. I'm waiting on a Maya license at the moment so as soon as I get that I'll write a how-to guide on editing SMD models there.

Converting the textures
Now, to get the textures into a format we can work with. The compiler will want .tga files, so we want to decompile the .vtf textures into .tgas.

1) Open up VTFEdit and navigate to the folder where you put all your textures. Or, if you associated your files with VTFEdit at install time, you can double-click on them to open them up.

If you click on a .vmt (Valve MaTerial) file, you'll get a text file that looks something like this:

(for dark_eyeball_l.vmt)
"eyes"
{
    "$basetexture" "models/Humans/Female/dark_eyeball_l"
    "$iris" "models/Humans/Female/pupil_l"
    "$halflambert" 1
}

Don't worry aobut those for the moment. If you open up a .vtf file you'll see an image.





There are bunches of check boxes and stuff on the left that we're not going to worry about for now. They'll be useful on recompile but right now we're just worried about exporting.

2) Go to File>Export and then pick where to save your .tga file. Your file will be exported into that location, then you can edit the Targa (.tga) file using an image editor like GIMP. It's just like editing any other image.

That's it! Let me know if you have any questions.

BMW motorola Symbol

The representative from Motorola contacted me and I found out that the device that they currently use only has audio output, there isn't a type of Video output. The representative said that he was pretty sure that there was not an available device that would do what we needed it to.

Useful Links for Character Creation

Here are some links that I have found that have some pretty good stuff on it.
//both of these have freebies!!
http://faerie-dreams.com/page_3.html
http://www10.sharecg.com/search/index.php?q=maddie&button.x=0&button.y=0

sharecg is where I found the free dress and the free morphs for the hair.
faerie-dreams has the free play clothes, and whimsical costumes and hair props.
Still trying to figure out how to make them all fit.
Will continue to look for more free stuff.

When downloading free stuff, make sure to put them into the correct folders
c->program files->smith micro->poser pro->downloads->runtime->..........

resource for import and modification of Source assets

Stumbled across Kathar's website today. He has a whole section on HL2 modding, specificaly on asset modification (i.e. decompiling and recompiling HL models, which is also helpful for importing in our own models.

yay progress.

Friday, September 18, 2009

tools of the trade: Cannonfodder's model decompiler

To access and modify models, you need to use this decompiler:

http://www.chaosincarnate.net/cannonfodder/cftools.htm

For the executable to work, it'll need to be in:

C:\Program Files\Steam\steamapps\\sourcesdk\bin\ep1\bin


then you can pick which file to decompile.  You'll get a bunch of files when you do:

.smd files are models, animations, and textures, all put together
.qc is a file in Quake C, that instructs the compiler on how to interpret things
.vta is a texture file

Extra steps are needed to get into each of these files. .smd files can be imported into Mod Tool by using the ValveSource plugin, as can .vta files. .qc files are plaintext so you can edit them.

tools of the trade: GCFScape

As I was going through the models in Face Poser and Model Viewer in the Source SDK, I wondered where all those models were stored, because I was thinking about looking at the construction of a couple of them to get some ideas about how to build our own. Model files in Source have a .MDL extension, so I did a system search for ".mdl", but no results! Strange.

I began poking through the folders and found these large files with a .gcf extension. After looking at the wiki, I found out that these are where all the resources for the games are stored. To get into these files to get out resources, you need a tool.

This is where GCFScape comes in. You can download it here:

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

So, you use this little program to extract out all the files used in the game. For example, I'm considering using one of the Half Life woman models for our patient's mom. I opened "source 2007 shared models.gcf", looked in hl2/models/humans/Group02 and grabbed all the files beginning in Female_02, and now I have all her data. I'll have to decompile using another program to really get to the inside of her, but that's a start!

So, when you see these mysterious figures from nowhere in your programs, now you know that they are contained in the gcf file and you can get to them if you want to :)

Wednesday, September 16, 2009

version control: a quick tutorial

About how it's set up:
I set up version control with Nell over the past few days to manage our files and revisions since several of us will be working on this project and trying to synchronize versions is generally a mess. Additionally, it will track changes for us, which proves to be invaluable on any large project.

I chose Subversion for our version control because I'm familiar with it and it's well-respected. Since we're using a Windows Server, I chose svn1click for easy setup and start up. It does most configuration for you through a Windows installer and goes ahead and starts the Windows service so you can access it.

I modified permissions to allow for all of us to access it through username and password, and to disallow anyone else from accessing it. Here's a little guide on setting a few of those things up, for future reference. It's super easy.

About how you should use it:
To access the repository, you need to download a svn client. I (and a lot of people) use TortoiseSVN. It integrates right into your right-click menu, making the repository easy to access. Go ahead and download and install it.

To set up your repository for the first time, make a folder where you'd like to keep your project. Open the folder, then right-click on the inside of it. You should see an option for SVN Checkout. Click it.
You'll get a dialogue box. Fill it out with the url of the repository, just prefixed with "svn://". In our case, that's svn://vegroup.cs.clemson.edu. The second folder should be the folder you just right-clicked in. The other settings are fine as-is.
 
After you click "Ok", you'll be asked for username and password. Ask me, and I'll tell you what yours is--it's different from your other passwords! After you authenticate, you'll get a progress dialogue box, and then if you look in your folder, you'll see stuff has been put there. The green check beside the folder means it's under version control. 


If you open up that folder, you'll see three others: branches, tags, and trunk. For now, we won't be touching "Branches" or "Tags", only "Trunk". Trunk is where all your work should stay, for the most part.
I'll step you through four processes right now: adding a file, modifying a file, updating your project, and restoring to an older revision.
Adding a file
 Open up the trunk folder. Make a file (any file will do for now). I'm going to make a text file and type some random gibberish in it. Now, let's say I want to add this to the project. Right-click in the folder, then choose SVN Commit.


When you click, a dialogue box will come up. In the top text box, write a comment that describes what you're adding. Comments help your team understand what you're doing, and find revisions when they  need to. The bottom pane is a list of files that you've changed. You can see that beside my new text file it say "non-versioned", meaning I've never uploaded it before. I am going to check that box so that it is uploaded.
I enter my login information and click okay, and now my file is under version control! Yay!

Changing a file
To change a file and its contents in the repository, just open up the file, do what you need to in it, then follow the same process as above.  Choose SVN Commit, then follow through the dialogue boxes. Your change is made!

Updating your project
Let's say that someone else was working on the project and added or changed some files too. It's good practice to make sure your files are up to date before you start working on them. So, before you sit down to modify any piece of the project, right-click and choose SVN Update. After clicking through a few dialogue boxes, your project will be brought up to date with whatever's on the server.

If you think it through a little, it's easy to see that this can cause some problems. What if you and someone else were changing a file at the same time? SVN handles this nicely. Instead of just overwriting your file when you update, it will show you that the files have a conflict and give you options on how to merge them. That's for learning about another day, though. Another thing you want to think about is that other people are using the code you check in. So, try not to check in anything that is broken, or else, other people will try to use it and be frustrated. Only check in once you have useful code. There are ways to get around this (like creating branches) but again, I'm not covering that right now.

Going back a revision
Let's say that I made a change in my code that turned out to make things go wrong, or that I realized I liked an old version of something better. SVN keeps track of all revisions so that you can go back to old versions.

To do this, right-click on the file you want to shift back. Then go to TortoiseSVN>Show Log.
You'll get a nice little list of all the revisions that have happened, along with the comments (this is why comments are important!!).
Then, you have bunches of options. "Compare with local copy" will show you the changes since that revision. "Save Revision to" will let you save that revision to another file. Open/open with will, well, let you open it. You can also pick "Revert changes from this revision" to make the changes from that revision go away, or "Update item to revision" will change your local copy to that revision.

Okay, there's a bit to get you started! You can do a lot more complicated things with SVN. Read about it yourself, or I'm sure I'll be posting more detailed steps for common tasks later.

Monday, September 14, 2009

starting point for character animation

In reading, it's become clear that any body animations associated with a character must be exported inside the SMD file for that character. There's not good documentation for how to export, though. The closest I can come to it is to find how SMD files are formatted:


http://developer.valvesoftware.com/wiki/SMD

Under that "vertex animation" section, that's where our stuff would be, but as you can see, that section is kind of undocumented. I'll spend the next few days trying things and looking at the file to see what I can decipher, as well as asking as many people as I can think of about how to do this.

Friday, September 11, 2009

Structure of a Source Mod

There are good step-by-step guides for setting up a Source mod, but I want to take a little bit to explore the structure of a Source mod after it is set up in its folders. Our team will be using version control and working from the same (already set up) project, so this is important so that we're all on the same page.

When you create a mod, it creates two folders: one at a location you specified, and one under the Steam application path. So, for my working copy, these folders are:

C:\virtual_patient
C:\Program Files\Steam\steamapps\SourceMods\virtualpatient

Let's talk about what's in each of these folders.

C:\virtual_patient
Here's a screenshot of its layout, partially expanded. (Yes, I misspelled "patient", haha.)


The folders are fairly well named. We don't really have to deal with most of them. The ones of interest are:
mapsrc: where uncompiled maps made using Hammer Level Editor should be stored
materialsrc: where textures and materials that we use for our game should be stored
modelsrc: where uncompiled models files should be stored (i.e., SMD format).

Of course, we are also concerned with the src folder, but only a small portion of it. Opening up that folder yields a bunch of subfolders holding source files, as well as two Visual Studio 2005 projects (don't worry, you can convert it to 2008 as well). We're not too concerned with the Everything_SDK-2005 solution. The Game-Episodic-2005 solution is the one that all our work will be done in. Opening that project will show that it's associated with a LOT of source files. This solution contains two projects: Client Episodic and Server Episodic. We'll only be working in Client Episodic.

If you open that project you'll see bunches of source files. Again, most of these will not be important for our purposes, since we're not shooting guns, fighting monsters, climbing ropes, or anything like that. What you're actually looking at is the full source code for whatever game you're modding. As you can imagine, our mod will probably end up deleting or not using the vast majority of these files. The ones that will be important to us are the more utilitarian ones, like the ones for physics, camera movement, level rendering, and human behaviors. However, this gives us some GREAT source code to work from. You can wade through a few files and try to make sense of them if you'd like.

C:\Program Files\Steam\steamapps\SourceMods\virtualpatient


All right, on to the second folder. In the root folder, there's gameinfo.txt, which holds important information about our game and might have to be modified eventually. The rest of the files you can kind of ignore in there, I believe. The folders here are well-named, too.

The cfg folder holds .cfg files for each "chapter" of our game (in our case, might end up being different nurse interview scenarios, for example), along iwth config.cfg, which looks pretty important, but I'm not sure if we'll have to modify that or not. Under Expressions you can see pictures of animations and phonemes for some characters; not sure why they're there at the moment, except that I opened them in FacePoser and perhaps it placed the images into my project. Under Maps are maps that you compile to run in your level using the Hammer Editor. In Scripts and its subfolders there are various animation scripts for vehicles, people actions, and effects. Of course, that will be very important for us in our project.

That's a brief overview of the structure of the mod that Steam sets up. More about the location of utility programs and files later!

Step By Step: Exporting a Character from Poser to Half-Life Uncompiled Format

Since there is not a good step-by-step guide, I am going to write in detail how to get a character out of Poser into a format that Half Life can use, with instructions and screenshots.

This process was taken from the two YouTube videos cited in the previous post.

Tools You'll Need:
Poser (another modeling package would probably be similar)
Source SDK
Mod Tool 6.01
ValveSource Plugin for Mod Tool

Exporting from Poser

1) Open up Poser Pro (or your other program) and get the model you want. I'm using Simon because he's dressed and ready to go. Select File>Export>COLLADA.
EDIT: In order to make the textures map correctly, try exporting as a .obj file and importing that into Mod Tool. Sometimes COLLADA doesn't work right.
 
2) In the next dialogue box, select Single Frame export. I haven't figured out animation yet, but it may be that in the future multi-frame export is useful for animation. Separate post for that!
 

3)  In the next dialogue, make sure that only Simon is selected.

4) Give your file a name in the following dialogue box. In the one after that, change the scale to 1000%. Uncheck "Include Normals" and "Include Rigging" since we'll be rigging the character ourselves. Everything else should be set up okay from there. If a "Select Morphs" box comes up after that, just click "OK".


Importing into Mod Tool

5) Yay, your model is exported! Now, open up Mod Tool. (BTW, all these programs take up a LOT of memory so if you run them at the same time, your computer might crash. I advise opening each separately.)
In Mod Tool, go to File>Import>Model...
 
6) Choose Collada (.dae) on the File Type dropdown in the Open dialogue. Find your model and double click it to import. You'll probably get an error in red at the bottom: Triangle Count Exceeded. Don't worry about it.
Reduce Polygons
7) Let's go ahead and reduce down the polygon count to make it easier to work with (and allow for export into Half Life). Choose Model>Poly. Mesh>Polygon Reduction.


8) When the dialogue box opens, use the "Units" drop down menu to select "Final triangle count" and then beside "Tri Count" type "7000". Half Life will allow for up to 7500 polygons for its characters, so I'm just exporting a little below that count to be safe. Immediately your image will change to have fewer polygons. You'll see a visible difference.

Exit out of that dialogue box.

Freezing Transforms


9) To make your model export correctly, you need to freeze all of its transforms. This is accomplished by clicking "Transform" in the right hand menu then clicking "Freeze All Transforms".



Baking the Textures

10)One more step before we line up the skeleton: exporting the texture map. When you exported the COLLADA file, in the same location, all the textures were saved with it. Although they don't show up on your model right now, they're still associated with the appropriate parts. What you need to do is to let the program make one texture out of all those textures and to save it somewhere. To do this, click on the character to select it, then go to Model>Property>Render Map.


11) When that dialogue comes up, set X Res to 512 or 1024, whichever works, then next to UV, select New>Unique UVs (Polymesh).

12) Set the Path to wherever you want to put it, preferably in the Source SDK material folder that you'll be using. Choose Targa(.tga) under "Format", and under the first dropdown under the Map section, select "Surface color only (albedo)". Then, click "Regenrate Maps..." and exit out of the dialogue box.
 
13)  Press 8 to open the explorer (handy shortcut!) and find your object. Delete any materials that are already there.

14) On the right sidebar, under "Create", click "Textures", then click "Image."A dialogue box will show up. 


15) Click "New" beside the Image dropdown, and find your image that you saved for the texture.Yay, your model is textured! If you choose "Textured" under the drop-down view mode menu to the right of the screen, you'll be able to see your texture. (You can see my texture didn't turn out so well in this screenshot. I'm not going to take the time to fix it now because usually it turns out okay. Look for a separate post on texture tweaking.

 



Add & Align Biped Guide
16) Now that our character is all set up, we're ready to put bones into it! Choose ValveSource>Character Rigs>Biped Guide. (I'm going back to wireframe view for this.)

17) When you do that, a "skeleton" will show up on the screen with different lines connected by boxes. But it is HUGE! Type "z" to activate the zoom tool, then right-click to zoom way out to see the whole thing. You should see your character in between the legs of the guide.


18)The boxes act like joints and the lines act like bones. Your goal is to line up the bones and joints as closely as you can with the Poser model. So, you'll want to select the model and use the Scale, Rotate, and Translate tools to line up that character. First, uniformly scale up until the shoulders and head kind of line up. You can do this by typing scale coefficients into the "Transform" box near the "S" on the right side of the screen, or by clicking "S" and then dragging the box in the middle of the three axes. I like typing because it's quicker, but sometimes it doesn't work correctly. You also might want to switch from 'User' perspective to 'Front' perspective so you don't have to deal with the distortion that the camera brings while resizing.
 
19) After you get it scaled up appropriately, click on the red boxes to select them ('y' is the shortcut key for getting into select mode). Then, click on the R and T buttons for rotating and translating, and make the bones line up with the body. Other helpful keyboard shortcuts: Zoom tool, press 'z', then middle click is zoom in, and right click is zoom out, and left click + drag is reposition.
  
20) This part is more of an art than a science. You need to line up all those bones from Top, Right, and Front views. The hands will be the most difficult part since you have to move the position of each of those fingers.  I'm not going to take a lot of time to do my alignment since I'm primarily doing this for tutorial purposes, but go ahead and spend some time to make this right. A quick check shows all my bones are decently in line from each perspective.

Rig the Character
 21) Now, select ValveSource>Character Rigs>Rig from Guide. It'll do a bunch of magic.You'll end up with a different looking model and bunches of dialogue boxes. You can exit out of all those.



22) Press 8 again to open an explorer, if you closed it. Click on ValveGuide, then press Ctrl+T for "Select Tree", then press the Delete key to delete the guide.

Envelope the Character
23) Almost there, I promise!   Expand ValveBiped in the explorer. Click to select your character, then go to Animate>Envelope>Set Envelope.

24) Click "Yes" in the dialogue box that comes up next. Then, your mouse cursor will turn into a little arrow with "PICK" right beside it. Now, left-click to select, then right-click to confirm. Sometimes this works weirdly for me but keep trying that process and eventually you'll get a new dialogue box (that you can close) and a colored-point version of your model.
 
Tweaking the Points
25) All right! You're close to done! Use the rotate and translate tools and select some of the random sphere things that were added to your model. Play around with them and make sure that your character is moving fairly naturally. Try nodding/shaking its head, moving arms forward and backwards, etc. If you find something that's deforming strangely, then you'll want to edit their point weights. I will cover that later in a fine-tuning tutorial.
Exporting
26) Finally! Click on ValveSource>Export to .SMD. Pick the location of where you'd like to save the file (probably in the models source folder of your mod). You can leave all the other settings. Click the OK button!

You're done!! Well, kind of.
The next steps are compiling together the model you just exported and its texture into one file that Half Life can handle. I will be covering these steps in a future tutorial, since I haven't worked quite that far yet.

Remaining things to do for character importing:
- Actually getting the character into the mod
- Finding out how to do animations using this model in Face Poser
- Figuring out if there's anything additional you have to do to allow for lip syncing

Final Words
Yeah, the process seems long and overwhelming, but the truth is, after you've done it 10 or 12 times (as  I have while trying to get things right) it's not too bad. You'll get better at it. Any modeling tool has a steep learning curve but after spending a bunch of time using Mod Tool and learning the different shortcuts you'll get much quicker at it.
Please let me know if you have any problems or questions!