Push
Push (St Actorname);
The push command is used in conjunction with DoShift, DoSpinShift, and DoShiftSpin to install actors in the queue. See those commands for details on creating the Anonymous Actor that represents the track of motion.
The sequence of actions for these commands is:
1) Gldraw {...}
2) Push
3) DoShift or DoSpinShift or DoShiftSpin
Suppose, for example, that you wanted to move some actors simultaneously along their trajectories given by differential equations, or by curves, or even stochastically. You could create the trajectories as an anonymous (and invisible) actor. If the trajectories were to be sequences of positions (without changing orientation) you would use the Gldraw{...} protocol with the desired sequences of positions as Vertex() or Vertex3() calls computed within it. You should not use Begin() ... end() within the Gldraw{..} or any other OpenGL functions. Then you would use the DoShift command to move the actors in the queue through the sequence of steps in the invisible actor.
The queue works this way. Suppose it contains actors: {a1, a2, .., an}. Then when DoShift is called, tha actor a1 is moved to the first position, a2 is moved to the second position, a3 is moved to the third position, ..., an is moved to the nth position, then a1 is moved to the (n+1) position, and so on cyclically, until there are no more positions.
If you wanted the orientation to change, as well as the position, for example, in rotating and orbiting a planet, you would create an invisible actor with the sequence of pairs of orientations and positions, in that order, and use either DoSpinShift or DoShiftSpin.
The Push Command adds an actor to the queue of actors to move along this invisible actor. For each actor that you plan to move, you should make a separate Push call with its name. If a name is repeated, it is ignored the second time an attempt is made to install it. The actors are moved in the order in which they are installed after the invisible actor is created.
Note: Each time an invisible actor is created (or any call to Gldraw{..} is made), the queue is erased. So you should call Gldraw{...} first to create the invisible actor, then create the queue of actors to move using push.
The following example moves the actor "Ted" along the solution trajectory of a differential equation (the "Lorenz" equation):
refresh;
let ss be gettext("step");
gldraw { lorenz( [1,2,-1], .02*ss, 4000)};
push "ted";
doshift;
The program Lorenz is defined in Book script by:
program lorenz (ve #3 start) (ex step) (ex no)
{
local (ve #3 vec) {
let vv(x,y,z) be value [10*y-10*x, 28*x-y-x*z, x*y-8*z/3];
do
i := 0
vec := FALSE
maximum := [10^6,10^6,10^6]
until or(i > no, start >= maximum, -start >= maximum)
{
vec := start+step*vv(start);
vertex(vec);
start := vec;
i := i+1;
}
}
}
See Also