User:DougWood

From Valve Developer Community
Revision as of 19:45, 7 July 2005 by DougWood (talk | contribs)
Jump to navigation Jump to search

Creating a view model for Source using XSI

Camera Setup

Lets start by positioning the camera in XSI to give us a similar view as what we will be seeing in the game. Set a 54 degree F.O.V. perspective camera at origin, using the coordinates shown below, facing along the negative Y axis. The Source engine supports any F.O.V., but if you use 54 (which is close to the human eye) you will be able to model a weapon to correct scale without having it look distorted in the engine. We actually use a dual F.O.V. system with Source. In Half-Life 2 the world is rendered at 75 F.O.V. while our weapons are rendered at 54.

Camera settings.jpg

Positioning

If its not in the scene already, merge/import your weapon mesh. Position your weapon to where it looks best in the camera view. To do this move the weapon mesh and not the camera. I recommend doing this before you finish your model because its good to see where to best spend your polygons. As you can see in the below picture (area marked as A.) the front of the shotgun mesh has some detail near the barrel that is not seen in the camera view. Those polygons would perhaps be best used up near the handle or simply deleted.

Shotgun singlemesh.jpg

Merging texture coordinates

In this example, the shotgun and arms have been modeled and textured separately (You will first need to step into the world of imagination and pretend that my example is textured). View model weapons need to consist of a single mesh, so we need to merge both the shotgun and arm meshes together while keeping the texture coordinates in tact. Do to this, merge the arm mesh into the scene File > Merge, next, under the Model panel select Poly. Mesh > Merge. A dialog box will then pop up (shown below). I usually put the tolerance to 0. The tolerance will weld verts that are close to each other. The higher the tolerance number, the more verts will be welded together. This is handy for when you are stitching two models together, such as modeling one side of an object, duplicating and mirroring it, and then welding it back to the original. For this example however, I don't want the hand verts to be welded to any of the weapon verts. Click the All button to merge all materials and texture coordinates into a new single mesh.

Merge armmesh.jpg

XSI creates an additional mesh after a merge (named Polymesh). Freeze the new mesh before deleting the old meshes.

Singlemesh.jpg

Rigging

Now attach the mesh to your rig. Although I used a rig with fully articulate fingers to pose my hand gripping the gun (figure A.), for the final version I will use a single bone to control the rotation and translation of the hand and shotgun (figure B.). High bone counts can be very costly and with view models you can't take advantage of bone L.O.D.s like you can with characters because its always close to your view-point. If you find that you need to see the finger move (pulling the trigger for example) then add one bone to your scene which is a child of your hand-bone. My right hand (gun holding hand) usually consists of three bones. One for the elbow, hand, and gun. This example will only have two (elbow and hand) because I already know that my hand will never let go of my shotgun handle. Of course, you will have extra bones parented to the gun if the gun has moving parts such as clips, bolts, etc.

Plan ahead before you create a rig for your weapon.  If you find out that none of your animations require the right hand to ever let go
of the handle, don't put bones in all of the fingers of the right hand.

Simple rig.jpg