this lesson, you will learn how to set-up and use the two bone IK solver.
This solver is ideal in setting up characters for use in a Real Time 3D
game. The source code for this solver is included with Maya, and its core
algorithm can be extracted and integrated into a games engine.
In addition, you will export the animated arm to VRML to preview your
animation in a RT3D setting.
This is a supplementary how-to to the Learning Maya 3 book, and it is
suggested that you complete Project One in order to acquaint yourself
with the Maya interface and workflows.
This is the polygon arm that you will add a skeleton and IK control to.
Select Window > Settings/Preferences > Plugin Manager...
If you are on NT, load ik2Bsolver.mll. If you are on IRIX, load ik2Bsolver.so.
You should also click in the white check box next to it called auto load.
This will make sure that every time you run Maya, the ik2Bsolver.mll plugin
will be loaded on startup.
In the command line type ik2Bsolver;. This will create the ik2Bsolver
custom node. You are now ready to create a skeleton with the two bone
Select Skeleton > Joint Tool.
In the Side viewport, click inside the shoulder area. This will place
the root of the skeleton. Then continue to click in the elbow area and
then again at the hand. You will now see that there are two bones connected
from the shoulder to the hand.
Press Enter on the keyboard to complete the skeleton.
You will now set the IK solver for this skeleton. IK solvers figure out
how to rotate all the joints in a chain controlled by an IK handle. An
IK handle runs through the selected joint like a wire, providing you with
a way to move the entire joint chain.
Select Skeleton > IK Handle Tool > Options. Change the Current
Solver to ik2Bsolver.
Press Close and click on the top of the joint in the shoulder area and
then click on the end of the joint in the hand area. This tells the solver
to solve from the root joint to the last joint in this 2 bone chain.
After the solver has been added, you will notice that the skeleton has
turned purple and that there is a green line running through the skeleton
and a green line directly from the root joint to the end joint. As well,
there is now a move manipulator at the end of the joint chain. This indicates
the IK handle is selected.
Select this manipulator and move it around. The chain reacts to wherever
the manipulator is placed. Undo this by pressing Z on the keyboard.
To better understand the ik2Bsolver, there is a dedicated section in
the Character Setup manual called Using IK Two Bone Handles. For more
character set-up information, go through the Primitive Man tutorial in
the Learning Maya 3 book.
When you moved the IK handle you probably noticed that the arm stayed
in place. This is because you have to Bind the arm to the skeleton chain.
This process is called skinning. Skinning the arm will allow it to deform
with the movement of the skeleton. Smooth skin will assign influences
to the vertices of the arm based on their proximity to the joints and
bones of the chain.
Select the arm geometry and Shift - Select the upper or lower bone of
the arm's skeleton.
This tells the Smooth Bind operation that you want to assign this geometry
to this skeleton.
Select Skin > Bind Skin > Smooth Bind.
The display shows the geometry in purple and the IK handle selected.
Move the IK handle around and you will see that the geometry moves with
the skeleton. Undo your movement.
How each vertex of the geometry relates to each bone in the chain is
referred to a skin weights.
To examine weighting info on a vertex in the elbow area, select Window
> General Editors > Component Editor. The Component Editor contains
many different tabs that will show information for the selected components.
Click on the Skin Clusters tab.
Press F9 to go into Vertex component selection mode.
In the Side viewport, select a vertex on the inside of the elbow. The
Component Editor updates to show the information for the vertex you selected.
You will notice under the joint1, joint2, and joint3 columns, that the
weighting information is shown. On the vertex that was selected for this
lesson, joint1 had a weighting of 0.500. This was the same for joint2.
Joint3 has no weighting. This means that joint1 has a 50% influence on
this vertex and so does joint2. All the influences must add up to 100%
or 1.0 in the component editor. When you change a value for one joint,
the other joints update respectively to meet a 1.0 total. You can change
these influences by typing a different value, and you can hold a particular
value by changing the off value to on just below each joint.
Assume that the character this arm would be attached to is standing in
front of a control panel in a game. You will animate the arm coming up,
pushing a button and then coming back down.
Select the IK handle if it is not already selected.
In the timeline, make sure that you are at frame 1. If you are not, then
set the current frame number in the box next to the playback controls.
Press Shift - W. This will set keyframes on only the translation for
the selected manipulator.
Move the timeslider to frame 22 and either move the manipulator handles
or type directly into the appropriate boxes in the Channel Box to set
the values to : X = 1.663, Y = -4.472, and Z = 4.104. Don't forget to
press Shift - W to set a key for this frame after entering the values.
Continue to set keys based on the information below;
Frame 42 : X = -0.032, Y = -3.994, Z = 7.587 ;
Frame 44 : X = -0.032, Y = -3.994, Z = 7.587 ;
Frame 69 : X = 0.307, Y = -4.811, Z = 4.104;
Frame 88 : X = -0.032, Y = -7.821, Z = 1.008.
You may have noticed that the values for Frame 42 and 44 are the same.
These keyframes can be set by moving the timeslider to frame 42 and then
move the timeslider to frame 44 by middle mouse clicking on the time slider
and moving the current frame indicator to the desired frame. Then, set
a new keyframe. This lets you set similar keyframes in an animation without
the need for copying and pasting.
MMB in the perspective window to make it active. Press the playback button
in the time controls area to see the animation playback. When you are
done, press the stop button or the esc key.
Now that you have the animation complete, you will want to preview it
in a real-time environment. For this you will use the VRML exporter.
Select Window > Settings/Preferences > Plugin Manager
Load vrml2export and close this window.
Select File > Export All > Options.
Change the File Type dropdown to vrml2. This will change the window to
include a whole new set of options. Change the following parameters;
Under Animation Options :
loop to On
End to 88
Vertices to On.
Under vrml2 Options :
Normals to On .
If you have a VRML viewer installed then you will want to set Launch Viewer
to On as well.
Click on the Export All button on the bottom of the window, and then
a window will pop up for file path and file name. Export it to the directory
you wish. If you exported with Launch Viewer On, then an Internet browser
should open and in a few seconds you will see your animated arm in all
For more information on VRML output options, see the Games Translators
section in the online Documentation.
The two bone IK solver is a great tool for setting up your characters
for use in Real-time 3D games. It is optimized to solve a two bone chain
only and the source code is included as a bonus. This can also be used
in any character animation scenario, as it is not limited to just games.
VRML export is just one of the options that is available to you from
within Maya. Other games file formats are available as well. With the
Maya API and the Dt Games API, you can easily write your own customized
exporter to your game engine.
VRML was used in this how-to in order to give you the ability to view
your IK animation converted to vertex animation. VRML can be a useful
tool in troubleshooting your model before handing it off to the game engine.