Making a 3rd Person Model for Half-Life - Page 1

Making a 3rd Person Model for Half-Life

By

RatLogo.gif (7996 bytes)

This tutorial has been made possible because of the response I have been getting for the first in the series. I appreciate the feedback. A lot of you that have dropped in on the wavelength channel to say thanks is also much appreciated! As mentioned on the last page of "Making a World Model for Half-Life" we will be taking the model that we just made into a "p_" model. And if all goes well with the series, we will move on to a "v_" model, which will require animation. Then I hope to help you make a character model. download of this entire Tutorial in HTML is available at: http://www.drawcad.com/upload/HL-P-model-Tutorial.zip

What is needed to complete your model

As mentioned in the "Making a World Model for Half-Life" tutorial, you will need to get a copy of the Milkshape 3D program by Mete Ciragan. This can be found at the following web site: http://www.swissquake.ch/chumbalum-soft/index.html

Another program that we will be using for the extraction of Valves and other add on packs and Modifications models is called Qped. You can find this at:

http://www.planetquake.com/qped/

Another program that will be useful in your creation of models is the Half-Life Model Viewer that can be found at:

http://www.swissquake.ch/chumbalum-soft/hlmv/

The p_ model and what it is

These models are what you see in the 3rd person, as what you see another player hanging onto in battle, e.g. a glock, etc. This is a required model to be able to view your model if someone else happens to be using it to get you with it.There is no animations that are involved in it. In actuality it should be easier than a world model, because on rare occasions you see a world model that has some animations. For example, take a look at the "w_squeaknest" model in "HLMViewer.exe." You will see it has 2 animations, one that never is used in HL, called "walk." The hard part about the "p_" model is that you have to have the supporting biped's bones added to it, or at least a portion of it, for it to look like it is attached to the model that is using it. Look at Figure 1.1 for an example of our "p_knife2.mdl," to see how this weapon will look with a partial Skeleton that has to be used to reference the full "biped," (a biped is the skeleton or all the joints of a model. You have to make some sort of a biped so that the mesh of your model can distort to look like it is alive or in movement). of the model.Where as our World Model, or "v_" model, scale is slightly larger than , 3rd Person, or "p_" model, around 1.3 instead, compared to that of 1.0, you can use the very same model..Now you know why we made the World Model first! A modified version is made for the ViewModel, or "v_" model, in which you can remove the hidden faces to reduce the polygon count. But more on that latter. On with the "p_" model!

mt-fig2-1.gif (37959 bytes)

Figure 1.1 Screen shot of completed 3rd person model in Milkshape 3D

In this tutorial, we will be learning how to get the model so you can view the knife2 model that we made in the first tutorial as a world model, as a 3rd person world model. There is not much going on with it, but you can have some fun with it as I show you a few tricks in how to get it ingame to look at your handy work.

Creating a Skeleton or Biped for your 3rd Person Model

You will need to either create Skeleton, partially that has the same joint, or bone names that the player model has that you wish to see you model attached to. Here is where, if you wish to not create a entire Skeleton, or Biped, from scratch, is to steal from a previously created Skeleton.

Note: If you choose to create a new biped, you will have to animate each and every animation that is required for a DM player in HL. There are presently 77 animations, (some are two of them combined called "blends," that are a combination of 2 animation to make 1 animation. A blending of two separate animations to effectively make it look like you are changing or morphing from one animation to the next, to create an illusion of if you happen to be using the mouse up, or the page up, or else you would be using the mouse down, or page down in aiming, shooting, etc. This brings us to 129 total animations that have to be made for scratch!).

The reason behind doing skeletal animations is that you do not have to make or distort your model's mesh for each frame of action. Quake models used mesh animations, and this took forever to do this kind of thing to hammer out a model. With Skeletal animation, you only need to create the mesh, once. The skeleton is then animated and the mesh is later deformed to fit the skeletons animation on the fly. This is done by code that checks for the particular position of all the bones and making sure that the mesh that is assigned to the proper bones are in place for that particular frame of animation. e.g. if you are walking, the code checks the frame of animation that is current, and places the foot where the skeletons animation currently is. Some deforming has to be done, this is why some animations may not be perfect, and reassignments of joints, or bones are done so the deformation looks realistic. i.e. if you assign on of the fingers on a hand on the left hand to the right hands finger of the same position, it will look as if the finger had stretched to the tip of the bone on the right hand, causing an unwanted distortion! No we do not want to create an unusual creature from the murky depths, but a natural looking humanoid!

Open the "w_knife2.ms3d" file that you created in the last tutorial, or download it from:

http://www.drawcad.com/upload/p_knife2.zip

Note: You will need Milkshape Version 1.4.0 to open the Ms3d file that is contained in the zip.

Of course you will want to be making a new directory for this "p_" model and we will name the directory "p_knife2" so as not to be confused with the "w_knife2.mdl" that we made in the last tutorial. save this file as "p_knife2.ms3d."

Lets get to work on our Skeleton. I am going to be looking at a similar biped that would be used for the creation of the character that we will be eventually be making. This is going to be a secret for now as to how the player model is going to look.

First off you do not have to create the skeleton completely to make a "p_" you only have to make a portion of it. But as mentioned before, these "joints" or bones need to have the bone names exactly the same as the "biped," or skeleton of the full character model that we will eventually create.

I would like to pause here a bit to show you how you can save yourself some time in the creation process of a biped. Milkshape 3D has as mention in the "Making a model for Half-Life" tutorial, has a decompile utility. This means that you can decompile models that have a similar mesh build and taking the biped out of it.

Create a new directory called "op4_knife" to save to when we export the knife for the next step.

You will be looking for the op4 knife in the add on pak0 file of "Opposing Force®" and decompiling it to see how its "p_knife.mdl" looks like and what the bone names are called. So start up Qped and lets extract it. Choose "File->Open..." and find your "pak0.pak" file from the "Opposing Force®" directory. I found mine in this directory structure: "C:\SIERRA\Half-Life\gearbox" yours may vary.

Export the knife to your "op4_knife" directory. See Figure 1.2 for and example of this.

mt-fig2-2.gif (8448 bytes)

Figure 1.2 Exporting the op4 p_knife.mdl

Page 2->


Making a 3rd Person Model for Half-Life - Page 2

Close the Qped program as we are done with it. Select "File->New" in Milkshape 3D to clear out the model and joints that may interfere with importing of the op4 knife model. Select "Tools->Half-Life->Decompile Normal HL MDL file..." in the menu selections. Look up the "p_knife.mdl" in the "p_knife" folder on your hard drive.Click "open" to get the dialog box as in Figure 1.3. You want to have all the check boxes checked as in Figure 1.3.

mt-fig2-3.gif (1586 bytes)

Figure 1.3 Decompiling the op4 p_knife.mdl

Open the "p_knife_Reference.smd" by selecting the "File->Import->Half-Life SMD..." and you will want to have all the check boxes checked as in Figure 1.4 in the import dialog box.

mt-fig2-4.gif (1220 bytes)

Figure 1.4 Importing the op4 p_knife.mdl

<-Previous Page| |Page 3->


Making a 3rd Person Model for Half-Life - Page 3

Now you should be able to see the skeleton and we will be examining its joints or bones.

Figure 1.6 Selecting the Joint to examine

If you examine all the joints or bones, you should see that this skeleton does not contain the full skeleton of a character model. This should be obvious from that you see only one finger listed on the right hand, while the left hand is missing all together. Our bone for the knife is called "knife" and you should select it as shown in Figure 1.6. You should see the "joint" turn red when it is selected. Also, the rotational axis show up if you zoom in on it. If you were to switch to the "Model" rollout, and select the ""Rotate" tool, you would see the knife rotate and the axis reflect its "X," "Y," and "Z" directions.

One of the most important joint or bone, called "Bip01" is where all joints should connect to, and is the first one that should be created. This is because this bone is where the center of gravity for the mass of the model is, sometimes called "COM" or "Center Of Mass" in modeling. In the 3D Studio Max world this is what this joint is referred to.

We will merge our "p_knife2.msd3" file with what we have already open. Doing this will enable us to get a relative height and position of the knife. This will save a lot of trial and error on our part. As time goes on you will have a library of your own to quickly access and not have to create new skeletons for each and every model. Merge the "p_knife2.msd3" file, by selecting "File->Merge..." from the menu selections, then choose the "p_knife2.msd3" file. If you were to open the copy of the "p_knife2.msd3," and then the op4 "p_knife.mdl" the op4's model skeleton would not show up. Milkshape keeps the old skeleton, assuming that you just want the models mesh and not the skeleton.

Switch to the "Model" rollout, and click on the "Select" in the "Tools" options. Also click on the "Face" in the "Select Options" as shown in Figure 1.7.

Figure 1.7 Selecting all the faces in the p_knife model

<-Previous Page| |Page 4->


Making a 3rd Person Model for Half-Life - Page 4

Before moving on, we will be regrouping this model so that it will be easier to work with and not get confused as to what we need to select later. Switch to the "Groups" rollout and click on the "Regroup" button in the "Group" options as shown in Figure 1.8. It doesn't mater what is highlighted in the list as you have isolated all the faces you wish to regroup.

Figure 1.8 Regrouping all the faces in the p_knife model

Rename this group to "p_knife2.mdl" by double clicking in the text box to the left of the "Rename" button, and typing in the new name. Click the "Rename" button. As you can see you can now quickly reselect the entire knife for manipulation.

It now is up to you to position your knife by moving and rotating it to match the position of the op4 knife.

After you have it in place as Figure 1.9 shows, you will be deleting all the groups of the op4 knife and the materials that were used for it. Click in a blank area of a 2d viewport window to deselect your "p_knife2.mdl" group. Click on a group that is part of the op4 groups in the list area and click the "Delete" button. Repeat these steps until all the groups except the "p_knife2.mdl" group remains. (See Figure 1.9).

Figure 1.9 Deleting the unnecessary Groups

<-Previous Page| |Page 5->


Making a 3rd Person Model for Half-Life - Page 5

Once in awhile you have to check for stray "vertices," and delete these. They usually show up in the 2d viewport as red dots as shown in Figure 1.10. Just simply press the "Delete" key on your "keyboard," to get rid of these.

Figure 1.10 Stray Vertices from previous Delete

Switch to the "Materials" rollout. Select the material for the op4 knife called "knife_blade.bmp" in the list area. Click the "Delete" button as shown in Figure 1.11.

Figure 1.11 Deleting the unnecessary Materials

If you would like to use the op4 skeleton for viewing your knife as attached to a model. you could do as described in the next paragraph. We will be creating our own skeleton though. I am just going to step you through how to use an existing skeleton so that in the future you will not have to create a new skeleton each time.The first step for making the "p_knife2.mdl" will be exactly the same as we just have done in the paragraphs preceding this, even if you are going to create your own biped.

<-Previous Page| |Page 6->


Making a 3rd Person Model for Half-Life - Page 6

Find the "Knife" in the "Joints" list box and click on it.Switch to the "Model" rollout and make sure you have the "Select" button, and the "Vertex" button both on. Switch back to the "Joints" rollout and click on the "Assign" button as shown in Figure 1.12.

Figure 1.12 Assigning the vertices to a Joint

That's really all there is to this as you only need to make one assignment. As stated before, you could actually save this as the reference and compile this for use to see this as a 3rd person model. However we are now going to take a step backwards to the point where we just have moved the knife into position and deleted the op4 knife.

To get rid of a "Biped" or Skeleton entirely in Milkshape, you need to find its "root" bone, or joint. Remember we talked about the most important bone in the model? That's right it is the "Biped01" bone that we described earlier and called it the "COM" bone.

Before we do this though, we need to have something that can help us in setting up a brand new skeleton. Save your "p_knife2.ms3d" file, then save a copy of it by naming it as "temp.ms3d" file. You will need to start paying attention to the "Title" bar of Milkshape from now on as we are going to open up a second Milkshape 3d program and load the "p_knife2.ms3d" file into it as Figure 1.13 show them lined up side by side. See Figure 1.13 for an example of this.

<-Previous Page| |Page 7->


Making a 3rd Person Model for Half-Life - Page 7

Figure 1.13 Viewing 2 open Milkshapes to compare Joint positions

The reason for two Milkshapes is that we will be deleting the Skeleton from the "C:WINDOWS\Desktop\models\p_knife2.msd3" program. In the "Joints" list box, click on the Biped01" joint as shown in Figure 1.12. Press the "Delete" button on the "keyboard" to delete it. The entire skeleton will be deleted in a single operation because of it being the "root" joint. Now you will be looking at the "C:WINDOWS\Desktop\models\temp.ms3d" for its position of the first joint or "root" joint that you will be creating. Pay particular attention to this. This is the "COM" that we talked about and the game engine will pay attention to it for placement in game when we will be completing the entire skeleton for a character model in a later tutorial.

To create your "root" joint, switch to the "Model" rollout and click on the "Joint" button. Then click in the same relative position as seen in the "C:WINDOWS\Desktop\models\temp.ms3d" but in your "C:WINDOWS\Desktop\models\p_knife2.ms3d" program. If necessary count the grid positions in "C:WINDOWS\Desktop\models\temp.ms3d" and try to match it in "C:WINDOWS\Desktop\models\p_knife2.ms3d." (See Figure 1.14).

Figure 1.14 Creating the root or "COM" Joint

We will be renaming this new joint. Switch to the "Joints" rollout and click on the new joint that you just created and double click in the name text box next to the "Rename" button so that the name is highlighted for overtype mode. Type in "Bip01" and pay particular attention to the capitalization of the joint naming convention as this matters in the compilation of models when dealing with "QC" files. If they are not named exactly the same thourghout your models designs, parts will not fit up correctly or may not even appear in game or cause game crashes. One of the most disappointing things that will happen to you if you do not name them correctly, is that what is called "Attachments." These "Attachments" are responsible for positions of things like "Muzzel Flash" points. Now you know why some guns that have been created for a new weapon model, seem to shoot from the stomach or head or some other weird place ingame! As an example of the "Attachment" look at the "v_9mmhandguns.qc" file. It has a line that reads:

// 1 attachments

$attachment 0 "Bip01 R Hand" 10.000000 2.250000 4.250000

You might experience and error during compilation that will say:

************ ERROR ************

unknown attachment link 'Bip01 R Hand'

Now this should become obvious to you as to why this error will occur, either you have named a bone wrong, or you have no assignments to this bone.

You will continue to create the rest of the Skeleton in the same fashion as outline in the preceding paragraphs until you have all the necessary joints created. Remember to switch back and forth to the other Milkshape window

You will assign all the vertices of the knife to the "Knife" joint, by switching to the "Joint" rollout and clicking on the "Knife" selection in the list box, then clicking the "Assign" button.

At this point we are now ready to export our file as a Valve smd. Select "File->Export->Half-Life SMD..." and type in the "File name:" text box: "p_knife2(ref)" then click the "Save" button. Make sure you have the "Reference" Radio button checked like Figure 1.15 shows.

Figure 1.15 Exporting the SMD Reference file

<-Previous Page| |Page 8->


Making a 3rd Person Model for Half-Life - Page 8

You will now need to create a "QC" file for this new model. Select "Tools->Half-Life->Generate QC file..." and type in the "File name:" text box: "p_knife2" then click the "Save" button. You will need to alter this "QC" file like we did in the creation of the world model. So we will edit it by selecting "Tools->Half-Life->Edit QC file..." then click the "p_knife2" and the click on the "Open" button. You will need to change it like Figure 1.16 depicts.

Figure 1.16 Correction of the QC file

The final part of the model creation is to compile the file to make your model. First dot forget to save the corrected "QC" file! Next select "Tools->Half-Life->Compile QC file..." and select "p_knife2.qc" and the click on the "Open" button.

After a bit of scrolling in the "Message Window of Milkshape, the compiling will be done and your now ready to see your newly created model in "HLMViewr" or..., you can view it ingame!

How to view your model in a HL gameplay

You heard me right! After a bit of discussion, you should be able to see your new knife ingame, using tricks that HL modelers use without having to know a bit of coding a new dll to see it ingame.

If you had to recode a new dll just to see what your new weapon will look like ingame, you probably would get discouraged, really fast. Plus the fact is that you may not at this point in time, or ever even want to spend the time to learn how to code. You are probably also tired of looking at the model in HLMViewr. Now you want the thrill of seeing the model and its animations of the model that is using it with your brand new model. It has been know for quite some time, that you can view the player model in what is called 3rd Person View.

The steps necessary to do this is:

  1. Find your "Half-Life\valve\models" directory, (this could be different from some, mine is: "C:\SIERRA\Half-Life\valve\models").
  2. Place your "p_knife2.mdl" in this directory.
  3. Rename you model to "p_crowbar.mdl."
  4. Make a short cut for Half-Life to play in 3rd person mode by creating a new shortcut on your desktop by first right clicking on a blank area of your desktop
  5. Click "New->New->Shortcut."
  6. Type in the "Command Line:" text box: "C:\SIERRA\Half-Life\hl.exe -dev -toconsole +map boot_camp +thirdperson +cam_idealyaw 220 +cam_idealdist 90"
  7. Click "OK"
  8. Click on this new shortcut.
  9. Pull down the console by using the "~" key on your keyboard.
  10. Type in the console:"impulse 101"
  11. Go back to game play by using the "~" key on your keyboard.
  12. Select the crowbar in slot 1 by using the "1" key.
  13. Enjoy looking at your new knife model!

See how easy it is to see your weapon or other models ingame without the use of code?

Note: You may choose to view the model a bit closer or further than I prefer to, you can change this by changing the command line where it says: "+cam_idealdist 90" to a greater or lesser number. If you wish to view the player model at a different angle than I do, then you can do this by changing the command line where it says "+cam_idealyaw 220" to to a greater or lesser number.

Next tutorial we will move on to making a working view model or "v_knife2.mdl" for your viewing pleasure.

<-Previous Page

All material in this tutorial is copyrighted © 2000 by Rick J. Kelley and is not to be copied without the express permission of Rick J. Kelley. Half-Life® is Registered Trademark by Valve. Opposing Force® is a Registered Trademark of GearBox Software. Use of the pseudo name Rat is a referral to the author Rick J. Kelley.