/* Trajectory - DMS2 Jun 99 - by Christophe LOREK */ /* Trajectory2 - January 2003 - by Bob Le Gob */ /* Last update: 6th of February 2003 - Bob Le Gob */ typeof class = S;; /******************************************************************************* cbTick() - Instance timer callback function tmr -> Timer : Instance timer a -> [S I I I I Timer] : [ObName PlayFlag PlayOnceFlag ServerActionFlag TimerPeriod Timer] <- I : Not used *******************************************************************************/ fun cbTick(tmr, a) = _rfltimer tmr nil nil; _deltimer tmr; mutate a <- [_ 0 _ 0 _ nil]; 0;; /******************************************************************************* StartTimer() - Starts instance timer a -> [S I I I I Timer] : [ObName PlayFlag PlayOnceFlag ServerActionFlag TimerPeriod Timer] <- I : Not used *******************************************************************************/ fun StartTimer(a) = let a -> [_ _ _ _ period _] in mutate a <- [_ _ _ _ _ (_rfltimer _starttimer _channel period @cbTick a)]; 0;; /******************************************************************************* ResetTimer() - Destroy instance existing timer a -> [S I I I I Timer] : [ObName PlayFlag PlayOnceFlag ServerActionFlag TimerPeriod Timer] <- I : Not used *******************************************************************************/ fun ResetTimer(a) = let a -> [_ _ _ _ _ tmr] in if (tmr != nil) then ( _rfltimer tmr nil nil; _deltimer tmr; mutate a <- [_ 0 _ _ _ nil]; 0; ) else 0;; /******************************************************************************* cbActivate() - Standard callback function for plugin actions o -> Ob : Ob to which the action is associated from -> DMI : Not used cli -> CLIENT : Client who triggered the action action -> S : Action param -> S : Parameter reply -> S : Not used a -> TrajAnim : Trajectory structure associated with Ob <- I : Not used *******************************************************************************/ fun cbActivate(o,from,cli,action,param,reply,a)= if (!strcmp action (strcat (ObName o) ".playonceS")) then ( ResetTimer a; mutate a <- [_ 1 1 1 _ _]; UsendCli this nil (ObUi o) "playonce" (ObName o); StartTimer a; 0; ) else if (!strcmp action (strcat (ObName o) ".playloopS")) then ( ResetTimer a; mutate a <- [_ 1 0 1 _ _]; UsendCli this nil (ObUi o) "playloop" (ObName o); 0; ) else if (!strcmp action (strcat (ObName o) ".stopS"))then ( ResetTimer a; mutate a <- [_ 0 _ 1 _ _]; UsendCli this nil (ObUi o) "stop" (ObName o); 0; ) else 0;; /******************************************************************************* cbComm() - Standard cbcomm callback function for intra plugin messages ui -> UserI : User Instance linked to Ob cli -> CLIENT : Client who sent the action action -> S : Action param -> S : Parameter a -> TrajAnim : Trajectory structure associated with Ob <- u0 : Not used *******************************************************************************/ fun cbComm(ui,cli,action,param,a)= if !strcmp action "newclient" then let a -> [_ playFlag playOnceFlag srvActionFlag _ tmr] in if (playFlag && playOnceFlag && srvActionFlag && (tmr != nil)) then UsendCli this cli ui "playonce" param else if (playFlag && !playOnceFlag && srvActionFlag) then UsendCli this cli ui "playloop" param else if (!playFlag && srvActionFlag) then UsendCli this cli ui "stop" param else UsendCli this cli ui "noaction" param else nil;; /******************************************************************************* cbNewOb() - New object creation o -> Ob : New Ob <- I : Not used *******************************************************************************/ fun cbNewOb(o)= let atoi hd UgetParam ObUi o "NbFrames" -> nf in let atoi hd UgetParam ObUi o "Framerate" -> fr in let [(ObName o) 0 0 0 (1000 * nf / fr) nil] -> a in ( UcbComm this ObUi o mkfun5 @cbComm a; ObRegisterAction o (strcatn (ObName o)::".playonceS"::nil) mkfun7 @cbActivate a; ObRegisterAction o (strcatn (ObName o)::".playloopS"::nil) mkfun7 @cbActivate a; ObRegisterAction o (strcatn (ObName o)::".stopS"::nil) mkfun7 @cbActivate a; ); 0;; /******************************************************************************* IniPlug() - Function called when plugin is initialized file -> S : .plug file <- I : Not used *******************************************************************************/ fun IniPlug(file)= set class = getInfo strextr _getpack _checkpack file "name"; PlugRegister class @cbNewOb nil; 0;;