Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 30 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
30
Dung lượng
1,33 MB
Nội dung
5. Adjust the mesh rotations to match the pose in Figure 14.78. You want the charac-
ter slightly bent at the knees, with his left arm slightly bent beside him and the
right arm bent up at 90 degrees. Starting with the base node and moving on to the
pelvis, hips, and shoulders (in that order), adjust the joints of the skeleton.
Remember to rotate hip, knee, elbow, and shoulder joints to move the joints at the
extremities. Pay particular attention to the placement of the pelvis, lower spine,
and hip nodes. The pelvis should be well below the level of the hip nodes, and they
should be just a tad higher than the lower spine.
note
The node names and bones you see in Figure 14.77
are not in any way standard.They don't have to be.
However, there are standard skeletons for other
games that you can use. Torque also has a stan-
dard biped skeleton that is the same as the one
used for CounterStrike. But we can't really take
advantage of it, because it is only useful with
sequence files, which we do not yet have the abil-
ity to use given the current DTS Exporter that is
available. So we may as well use our own skeleton.
Rigging: Attaching the Skeleton
Now we have the skeleton built, the nodes have been named, and the bones are aligned
into a pose we like. Next we are going to attach our model to the skeleton. That way, when
the skeleton is manipulated, the mesh of the model will follow suit. It is during this step
that you might be inclined to thank me for insisting that you retain mesh groups for the
different model components like arms and feet and so on!
Rigging the Head
We'll begin with the head, just to get a feel for the rigging operation.
1. In the Joints tab in the toolbox, choose the joint (or node) named "head". Make
sure it appears highlighted in red in the wire-frame views.
2. Switch to the Groups tab and choose the head mesh. It should appear highlighted
in red, as you already know.
3. Switch back to the Joints tab and click Assign. Now the head mesh is assigned to
the head node. To double-check, just click anywhere in a blank space in a wire-
frame view to make sure that no objects are selected, choose the head joint to
ensure it is selected, and then click the SelAssigned (Select Assigned) button. The
head mesh should appear highlighted. If not, go back and repeat these three steps.
Character Animation 447
Figure 14.78 The pose-adjusted skeleton.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Aw shucks, there it is—the head is now rigged! Of course, that's not the end of the story.
There is still the rest of the model.
There's also the issue of what to do when a bone is rigged wrong. Sometimes it's a trivial
fix, and other times you might have to rerig the whole model. Or you might have to rig a
model by attaching a node to just a few vertices rather than a whole mesh or submesh.
That can get very, um, fiddly—I guess that would be a reasonable description.
Part of the simplicity in rigging this model comes from the technique we used; building
from primitives allows us to easily define meshes and submeshes. We'll use a "one node
per mesh" rule of thumb. It can get trickier using other techniques, but sometimes those
other techniques might be more appropriate for the model you want to build. It's a judg-
ment call, as everything important tends to be. There is one exception—as there always
is—to the "one node per mesh" rule that we'll get out of the way next.
Rigging the Torso
Okay, so the head was a cakewalk. It wasn't even necessary to show any pictures for you to
be able to follow along. How about the torso then—duck soup again, no?
Well, yes…I mean no, actually. No duck soup for this one!
The head mesh is attached to the head node, and that is fine. Tilting or rotating the head
node will indeed move the head in the manner we want. There really isn't a whole lot to
choose from. The neck is more a part of the spine than the head. The camera and mount1
nodes aren't even related to the skeleton. They are special nodes that will have a different
role to play in Torque, which we'll cover later. So that leaves the head node to control the
head mesh.
The torso, though, has at least five nodes that it might be attached to. But which should it
be? Let's eliminate the neck node for now. That leaves the spine nodes or the pelvis node.
Actually we can use more than one node for a mesh giving different parts of the mesh to
different nodes. When we built the torso mesh, we actually combined two primitives
together, remember that? One was the chest cylinder, and the other was the abdomen
cylinder. We could have left them as two separate submeshes, but I wanted to show you
how to join them together. We can still use them as if they were two separate meshes, by
assigning their respective vertices to different nodes.
If you look at the nodes, you'll see that the pelvis node is pretty well the obvious candi-
date to control the abdomen part of the mesh. The upper spine node, although probably
not as obvious, is likely the best candidate for the other node, because it exists in circum-
stances similar to the pelvis—there are limbs attached. So we'll go with these two and see
how that works out.
Chapter 14
■
Making a Character Model448
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
What this will mean in terms of animation is that we can have the vertices that are
attached to one node move in one way, while the vertices attached to the other node move
differently. Or not. It all depends on how you rig it.
None of this is strictly necessary. The animations we are going to create don't actually require
the torso mesh be given more than one node, but it's a good thing to learn, so we'll do it.
1. To get started with rigging the torso, let's tidy up the ol' drawing board a bit by
hiding all the meshes except the torso mesh. If you've forgotten how, just go to the
Groups tab of the toolbox, choose each mesh, and click Hide. Unfortunately, we
can't selectively hide parts of the skeleton. It's either all or nothing when it comes
to the bones.
2. Choose the pelvis node in the Joints tab.
3. Switch to the Model tab and set the Select tool to Vertex mode. Then select the ver-
tices that are the abdomen. You can use either the Front view or the Side view. Fig-
ure 14.79 shows the vertices to select.
4. Back in the Joints tab, click Assign. Now the vertices are attached to the pelvis
node.
5. Now choose the upper spine node, and then select the vertices for it, using Figure
14.80 as a guide.
6. Click Assign in the Joints tab, and that should do it.
7. Double-check to make sure you didn't overlook any of the vertices by choosing
each node in turn, clicking the SelAssigned button, and looking to see which
vertices for that node might
have been missed. If you did
miss any, you can simply select
the node, select the vertices, and
then click Assign to add them to
the nodes list.
There, that's the torso. It might not have
seemed so difficult a task to you, but to
me it was a nightmare! Well, maybe not
that bad, but it shows you the kinds of
decisions you will have to make when
rigging your models. What goes where
and how best will it work?
Now that we have a few nodes rigged,
let's take a look and see what they
actually do.
Character Animation 449
Figure 14.79 The abdomen vertices.
Figure 14.80 The chest vertices.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
1. If you don't have a button at the lower right called "Anim," then choose Window,
Show Keyframer, and make sure there is a check mark there.
2. Click Anim to activate the Keyframer.
3. Using the Select tool in the Joint mode, select the pelvis joint (or you can use the
Joints tab to do the selection).
4. Use the Rotate tool in freeform mode in the Right Side view. You will recall that
freeform rotation is a simple matter of selecting the Rotate tool, then clicking in
the wire-frame view, and dragging the cursor left and right.
Now what you should be seeing is the entire torso, plus the head, rotate around the pelvis.
You should also see some strange things as well. The arm, leg, foot, and hand meshes don't
move. That's because they aren't rigged yet.
But notice that the leg bones are rotating when you rotate the pelvis. Aha! I don't know
about you, but when I bend over, my legs don't move back. Well, not unless I'm floating
in water, of course. So the pelvis node, while it seems to be an obvious candidate for bend-
ing your character at the waist, looks to not be the right one.
So go back, right now, and change it. It's simply the same procedure I showed you for the
pelvis, except you do it for the lower spine node. Make sure to click the Anim button to
take it out of the Keyframer first, or you won't be able to make the changes. I'll wait.
Musical Interlude.
There you are. Now that that's done, go back into the Keyframer as I showed you before,
and check the rotation of the lower spine node.
Another Musical Interlude.
Good! So everything should be working as expected now. The torso and the head meshes
bend over in unison, and all the bones attached above the lower spine bend in unison, as
shown in Figure 14.81. As you've probably
deduced, it is now a reasonably minor
matter to rig the rest of the nodes. Use
Table 14.2 to guide you in your rigging.
You just need to match a mesh to a node,
attach it, and move on. I'm enjoying the
music here, so you go ahead and do the
rest of the rigging, and I'll sit back and
relax.…
Yet Another Musical Interlude.
Great! With that done, let's move on.
Chapter 14
■
Making a Character Model450
Figure 14.81 Bending at the lower spine.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Idle Animation
The idle animation is the one used by Torque when the character is just standing there,
doing nothing in particular. In some games you will see some pretty complex idle anima-
tion where the character scratches himself in rather inconvenient locations, looks around,
scuffs his feet, and so on. We're just going to do a basic breathing sequence so that you'll
know that the character is alive. The name for the idle animation in Torque is root.
Even with a basic animation, the watchword is subtlety. Don't overdo it.
1. Make sure the Keyframer is enabled by clicking the Anim button in the lower-right
corner.
2. Set the number of frames in the Keyframer to 30. Do this in the right-hand edit
box in the lower-right corner of the Keyframer (see Figure 14.82).
3. Move the slider to the 1st frame.
Character Animation 451
Table 14.2 Hero Rigging
Node Mesh to Be Rigged
ZHead Head
UpperSpine Torso—chest-area vertices
LowerSpine Torso—abdomen-area vertices
LShoulder LArm
RShoulder RArm
LElbow LHand
RElbow RHand
LHip LThigh
RHip RThigh
LKnee LFoot
RKnee RFoot
Figure 14.82 The Keyframer control panel.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
4. Choose Animate, Set Keyframe. This indicates that this particular frame is a keyframe.
5. Move the slider to the 15th frame.
6. Take note of the angle of the elbows and hands.
7. Select the midspine node and rotate it 5 degrees around the X-axis.
8. Rotate each of the elbows in the opposite direction by about 5 degrees to place
them back where they were before.
9. Choose Animate, Set Keyframe to set the keyframe attribute for this frame.
10. Move the slider back to the 2nd frame.
11. Choose Animate, Copy Keyframes.
12. Move the slider to the 30th frame.
13. Choose Animate, Paste Keyframes.
14. Save your work!
Figure 14.83 shows the subtle pose difference between the 1st and the 15th frames. Now
you can test your animation by clicking the Play button on the Keyframer controls. The
Play button is the one that looks like a single arrow pointing to the right.
As long as the Play button is down, the animation will loop. If you find it runs too fast,
you can change the FPS number in the Preferences dialog box to a lower value to slow the
animation.
Notice that when the animation is actually running, that subtle pose change becomes
quite noticeable.
tip
An excellent tool called characterFX is useful for creating animations, and it works well with Milk-
Shape. Unfortunately, for logistical reasons it could not be included with the tools on the compan-
ion CD. However, it does a great job of streamlining the process and is flexible, so a quick Google
search for it on the Internet might be worth your while!
Run Animation
The run animation is the staple of first-person
shooters. Run and shoot, run and shoot. Our
Hero character has a somewhat awkward lower
body, which will tend to make any animation
of him running look a bit goofy. Well, we'll
turn that into a feature and capitalize on that
goofiness.
Chapter 14
■
Making a Character Model452
Figure 14.83 The difference in poses.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
1. Set the Keyframer to 120 frames. Additional frames will be added after the 30 you
started with for the idle animation.
2. Move the slider to frame 31.
3. Make sure that Operate on Selected Joints Only in the Animate menu is enabled.
4. Rotate the right hip joint slightly and then choose Animate, Set Keyframe. The
pose should be similar to the resting pose. The reason why we touched that hip
joint at all is to ensure that there is at least one joint in the frame that was affected
so that a keyframe will be made. You should have a pose much like that shown in
Figure 14.84.
5. Move the slider to frame 40.
6. In the Right Side view, select the Base joint, and
move it forward by one grid square and up
about three-quarters of a grid square, as shown
in Figure 14.85. This movement of the base
joint moves the entire model—it's a transfor-
mation across the ground. This transformation
is necessary in order to notify the Torque
Engine that the model is moving and how fast it
is moving. It doesn't need to be precise, but it
does need to be there.
7. Select the right hip, and then in the Side view
rotate it so that the leg moves forward.
8. Rotate the right knee forward as well, until the
leg matches the configuration in Figure 14.85.
9. Repeat the rotations for the left leg and move it
backward. In order to get things looking right,
you might have to adjust the joint positions
slightly by moving them, but not by much.
10. Rotate the left arm using the left shoulder node
and the left elbow node, swinging the hand for-
ward until it is approximately opposite the right
leg, as shown in Figure 14.85.
11. Set frame 40 to be a keyframe.
12. Move the slider to frame 50. Use Figure 14.86 as
the guide for this frame.
13. Move the base node one more grid square to the
right, but this time move it back down to the
ground level.
Character Animation 453
Figure 14.84 Frame 31.
Figure 14.85 Frame 40.
Figure 14.86 Frame 50.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
14. Move all of your legs and joints back to approximately the same configuration as
in frame 31.
15. Swing the left arm down to the side of the model.
16. Set this frame (50) to be a keyframe.
17. Move to frame 60. Use Figure 14.87 as the guide for this frame.
18. Pose frame 60 the same as frame 40, except swing the legs in the opposite direc-
tions.
19. Swing the left arm back and rotate the elbow so that the left hand comes up paral-
lel to the ground.
20. Set this frame to be a keyframe.
21. Move to frame 70. Use Figure 14.88 as the guide for this frame.
22. Swing the arms and legs back to roughly the pose they had in frame 31.
23. Set this frame to be a keyframe. Use the Play Forward button to watch the anima-
tion. If the animation seems to be too fast or too slow, change the FPS setting in
the Preferences dialog box until it seems right, and take note of the value you use.
Now you have probably noticed that although we set the pose in only five frames, the pro-
gram automatically interpolated, or figured out, what the in-between frames should look
like. Torque does the same thing for us when we use
the model in-game. This is goodness. That's as much
of the run animation as we're going to do here, but you
should practice working with this for a while. The first
place you should start is to set the keyframe exactly in
the middle of the ones we've already set—at frames 35,
45, 55, and 65—and adjust the leg positions to get a
better animation from the legs.
Don't try too hard to make the animation look natural
though—he's a goofy character and should have that
sort of goofy, cartoonlike appearance when running.
Head Animation
This is the animation that Torque automatically
invokes when it needs to know how far your charac-
ter is looking up or down. So basically this anima-
tion's purpose is to define limits or a boundary and
not so much the movement. However, if your charac-
ter's facial or head shape would change when looking
up or down, then you would create a more complex
head animation.
Chapter 14
■
Making a Character Model454
Figure 14.88 Frame 70.
Figure 14.87 Frame 60.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
That being said, it is really quite quickly dealt with.
1. Move to frame 71.
2. In the Right Side view, rotate the head joint until the head is looking up at the
maximum angle you want to allow. You may also need to move the head back a
bit.
3. Make this a keyframe.
4. Move to frame 72.
5. Rotate the head joint until the head is pointed down at the maximum angle you
want to allow. You may also need to move the head forward a bit.
6. Make this a keyframe also.
7. Save your work! There, you are done. That's the entire animation sequence! Check
your frames against Figure 14.89 to make sure you got it all right.
Headside Animation
In the same way that the head animation defines the limits for the up and down motion
performed by Torque, the headside animation provides the limits for the left and right
motion. This is most visible from the third-person perspective when in the game.
Do the same thing you did for the head animation, but use frame 73 for the left turn and
frame 74 for the right turn. Make each of these frames a keyframe, and save your work
when you finish.
Look Animation
The look animation is basically another movement-limiting animation that defines how
the character's arms will be posed when he is looking up or down. Again, it is a simple
two-frame animation that doesn't require us to go into in detail now. Use frame 75 for the
down "look," or aim. Make sure you have both arms positioned sensibly. Use frame 76 for
the up aim. Set both as keyframes and save your work again.
Death Animation
As you saw earlier, there are many possible ways to die. Torque supports 11 "standard"
death animations, but you can easily
add more by writing a minor code
change into the scripts.
We'll cover only one death animation
here. We'll have the character collapse
backward and fall to the ground on his
back with his feet tossing into the air
and back down again.
Character Animation 455
Figure 14.89 Head sequence frames.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
1. Move to frame 81 and set the pose back to resemble the resting pose as closely as
you can, without spending too much time on it.
2. Set this frame to be a keyframe.
3. Move to frame 90 and rotate the arms and hands to match. You can have the char-
acter's head pop off temporarily, like I do, or leave it on but thrown back. It's your
model! Let Figure 14.90 guide you.
4. Set frame 90 to be a keyframe.
5. Move to frame 100.
6. In the Side view, drag the base node backward several grid squares.
7. Continue to rotate and move the arms and legs, and rotate the body around the
pelvis node to make the body tipped past the horizontal with the bottom of the
torso higher than the top, as shown in Figure 14.91.
8. If you haven't guessed it by now, make this frame a keyframe!
9. Move to frame 110.
10. The body is hitting the ground, with
some momentum still in the legs.
Align the bottom of the torso (which
is actually the character's back) even
with the ground. Rotate the legs and
knees to fling the feet up over the
body, and rotate the arms to fling
them away from the body, as shown
in Figure 14.92. By now the base
node should be eight or nine grid
squares behind the origin along the
Z-axis, as seen in the Side view.
11. Yup, this is another keyframe. Go
ahead, make its day.
12. Now for the final resting position.
Move to frame 120.
13. Lay the body out, flat against the
ground. Also, move the base node
one or two more grid squares farther
back, to cause the body to slide along
the ground. Lay the arms flat to the
sides, the feet and legs down on the
ground and spread somewhat. Tilt
the head back. As you can see in Fig-
ure 14.93, he's dead, Jim.
Chapter 14
■
Making a Character Model456
Figure 14.90 Frame 90.
Figure 14.91 Frame 100.
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
[...]... vertices 3 Starting at the right side (the front of the car), begin creating faces, moving to the left along the top as you proceed, including the window area, as shown in Figure 15.7 When you reach the left side, you should have something resembling Figure 15.8 4 After completing the top row of faces, start making faces along the bottom, from the left back over to the right (see Figure 15.9) 5 Finish up... select all the faces by dragging the selection rectangle around all of them This will highlight all the faces 3 Now choose Edit, Hide Selection All of the correctly oriented faces will vanish, leaving behind only the ones facing the wrong way 4 To fix the problem, unhide all the hidden faces, clear the Ignore Backfaces check box, and select all the faces again This will select all correct and incorrect... special nodes that indicate where other game functions will happen: Wheeled vehicles need to know where the wheels are located, as well as information about how the springs and steering mechanisms are oriented Some vehicles might need nodes in their models to indicate to the engine where to generate engine exhaust smoke using particles Flying vehicles may require nodes to help the engine generate contrails... so is usually actually behind and above the vehicle The mount0 and mount1 mounts are used for games where the player's character actually gets "in" the vehicle; Team LRN Figure 15.28 Finished fender 475 476 Chapter 15 ■ Making a Vehicle Model they specify where the player's avatar will be mounted The game continues to use the player's avatar's camera and eye nodes You saw those in use back in Chapter... Making a Vehicle Model The Vehicle Model In this chapter we are going to build a complete wheeled vehicle—the runabout, which will wear the skin you created in Chapter 9 Then we will insert it into a little test game so that we can carom about and drive our insurance rates through the roof! The Sketch I find the best way to start a new model is with a sketch Doodle out some ideas, and keep working... everything by clicking the Select tool in an open area, and select the Ignore Backfaces check box again Team LRN 469 470 Chapter 15 ■ Making a Vehicle Model 7 Drag select over all the faces one more time Now only the faces that were originally incorrect will be selected 8 Choose Face, Reverse Vertex Order with those faces selected 9 Then for one final time clear the Ignore Backfaces check box, select all. .. deselect each node after it's been created 2 Name each of the joints with the names shown in Figure 15.30, with hub0 being the left front joint 3 Add two more unconnected joints to the locations shown in Figure 15.31 Name the front one "eye" and the rear one "cam" 4 Finally, add two unconnected joints to the locations shown in Figure Figure 15.27 All vertices moved 15.32 Name the one on the right (the left-hand... Material attributes can be set using the MilkShape Shininess and Translucency sliders as well as by embedding additional flags in the material name Environment mapping can be controlled for the model by use of the Shininess slider—it's the one on the left-hand side Setting the slider to any value but 0 will enable environment mapping for the texture Note that the texture you are using must have an alpha channel,... adjusted Side view I keep the original sketches as they were so that I can print them out for reference purposes (and also just to pin up on the wall because it's a cool artsy thing to do) The Model Figure 15.3 Side view sketch adjusted for use in So pour some gasoline in the ol' comput- MilkShape er, grab the pull-start, and fire up MilkShape again if it isn't already running If you need a quick refresher,... original size 20 In the Top view make sure the entire model is selected, and then use the Move tool to drag the model over the sketch so that it is Figure 15.14 After duplicating and moving the aligned around the longitudinal copies center of the car in the sketch You should now have a model that looks like that shown in Figure 15.15 21 In the Top view select the bottom nine rows (or forwardmost nine . on!
Rigging the Head
We'll begin with the head, just to get a feel for the rigging operation.
1. In the Joints tab in the toolbox, choose the joint (or. standing there,
doing nothing in particular. In some games you will see some pretty complex idle anima-
tion where the character scratches himself in rather