2009
where Time is one of the predefined time variables such as NT or S; Pos1 and
Pos2 are the Position controllers of two other objects.
The subexpression (1+sin(360*Time))/2 is a value that oscillates between 0
and 1 over time. (Pos1-Pos2) is the vector between the two other objects.
Multiplying the two and then adding Pos2 as an offset locates the object along
this vector.
Changing the Number of an Object’s Segments Based on Camera
Distance
This expression varies the number of segments in a cylinder based on the
distance of a camera. It is assigned 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 cylinder smoother; when
the camera is distant, the smoothing is less important and fewer segments
render more quickly.
The if() function 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 units away or closer, the number of segments
is the MaxSegs constant.
The values in the second argument are chosen so that as the distance 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 segments,
even when the division rounds to zero (Segments is an integer).
NOTE To the expression, it doesn’t matter whether the camera is moving, or the
cylinder, or both.
Layer Controller
Main toolbar > Curve Editor (open) > Highlight a Layer controller track and
right-click > Properties
3162 | Chapter 15 Animation