|
In this tutorial we will create virtual sliders which will be
given expressions allowing them to control multiple morph targets
simultaneously. We will be using a Gorilla model which was previously built and already contains several morph
targets. This tutorial does not cover the modeling techniques
required to build and articulate your character. It is important to note that the techniques described in this
tutorial need not be limited to morph target control. In fact,
these sliders can be easily be adapted to control virtually any
aspect of a scene.
Launch PiXELS 3D and use the File->Open menu command to open the
Gorilla model included with this tutorial. It is inside the Projects folder
in the same folder as the PiXELS 3D application.
We will use two basic primitives to create our slider; a cube and a null. Create the cube using the Shape->Cube tool. Enter the parameters as shown below.
Rotate and position the cube as shown. This will orient the cube
so that it is best viewed from within the top viewing pane. The
top viewing pane was selected because it is the least used view
in this scene. Furthermore, the cube is positioned so as to be
out of the way of the gorilla. In this way, we are turning our
top view into a control view.
Position the top view so that the cube is centered within it. The second piece of our slider will be built using a simple null
object. Create the null using the Shape->Null tool. Change the name of the null to mouth_open_slider. Set the position of the null to x: 60, y: 0, z: 80. Select the
null, then shift + select the cube. Use the Control->Link tool to establish a parent-child relationship. The following
dialog will appear:
Click OK to accept. Another dialog will appear:
Click Park to accept.
Select the null and use the Window->Expression Editor menu item to open the Expression Editor dialog. Enter the following script, exactly as it is shown: setparam -lp.y 0 mouth_open_slider setparam -lp.z 0 mouth_open_slider set val [expr [getparam -lp.x mouth_open_slider] / 100 + .5] setparam -si 2 $val ape_head set yPos [expr $val * -4 - 8] setparam -p.y $yPos lower_gum In the top view, select the mouth_open_slider null and move it left to right. Notice how the mouth of the Gorilla
opens. The bottom gum and teeth move with it, despite the fact
that they are separate objects. Lets take a look at the script
code:
setparam -lp.y 0 mouth_open_slider setparam -lp.z 0 mouth_open_slider These two lines simply use the setparam command to constrain the y and z position of the slider. For
aesthetic reasons, we want to keep our slider centered inside
the parent cube. The setparam command is used to define an object parameter. A complete list
of parameters which can be set can be found in the online manual.
set val [expr [getparam -lp.x mouth_open_slider] / 100 + .5] This line is doing several things. First, it is using the getparam command to get the current x position of the slider. This value
is then divided by 100 (the width of the cube encompassing our
slider). At this point, when the slider is in the middle of the
encompassing cube, its x position is 0. Because of this, we end
up with a slider which ranges from -0.5 to 0.5. We want our slider
to range from 0 to 1, so we must add in .5 after the division.
After all of this math is completed, the result is assigned to
the variable val.
setparam -si 2 $val ape_head This line, using the setparam command again, sets the shape influence
of morph target #2 to val. Simple.
set yPos [expr $val * -4 - 8] setparam -p.y $yPos lower_gum These two lines adjust val and assign it to the position of the lower_gum object. This is done so that the lower gum and the teeth will
move down as the mouth opens. Try removing these two lines and
see what happens. Also, try changing some of the values and observe
the results.
setparam -lp.y 0 snarl_slider setparam -lp.z 0 snarl_slider set val [expr [getparam -lp.x snarl_slider] / 100 + .5] setparam -si 1 $val ape_head This script works almost exactly as the previous one. The main
difference is that we are not moving any secondary objects as
before. In addition, we are adjusting the shape influence of morph
target 1, not 2.
This tutorial just touches the surface of what can be done using
custom controls inside PiXELS 3D. A slider system can be setup
to control the many aspects of facial and character animation.
In addition, third party software, such as FaceSpan or Real Basic,
can be used to quickly build custom user interfaces with true
sliders and floating palettes. |