8

Limit Controller 319
Changing the Number of an Object’s Segments
Based on Camera Distance
This expression varies the number of seg ments
in a cylinder based on the distance of a camera.
It is assig ned to the cylinder’s Segments creation
parameter.
if ( (length(Camera-Myself) > 35),
3 + (50*Height) / length(Camera-Myself),
MaxSegs)
where
Camera
is the position controller of the
camera;
Myself
is the cylinder’s position controller;
Height
(= 70) is the cylinder’s height;
MaxSegs
(=100) is the maximum number of segments.
When the camera is closer, more segments make
the c ylinder smoother; when the camera is
distant, the smoothing is less impor tant and fewer
segments render more quickly.
The if() func tion returns its second argument if
the first argument is true; otherwise, it returns its
third argument. In this example, if the camera is
more than 35 units away from the cylinder, the
expression calculates the number of segments; if
the camera is 35 u nits away or closer, the number
of segments is the MaxSegs constant.
The values in the second argument are chosen so
that as the dist ance decreases toward the threshold
of 35, the number of segments increases toward
MaxSegs. The addition "3+" ensures that the
cylinder always has at least three seg ments, even
whenthedivisionroundstozero(Segmentsisan
integer).
Note: To the expression, it doesn’t matter whether
the camera is moving, or the cylinder, or both.
Limi t Contr oller
Maintoolbar>CurveEditor(Open)>Highlightatrack
in the Track View hierarchy. > Track V iew menu bar >
Controller menu > Assign > Float Limit
Graph Editors > Track View - Curve Editor > Highlight a
track in the Track View hierarchy. > Track View menu bar
>Controllermenu>Assign>FloatLimit
The Limit controller lets you specify upper
and lower limits to available controller values,
thus restricting t he potential value range of the
controlled track. For example, in a character
rig you could use this to restrict rotation on
finger joints so the fingers can’t bend backward.
Basically, once a tr ack is limited, and the limit is
active, you can’t set a value for the track beyond the
limit. You can apply a Limit controller to any other
type of controller; the limited controller (that is,
the original controller) then appears as a child of
the Limit controller in the Track View hierarchy.
Because the Limit controller doesn’t change the
original controller, you can easily switch back
and forth between the original and t he limited
animation by toggling the limits. But if you
collapse (page 2–507)
the L imit controller, the
result is the limited animation, and the orig inal
animation is no longer available.
Use of the Limit cont roller makes it faster to set
up and create animation. It eliminates the need
for expressions or scripts to do the s ame thing,
this improving the ease with which you can set up
automation in hierarchies and r igs, creating effects
such as avoiding collision, FK joint limits, etc.
For example, a Technical Director might want to
assign limits to float values that animators w i ll
adjust to make posing easier, enforce standards, or
prevent inconsistencies and m istakes. A TD could
use limits for :
light intensity
•fingerrotation