8
316 Chapter 12: Animation
3.
Select the track for the variable to use, and then
click OK.
Example: To create an expression that moves a
sphere in a precise circle:
1.
Create a sphere 30 units in diameter.
Use Track View to create the Expression
controller.
2. On the Main toolbar, click Track View.
3. In the Hierarchy list, expand O bjects >
Sphere01 so the sphere’s Position track is
visible. Select this track by clicking the Position
label once to highlight it.
4. In the Hierarchy list, right-click the t rack then
choose Assign Cont roller
The Assign Controller dialog is displayed.
5. Select Position Expression from the list of
controller types, and then click OK.
The Expression Controller dialog is displayed.
Note: You can also open the E xpression
Controller dialog from the Controller >
Properties menu in the Track View-Dope Sheet.
6. In the Expression Controller dialog, create the
expression.
Replace the default expression by typing the
following position expression in the Expression
field:
[100*cos(360*NT), 100*si n(360*NT), 0]
7. Click Evaluate.
8. Play the animation. The sphere moves in a
circle about the world origin (0,0,0). The radius
of the circular p ath is 100 units.
Yo u’ v e n o w s p e c i f i e d a c i r c u l a r p a t h f o r t h e
sphere.NTisavariablethatmeansnormalized
time. Movement based on NT happens exactly
once per the active time segment, regardless of
how many f r a mes are in the animation.
Ex ample continued: To change the radi us of the
circle:
The two 100s in the position expression from the
previous procedure specif y the radius. To adjust
the radius of the circle’s path, create a symbolic
variable to represent the radius. The variable has a
constant value that is easy to edit.
1. Make Track View—D ope Sheet visible again.
2. In the Expression Controller dialog, type
radius intheNamefield.ClickScalar,andthen
click Create.
"radius" is displayed in the Scalars list in the
lower-left of the dialog.
3. Click Assign to Constant.
A dialog titled "radius" is displayed.
4. Ty pe 150 in the value field, and then click OK.
The radius variable is now 150.
Now use the new variable in the expression.
Exa mple continued: To replace the literal value with
thevariablename:
1.
In the Expression field, change 100 to radius in
both places. The expression should now look
like this:
[ radius*cos(360*NT), radius*sin(360*NT), 0]
2. Click Evaluate.
3. Play the animation. The sphere moves in a
circle about the world origin (0,0,0). The r adius
of the circular p ath is 150 units.
Ex ample continued: To mak e the sphere rotate
about a box:
1.
Create a box about 40 units square, and animate
its position over three or four keyframes.
2. Select the sphere.
3. In the Expression Controller dialog, type
boxposn intheNamefield.ClickVector,and
then click Create.