|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| TUTORIAL: Creating a Basic HL2 Character Model Using XSI
|
|
|
http://veazie.org/Tutorials/XSICustomCharacter/HL2_Custom_Character.html
Here’s the text in case the site goes down:
[B]Creating a Basic HL2 Character Model Using XSI[/B]
[B] [/B]
[B]By using a combination of the HL2 SDK model and the XSI v4.2 Man model, you can create your own basic character model ready for customization.[/B]
[B]The purpose of this tutorial is to provide the basic steps and concepts for creating and compiling an HL2 character model which you can customize and animate.[/B]
[B]This tutorial does not teach you how to create your own character mesh (it uses a default model supplied with XSI v4.2).[/B]
[B]This tutorial does not deal with creating eyes or mouth animations used in HL2 models.[/B]
For this tutorial you’ll need:-the Half-Life 2 SDK installed.-Softimage XSI Mod Tool v4.2 installed. You should have a working familiarity with most of the basic tools.-the ValveSource addon installed with XSI so you can export model SMD files, and export and import weightmaps.-an image editor such as Adobe Photoshop to modify images and export Targa (tga) format files Outline of this tutorial:-Setup files and directories for the character model-Prepare the body texture for the model-In XSI, open the HL2 male reference scene-Import the XSI supplied [I]Man[/I] model into the scene; scale it, position it and freeze it-Export the HL2 reference weight map and delete the HL2 model-Select the [I]Man[/I] model and import the weight map-Create a cluster for the head texture, get the facemap texture and adjust the UV coordinates for the head-Export a model reference SMD file-Edit the qc file for the model, compile the model and view it in the SDK model viewer. [B]Setup the files and directories for the character model[/B]
If you haven’t done so, setup folders for the model and textures, preserve the original SDK HL2 model files and compile the SDK sample model as described in the tutorial [B]HL2 Character Modeling - A First Step.[/B] [B]Prepare the Body Texture for the Model[/B]
Locate the texture file [B]Char_UV_Texture.gif[/B] in your Softimage installation in the folder [B]XSI_4.2_ModTool\Data\XSI_Samples\Pictures[/B]. The entire [I]Man[/I] model is UV-mapped to this image.Open the gif file in your image editor and size it to 1024x1024 pixels. Customize the costume as desired and save it in Targa format (tga extension) with the name [B]Char_UV_Texture.tga[/B]to the folder [B]sourcesdk_content\hl2\materialsrc\SDK\Models\Humans\Male[/B].Compile the [B]Char_UV_Texture.tga[/B] file by dragging-and-dropping it onto your desktop vtex.exe shortcut. Above is shown a portion of the [B]Char_UV_Texture.tga[/B] that I used. For demonstration purposes, I overlayed a portion of the [B]citizen_sheet.tga[/B] texture that can be found in the folder [B]sourcesdk_content\hl2\materialsrc\models\humans\male[/B] to use with the new model. The texture file is well labeled, showing which parts of the texture are mapped to which parts of the [I]Man[/I] model, and can be easily customized to create a custom costume for your character.You can ignore the portion of the texture (the red area at the bottom-right) intended to be mapped to the head of the XSI [I]Man[/I] model. Later in the tutorial, there are steps to demonstrate how a separate texture for the head can be added to the model. [B]Setting up the Reference Scene[/B]
Open XSI. Using File->Open, navigate to the folder [B]sourcesdk_content\hl2\modelsrc\humans_sdk\XSI_scn_files[/B] and open [B]SDK_Male_reference.scn[/B].Select the model and export the weightmap (ValveSource->WeightMap Export..). I created a WeightMaps folder under XSI_Samples, named the file [I]sdk_male_reference[/I] and saved the file in that folder. [B]Import a Character Model Into the Scene[/B]
In the main menu, click File->Import->Model.. and select [B]Man.emdl[/B] from the XSI_Samples\Models folder. [B]Scale The [I]Man[/I] Model[/B]
The [I]Man[/I] model is quite a bit smaller than the [I]Male_06 [/I]model. You’ll have to zoom out in one of the views to find it nestled between the feet of the [I]Male_06[/I] model.Select the [I]Man[/I] model (left-button drag over a portion of it). In the next few steps, you’ll attempt to match the [I]Man[/I] polymesh as closely in position as possible to the [I]Male_06[/I] polymesh. By doing this, you can use the weightmap you exported to envelope the new mesh to the ValveBiped deformers (bones).Click on the [I]Scale[/I] button in the Transform panel. Enter [I]3.5[/I] in each of the 3 axes fields. Click the [I]Scale[/I] button again to deselect scaling. [B]Position the Arms, Legs and Feet of the [I]Man[/I] model[/B]
Maximize the Front view and switch to Wireframe display (if needed). Zoom out and adjust the view so you can see the right arms of both models.Select the [I]Vertex Select Tool[/I] and select all the vertices of the [I]Man[/I] model right arm by dragging a box from the shoulder area of the [I]Man[/I] model out past the ends of the fingers. You should end up with the vertices in the arm selected as shown below.Click the [I]Rotate[/I] button in the Transform panel, and click the [I]Global[/I] and [I]Sym[/I] buttons. Click the [I]COG [/I]to deselect it. [I]All[/I] your model manipulations should be in Global coordinates for this tutorial. The [I]Sym[/I] button will apply the same manipulations to the left arm as well. Nice, huh?Hold down the [I]alt[/I] key and click near the center of the right shoulder (at the point where the red and green indicators cross as shown below) to change the center of rotation to the shoulder area. With the scaling you applied, the [I]Man[/I] and [I]Male_06[/I] shoulders should be pretty closely overlayed. Release the [I]alt[/I] key and position the mouse point over the blue circle to get the [I]z-axis rotation[/I] cursor. Click-drag to rotate the arm down to a position close to the [I]Male_06[/I] arm angle. Deselect [I]rotation[/I] and deselect all the vertices ([I]ctrl-shift-A[/I]).Select all the vertices in the right leg (but none in the hip area). Select [I]rotation, Global[/I] and [I]Sym[/I]. Position the center of rotation near the top-center of the right leg and rotate the leg so the [I]Man[/I] leg closely overlays the [I]Male_06[/I] leg. Deselect [I]rotation[/I] and deselect all vertices.Select the vertices in the right foot of the [I]Man[/I] model. Make sure you select [I]all[/I] the vertices as shown below.Select [I]rotate, Global[/I] and [I]Sym.[/I]Press [I]alt[/I] and click in the right ankle area to set the center of rotation for the foot. Release [I]alt[/I], position the mouse over the blue circle and rotate the foot into a more natural position. Deselect [I]rotate[/I] and deselect all vertices.Select the [I]Object Select[/I] tool (the button with the white arrow in the button bar above the views), select [I]translate[/I] in the Transform panel, click on [I]Global[/I] and turn [B]off[/B] [I]Sym[/I]. Click on the [I]y[/I] beside the [I]translate[/I] button to select [I]only [/I]the y axis for movement.Click-drag the [I]Man[/I] mesh up just a little so the bottom of the feet are even with the bottom of the [I]Male_06[/I] mesh. Deselect [I]translate.[/I]You’ve finished setting up the reference position for the [I]Man[/I] model, so, in the main menu, click [I]Transform->Freeze All Transforms[/I]. [B][I]This is a VERY important step![/I][/B] If you don’t freeze the transforms (the rotations and translations) for the mesh, the model will not compile correctly and it’ll look very messy or it may not compile at all.
|
|
|
|
[B]Delete the [I]Male_06[/I] Model[/B]
We don’t need the [I]Male_06[/I] model any more, so open up Explorer (press 8 or click on the Explorer button in the button bar), click the [I]Male_06[/I] node and press [I]Delete[/I]. [B]Import the WeightMap to the [I]Man[/I] model[/B]
Expand the [I]Man[/I] node in Explorer and middle-click on the [I]Man[/I] mesh name (it has the white mesh-like icon beside it) to select the mesh.In the main menu, click ValveSource->WeightMap Import.. and select the weightmap file you exported earlier. Click Okay.It may take a minute or so for XSI to apply the weightmap to the [I]Man[/I] mesh. Be patient. When I do it, a portion of the screen turns white. If that happens to you, that’s okay. XSI is just busy applying the weights for each bone to the surrounding mesh.[I]WeightMaps are factors applied to each vertex in the model. They determine how much a particular vertex moves when the bone or bones that it is weighted to move.[/I] You should now have a WeightImportProperty in the scene and the [I]Man[/I] mesh is highlighted with colors indicating which portions of the mesh are weighted to which deformers. [B]Finishing up and Saving Your Work[/B]
Expand the [I]Man[/I] polygon mesh node (the node with the white mesh icon), expand the [I]Polygon Mesh[/I] node (the node with the icon of a [B]P[/B] in a diamond) and check to see if there are any “unfrozen” operators (e.g., labeled [I]MoveComponent[6][/I]. If so, click on the operator to expand it, right-click on one of the entries and click [I]Freeze[/I] to clear the operators from the stack.As shown below, click on [I]MoveComponent [6][/I] and the node will expand to show some [I]Move[/I] operators still on the stack.Right-click on one of the [I]MoveComponent[/I] entries (e.g., [I]MoveComponent[5][/I] as shown below) and click [I]Freeze[/I].The operators will be removed from the stack and the [I]MoveComponent[/I] node will disappear from the Explorer tree. Close Explorer and save your scene with a name of [I]sdk_custom_male[/I] or something equally recognizable. [B]Checking the model[/B]
To make sure everything you’ve done to this point is correct, follow the steps in the section [B]Exporting the SMD and Compiling the Model[/B] below. Make sure your model compiles correctly and (as ugly as it is) appears okay in the ModelViewer. As you can see, the default texture for the [I]Man[/I] model that XSI supplies includes a mapping for the head which is just the color red. Not very exciting. You’ll now learn how to setup a separate texture just for the head of the model. [B]Create a Polygon Cluster for the Head[/B]
First, you must create a [I]cluster[/I] in XSI for the portion of the mesh to which you can apply a separate texture.With the [I]Man[/I] model selected, press [B]y[/B] to activate the [I]Polygon Select[/I] tool. With this tool, you can drag a box around portions of the model to select all the polygons, [I]including the backfacing polygons[/I], that lie entirely within the box.Drag a box around the entire head and part of the neck to select all the polygons in the head.You may have to use the [I]RaycastPolygon Select Tool[/I] (press [B]u[/B] or click the button to the right of the [I]Object Select[/I] button in the button bar with the icon of a single polygon). Click on any polygons as needed to make the selection correct as shown below.When all the polygons in the head have been selected, in the main menu, click [I]Edit->Create Cluster[/I] to create a cluster of polygons selected from the [I]Man[/I] polygon mesh. This doesn’t change the mesh itself. It creates a new object (a cluster) referencing a set of polygons from the mesh to which materials other than the default scene material can be assigned.Open Explorer and expand the polymesh node and the cluster node.Double-click on the Cluster named [I]Polygon[/I] and give it a meaningful name by typing in [I]tex_head[/I] in the name field of the property box. Close the property box and the Explorer panel. [B]Get a New Texture for the Head[/B]
With the cluster selected, in the main menu, cllick [I]Render->Get Texture->Image[/I]. Click [I]Yes[/I] to make a local copy of the material.In the dialog box, click [I]New[/I] and [I]New From File… [/I]to pick a texture for the cluster. In the file-selection box that pops up, navigate to the [B]hl2\materialsrc\SDK\Models\Humans\Male[/B] folder and select [B]sandro_facemap.tga[/B], the texture used for the Male_06 model. You’ll use that same texture to learn how to map a texture to a cluster.[I]You don’t have to select a texture projection for the new image because the entire [/I]Man[I] model is already UV-mapped. However, you’ll have to change the mapping of head vertices because things look pretty bad at this point.[/I] The [B]sandro_facemap[/B]texture you selected is a wraparound type texture. The entire head from neck to top of head and from front to back appears in one texture.Close the dialog boxes.
|
|
|
|
[B]Change the Texture Mapping of the Head Cluster, Point by Point[/B]
Select the tex_head cluster. If necessary, open Explorer and middle-click on the tex_head cluster to select it.Open the Texture Editor (I’ll be calling it “texed” - pronounced [I]tex-edd[/I]) by pressing [I]alt-7[/I].What you see are the existing UV coordinates of the vertices in the cluster mapped onto the new texture. It looks like only the right side of the head cluster has been mapped. Actually, the UV coordinates for the left side have been mirrored and overlay the right side coordinates. That is, any part of the image mapped to one side of the head will also be mapped to the other side in reverse. When the mapping is correct for the right eye, the eye portion of the image will texture the left eye of the model as well. This should become clearer as you adjust the coordinates.
[I]With the mouse over the texed[/I] and all the points selected, press [B]v[/B] or click on the [I]t[/I] button in the texed to select the [I]translate[/I] tool.Drag the coordinates to the left and position the coordinates of the ear somewhere close to the ear on the left of the image.As a first approximation, it’s not too bad. Obviously the ears needs work and the texture around the eyes needs badly to be repositioned.I’m not going to lead you through a complete remapping of the head. I’ll demonstrate how to move a couple of the points and leave the rest to you to practice on.[I]Tips for UV Mapping:[/I] The idea is to select a point in the texed, note where it appears on the model and move the point to a similar position on the image. For example, move the point at the corner of the eye on the model to the corner of the eye in the image. Another [I]very important[/I] tip: [B]always[/B] deselect all points in the texed (ctrl-shift-A) before selecting another point. If you forget to do this, you’ll drag several points around at once and really get things messed up. Another tip: always select a point by dragging a box around it. Don’t click on a point to select it. Each of the “points” in the texed is really several points overlayed, one on top of the other. By dragging over the point, you’ll select all the overlayed points and move them in unison. If you click on a point, you may not select all the overlayed points and, when you move the selection, you may leave a point or two behind. Don’t move [I]any[/I] points too far. Iterate up and down and back and forth, moving each point just a little. Don’t let any lines cross. That will cause confusion. When you move a point in the texed, watch the effect on the texture on the model to help you decide where the point on the image should go. The texture on the model is updated realtime so you can see the immediate effect of moving a point in the texed.In the texed, zoom in on the area below the mouth in the image. Press [B]z[/B] to select the pan tool, middle-click to zoom in, left-click to zoom out.Press alt-shift-A to deselect all the points.Drag-select the point in the middle at the bottom right.Note that this is the point on the model (zoom and pan in a Camera or User view) at the middle of the throat just under the chin. Press [B]v[/B] ([I]translate)[/I] and drag the point toward the middle of the image where it you think “just under the chin” is. Press [B]v[/B] again to [I]deselect[/I] the translate tool and deselect all points in the texed (ctrl-shift-A when the mouse pointer in the texed view). On the model, it’s on the underside of the chin.In the texed, select the point just above the one you just moved. In the texed, move that point to a position directly above the first point you moved.Work your way up toward the mouth, moving points on the image to approximate the location on the model.You may find points, which when selected, show colored edges around an “opening” in the map coverage. This indicates that two or more points which [I]should[/I] be overlayed, are [I]not[/I] overlayed. Notice, in the case shown below, that the two selected points in the texed map are the [I]same[/I] selected vertex on the model. You may have to select and deselect points around the perimeter of the “opening” in the map to find which points need to be overlayed.Move one of the points (it doesn’t matter which one) directly over the other point.

Drag-select [I]both [/I]points and click on the [I]Heal[/I] button to overlay the points exactly. There are two more points in this example that need to be healed. 

Move one of the points over the other, drag-select them [I]both[/I] and click the [I]Heal[/I] button.There are a couple of points that, when you select them in the texed, you won’t see them selected on the model. There’s a point in the middle of the nostril that’s up inside the model and a couple similar ones around the ear and the back of the ear. Move the nostril point to the dark area in the middle of the nostril in the image, etc.Also, the model has no eyeballs. Remap the points around the eyelids as shown below so that the eye portion of the image doesn’t appear on the model.


Shown above is my final mapping, details of the mapping around the ear and details of the mapping around the eye.When you’re satisfied with your progress (or you get too tired of it), save your scene file and see what the compiled model looks like.[B][I]Note[/I][/B]: You selected the sandro_facemap for the head texture. The compiled texture (the vmt and vtf files) should already be in the [B]half-life 2\hl2\materials\SDK\Models\Humans\Male[/B]folder. When (or if) you retexture your custom model, remember to compile the texture and place it in the correct folder in the game directory.
|
|
|
|
[B]Exporting the SMD File to be Used for Compiling[/B]
Click [I]ValveSource->Export SMD...[/I]Untick the [I]Remove All Unused Bones[/I] option. I’m not sure if it has any effect but it doesn’t seem to hurt and a couple of articles on the web recommend it. [[I]shrug[/I]]Select [I]Model[/I] as the type and click the “...” button beside the filename field. Save your file with a name like [I]sdk_custom_male[/I] in the [B]sourcesdk_content\hl2\modelsrc\humans_sdk\Male_sdk[/B] folder.Close XSI. Having XSI open [I]may[/I] interfere with the operation of ModelViewer. I think it may be because both programs use an OpenGL context for rendering and sometimes there are problems having several contexts open simultaneously. [B]Preparing the QC File for The Model[/B]
In the folder [B]sourcesdk_content\hl2\modelsrc\humans_sdk\Male_sdk [/B]folder, open the file [I]Male_06_sdk.qc[/I] in Notepad (or other ASCII editor).For the editing, refer to the sample file shown below. If you named the SMD file as suggested and saved it to the Male_SDK folder, the sample file should work.
Delete the lines beginning [I]eyeball, eyelid, mouth [/I]and [I]flexfile[/I] as this model doesn’t use those (perhaps a later tutorial). Delete the LOD sections as [I]Level of Detail[/I] files have not been created for this model. Add two lines:
$surfaceprop “flesh”
$mostlyopaque
Change the $alwayscollapse line to “Man.Man” from “Male_06.”
Change the model name and smd filename to the name you saved it under.
You should end up with a file that looks similar to the following:
/*
============================================================================== sdk_custom_male
==============================================================================
*/
$modelname sdk\Humans\sdk_custom_male.mdl
$cdmaterials sdk\models\Humans\Male
//start eye/face data
$eyeposition 0 0 70
// head controllers
$attachment “eyes” “ValveBiped.Bip01_Head1” 0.043 -4.2197 67.5554 absolute
$attachment “mouth” “ValveBiped.Bip01_Head1” 1.00 -6.30 0.00 rotate 0 -80 -90
$model sdk_custom_male “sdk_custom_male.smd"{
$include “../bodyrules_xsi.qci”
}
//end eye/face data
$surfaceprop “flesh”
$mostlyopaque
$include “../standardhierarchy.qci”
$alwayscollapse “Man.Man”
$alwayscollapse “XSISceneRoot”
$proceduralbones “../male.vrd”
$pushd “../male_animations_sdk”
$include “../male_animations_sdk/male_shared_XSI_sdk.qci”
$include “../male_animations_sdk/body_poses_lean.qci”
$include “../male_animations_sdk/WeaponAnims_shared_sdk.qci”
$popd
$include “hitbox.qci”
$include “ragdoll.qci”
Save the file as [I]sdk_custom_male.qc [/I]in the [B]Male_sdk[/B]folder.[I]Storing multiple model files in the same folder is not a problem. I do it on purpose in this tutorial to take advantage of the ragdoll and animation files already there.[/I] [B]Compiling the Model[/B]
Drag and drop the sdk_custom_male.qc file you just saved onto your [I]studiomdl[/I] desktop shortcut. It should compile and produce a bunch of files in the [B]half-life 2\hl2\models\sdk\Humans[/B] folder with extensions of vtx (3 of them), mdl, phy and vvd.[I]If not[/I], double-check that your qc file looks like the sample above. If that’s okay, you can open a command prompt window, change to the [B]sourcesdk\bin[/B] folder and run studiomdl with the command line:[B]studiomdl “c:\program files\valve\steam\steamapps\[your logon]\sourcesdk_content\hl2\modelsrc\humans_sdk\male_sdk\sdk_custom_male.qc"[/B][I]Include the quotation marks[/I]. Look at the studiomdl output for errors. Correct them and try again.One time in the past, I somehow missed a right toe. I corrected it by starting from scratch (importing the scene file, etc.) and paid close attention to selecting [I]all[/I] the vertices in the arm, leg and foot before I rotated them.When your model compiles successfully, open ModelViewer, Load Model.. and select your model from the sdk\Males folder to view it. It should appear with your custom body texture and head texture (if you applied one). He’s kind of blocky (the [I]Man[/I] model from XSI is very low poly) and your model won’t have eyes yet, just empty holes. You’ll add eyes in the next tutorial.You can now use your custom model in HL2 maps by inserting a generic_actor entity and selecting your model as the World Model property of the generic_actor. [B]Continuing on..[/B]
You can change the texture of the body of the model (or portions of it - shirt separate from the pants, etc.) by selecting polygons from the model in the appropriate arrangement and creating a cluster. With the cluster selected, click [I]Render->Get Texture..[/I], etc., to apply another texture to that portion of your model.You can translate or scale portions of the model to change proportions. The [I]Man[/I] model has pretty anemic arms and legs. Rescale portions of the model or manipulate vertices to build some better looking muscles.If you want to smooth the surface of the model, you can split polygons to reduce angulation. Be sure to envelope the new points to the right deformer and map the new points to the correct place in the correct texture.You can add animations to the model as described in other tutorials. For the scene used in this tutorial, you’ll have to click [I]View->Unhide All Objects[/I] to see and use the animation controls. Select and hide the eyeballs that are still part of the scene. They can be used later.
|
|
|
|
[B]Note:[/B] If the model does not compile (if you see the Error model in the HLMV) , the problem may be the inclusion of the file Male_Animations_sdk/WeaponsAnims_Shared_sdk.qci.
That file contains a $weightlist pelvisonly line identical to a line in the included file male_shared_XSI_sdk.qci.
* In the Male_Animations_sdk folder, make a copy of the WeaponsAnims_Shared_sdk.qci file.
* Rename the copy to WeaponsAnims_Shared_sdk_X.qci (or other unique name).
* Edit the WeaponsAnims_Shared_sdk_X.qci file and comment out the $weightlist line
“//$weightlist pelvisonly ...”
* Open for editing the file male_06_sdk.qc.
* Change the line $include “../male_animations_sdk/WeaponAnims_shared_sdk.qci” to
$include “../male_animations_sdk/WeaponAnims_shared_sdk_X.qci” //(or as otherwise renamed above)
* Save the male_06_sdk.qc file.
* Recompile male_06_sdk.qc to determine if the error was corrected.
|
|
|
|