8

364 Chapter 12: Animation
Tr ans for m S cr ipt Contr oll er
Maintoolbar>CurveEditor(Open)>Selectatransform
track i n the Track View hierarchy. > Track View menu bar
> Controller menu > Assign > Transform Script
Graph Editors > Track V iew - Curve Editor > Select a
transform track in the Track View hierarchy. > Track Vi ew
menu bar > Controller menu > Assign > Transform Script
Animation menu > Transform Controllers > Script
The Transform Script controller contains
all of the information contained in a
P osition/Rotation/Scale (PRS) controller
(page 2–341)
in one scripted matrix value. Instead
of having three separate tracks for position,
rotation, and scale, all three values can be
simultaneously accessed from one script controller
dialog. B ecause the transform values are defined
by a script, they are easier to animate.
Thevalueofthecontrollerscriptmustbeamatrix3
value. A matrix3 va lue is a 4x3 3D transformation
matrix. For more information, see the Matrix3
Va lu e s topic i n t h e
MAXScript reference (page
3–973)
.
Wr it ing Control l er S cri pts
The software interprets the text you typ e into the
Script text box as the body of a MAXScript block
expression. You can t yp e as many expressions
as you want on as many lines as you want, and
they are evaluated in turn. The value of the last
expression is taken as the controller va lue. This
must yield a matrix3 value.
Since the text is inside a block expression, you can
declare local variables that are visible only within
the script and are temporary for one evaluation.
You can also declare or access global variables that
are shared with all other scripts in MAXScr ipt and
hold their values from one evaluation to the next.
A controller is always evaluated with respect to
a specific animation time by the software. This
mightbethecurrenttimesliderorincrementing
frame time if an animation is playing, or a
renderingisunderway. InthecaseofScript
controllers,thetimebeingevaluatedisusedto
establish an automatic "at time" context around
the controller script, so any properties you access
(outside of other explicit “at time expressions)
yield the correct values for the current controller
evaluation time. This means you don’t have to
do anything special in your scripts to work at
the correct time. You can access the evaluation
time with the standard MAXScript variable,
current Time. You can also reference scene
propert y values at other times by using "at
time" expressions in your scripts, as in regular
MAXScript prog ramming.
Assign Nodes and Tracks to Variables
When you need to refer to no des in your scene
or to animation tracks, it is recommended that
you use the Script controller variable toolset to
create variables to assign to any part icular node or
controller track. This way, if you decide to later on
rename your scene objects, the script controllers
usingtheseobjectsarepreservedbecausethe
var iables maintain the link to the nodes.
Otherwise, if you assign, for example, a node to
a var iable manually in the dialog’s Expression
w indow, that link becomes broken as soon as you
rename that particular node.
Note: It is especially important to assign nodes and
tracks to variables with the corresponding buttons
when using XRef scenes and objects.
See also
MAXScript Reference (page 3–973)