6.1.8 Customized Paths
The PATH method requires one parameter which is simply used for
defining how target objects should be moved. The type of the parameter
can be any "evaluable" primitive like a circle, a polygonal line, a
B-Spline curve or even a mesh. Almost all kind of motions can be
defined using these paths. Furthermore, motions can be accumulated by
creating hierarchical animations as we did in the example 6.1.4
"Hierarchical Animations and Bouncing Sphere".
Before we get into the point, remember that the following description
shows you how you can create new "evaluable" primitives. In other
words, you can use them with all methods, not only with PATH.
For this example, you have to create one sphere and animate it using
the function Animate/Create/Path. We will use the B-Spline curve to
define a path for the sphere, and a formula to fine-tune the path so
the sphere vibrates while it moves along the path.
1. Select the B-Spline curve and select the menu Modify/Properties/Tags.
Add the following TAG to the curve:
SFOR x+=0.2*sin(t*20*PI), y+=0.2*cos(t*20*PI)
2. Play the animation and sphere vibrates while it moves along the curve.
The variable "t" is a time, and "x", "y" and "z" define points in the
curve corresponding the time. See the reference section for full
description of variables for evaluable parameters.
Now you can save this customized curve and whenever you need this kind
of vibrating curve, just load it in.
If formulas cannot be used for solving your problem, you can write a
RPL function where you can use conditional expressions like IF ELSE
ENDIF, loops like DO LOOP, variables, etc. to define desired motions
for your objects. Lets consider the following situation: a sphere
follows a B-Spline path and when animation reaches the middle point,
the sphere starts to vibrate. In order to do this, you have to create a
RPL program which uses IF ENDIF structure:
1. Start you favorite text editor, write the following RPL program and
save it as "vibrapath.rpl":
: VibratePath
t F@ 0.5 F> (if t > 0.5)
IF
"x+=0.2*sin(t*20*PI), y+=0.2*cos(t*20*PI)"
EVAL DROP
ENDIF
;
2. Create another sphere following another path and attach the following
tag to the B-Spline curve:
SRPL VibratePath
3. Execute your RPL program by selecting the menu Project/Macros/Execute
Named and by selecting the file "vibrapath.rpl".
Play the animation and the sphere starts to vibrate as soon as the time
reaches the value 0.5.
It is about time to leave PATH method now (there is still 23 other
methods to go through). Examples we have gone th rough so far should
give you some ideas about how to solve all possible and impossible
"move along" problems.
|