User:DougWood

From Valve Developer Community
Revision as of 13:55, 12 July 2005 by DougWood (talk | contribs)
Jump to navigation Jump to search

Stub

This article or section is a stub. You can help by expanding it.

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. You can do this in two different ways as described below (A. and B.). 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.

(A.) Set a 54 degree F.O.V. perspective camera at origin 0,0,0 facing down the Positive Z axis.

(B.) Set a 54 degree F.O.V. perspective camera at origin, using the coordinates shown below, facing along the Positive Z axis. Use the QC command $Origin 0 0 68 to compensate. This way is useful when you need to merge in character rigs to animate with, otherwise it is recommended to use example (A.)


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

Rig the left hand depending on what animations are needed. For the shotgun, I want the left hand to be fully articulate for the reload animation. This is a very old example (notice the old rig) or I would have made the last two fingers of the hand use the same bone controls.

Left hand rig.jpg

Once rigged and animated, delete any faces that are not seen in your camera viewport. Re-export your reference file smd. In the below example the faces from the elbows to the shoulders have been deleted. Other areas to look at would be the right-bottom forearm, the back of the right hand, and the right side and underneath of the shotgun.

Reduced.jpg