/* Module Rotate2, d'après le module Rotate code client par iri (http://www.irizone.net), février 2008 sous licence Scol */ var ROT2_FRAMES_PER_SECOND = 30;; /* default framerate value */ var ROT2_INITON = 0;; /* default value */ var ROT2_NOEND = 1;; /* default value */ var ROT2_NUMBER = 1;; /* default value */ var ROT2_ANGX = 100;; /* default value */ var ROT2_ANGY = 100;; /* default value */ var ROT2_ANGZ = 100;; /* default value */ typeof class = S;; typeof ROT2_data = [I I I I I I I I I I I I I I I];; typeof ROT2_dataInit = [I I I];; typeof ROT2_working = I;; proto setDefaults = fun [I I I I I I I I I I] [I I I I I I I I I I I I I I I];; fun getDefaults(l)= set ROT2_data = [ atoi hd l atoi hd tl l atoi hd tl tl l atoi hd tl tl tl l atoi hd tl tl tl tl l atoi hd tl tl tl tl tl l atoi hd tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl tl tl tl tl tl l atoi hd tl tl tl tl tl tl tl tl tl tl tl tl tl tl l ];; fun setDefaults(framerate, initon, noend, number, totalangularx, totalangulary, totalangularz, angx, angy, angz)= if framerate == nil then set framerate = ROT2_FRAMES_PER_SECOND else nil; if initon == nil then set initon = ROT2_INITON else nil; if noend == nil then set noend = ROT2_NOEND else nil; if number == nil then set number = ROT2_NUMBER else nil; if totalangularx == nil then set totalangularx = 90 else 0; if totalangulary == nil then set totalangulary = 90 else 0; if totalangularz == nil then set totalangularz = 90 else 0; if angx == nil then set angx = ROT2_ANGX else nil; if angy == nil then set angy = ROT2_ANGY else nil; if angz == nil then set angz = ROT2_ANGZ else nil; [framerate nil angx 0 angy 0 angz 0 number 1 totalangularx totalangulary totalangularz initon noend];; fun rotobj2(x, v) = match x with (objAnchor [h _ _ _] -> M3rotateObjExt session h v) |(_->nil);; fun rotobj(o)= let ROT2_data -> [framerate tick angx angxaccum angy angyaccum angz angzaccum number numbercum totalangularx totalangulary totalangularz initon noend] in let if (numbercum > number) && (noend == 0) then 1 else 0 -> theend in ( if tick == nil then set tick = _tickcount else nil; if theend && ((angxaccum >= totalangularx) || (angx == 0)) && ((angyaccum >= totalangulary) || (angy == 0)) && ((angyaccum >= totalangulary) || (angz == 0)) then ( ObCbAnim o nil; _DMSevent this (strcatn (ObName o) :: ".stopped" :: nil) nil nil; set ROT2_working = 0; ) else 0; let _tickcount -> currenttick in let ((currenttick - tick) * framerate) -> timeframe in let 0 -> a in let 0 -> b in let 0 -> c in ( if angx == nil then nil else let (timeframe * angx) -> xtimeframe in let mod xtimeframe 1000 -> xaccum in ( set b = (xtimeframe / 1000); set angxaccum = angxaccum + b; if theend && (angxaccum > totalangularx) then set b = 0 else 0; let angxaccum - 65536 -> tmp in if tmp >= 0 then ( set angxaccum = tmp; if noend == 0 then ( set numbercum = numbercum + 1; if theend then set b = 0 else 0 ) else 0 ) else nil ); if angy == nil then nil else let (timeframe * angy) -> ytimeframe in let mod ytimeframe 1000 -> yaccum in ( set a = (ytimeframe / 1000); set angyaccum = angyaccum + a; if theend && (angyaccum > totalangulary) then set a = 0 else 0; let angyaccum - 65536 -> tmp in if tmp >= 0 then ( set angyaccum = tmp; if noend == 0 then ( set numbercum = numbercum + 1; if theend then set a = 0 else 0 ) else 0 ) else nil ); if angz == nil then nil else let (timeframe * angz) -> ztimeframe in let mod ztimeframe 1000 -> zaccum in ( set c = (ztimeframe / 1000); set angzaccum = angzaccum + c; if theend && (angzaccum > totalangularz) then set c = 0 else 0; let angzaccum - 65536 -> tmp in if tmp >= 0 then ( set angzaccum = tmp; if noend == 0 then ( set numbercum = numbercum + 1; if theend then set c = 0 else 0 ) else 0 ) else nil ); set ROT2_data = [framerate currenttick angx angxaccum angy angyaccum angz angzaccum number numbercum totalangularx totalangulary totalangularz initon noend]; apply_on_list (ObAnchor o) @rotobj2 [a b c]; 0 ) );; fun delete(o) = ObCbAnim o nil; _DMSevent this (strcatn (ObName o) :: ".stopped" :: nil) nil nil; set ROT2_working = 0; let ROT2_dataInit -> [ax ay az] in match hd (ObAnchor o) with (objAnchor [h _ _ _] -> M3setObjAng session h [ax ay az]) |(_->nil);; fun inverse(o, from, action, param, reply)= 0;; fun stop(o, from, action, param, reply)= ObCbAnim o nil; _DMSevent this (strcatn (ObName o) :: ".stopped" :: nil) nil nil; set ROT2_working = 0;; fun stopS(ui, action, param, o)= ObCbAnim o nil; _DMSevent this (strcatn (ObName o) :: ".stopped" :: nil) nil nil; set ROT2_working = 0;; fun isWorking(o, from, action, param, reply)= if ROT2_working then _DMSevent this (strcatn (ObName o) :: ".working" :: nil) nil nil else _DMSevent this (strcatn (ObName o) :: ".noWorking" :: nil) nil nil;; fun start(o, from, action, param, reply)= if ROT2_working then 0 else ( ObCbAnim o @rotobj; _DMSevent this (strcatn (ObName o) :: ".started" :: nil) nil nil; set ROT2_working = 1 );; fun startS(ui, action, param, o)= delete o; ObCbAnim o @rotobj; _DMSevent this (strcatn (ObName o) :: ".started" :: nil) nil nil; set ROT2_working = 1;; fun reset(o, from, action, param, reply)= delete o;; fun changeS(ui, action, param, o)= let lineextr param -> l in getDefaults l; 0;; fun newOb(o)= let atoi hd UgetParam ObUi o "angularX" -> angx in let atoi hd UgetParam ObUi o "angularY" -> angy in let atoi hd UgetParam ObUi o "angularZ" -> angz in let atoi hd UgetParam ObUi o "framerate" -> framerate in let atoi hd UgetParam ObUi o "initon" -> initon in let atoi hd UgetParam ObUi o "noend" -> noend in let atoi hd UgetParam ObUi o "number" -> number in let atoi hd UgetParam ObUi o "totalangularX" -> totalangularX in let atoi hd UgetParam ObUi o "totalangularY" -> totalangularY in let atoi hd UgetParam ObUi o "totalangularZ" -> totalangularZ in ( set ROT2_data = setDefaults framerate initon noend number totalangularX totalangularY totalangularZ angx angy angz; set ROT2_working = 0; ObRegisterAction o (strcatn (ObName o) :: ".start" :: nil) @start; ObRegisterAction o (strcatn (ObName o) :: ".isWorking?" :: nil) @isWorking; ObRegisterAction o (strcatn (ObName o) :: ".reset" :: nil) @reset; ObRegisterAction o (strcatn (ObName o) :: ".stop" :: nil) @stop; ObRegisterAction o (strcatn (ObName o) :: ".inverse" :: nil) @inverse; UcbMessage ObUi o ["Start" mkfun4 @startS o] :: ["Stop" mkfun4 @stopS o] :: ["Change" mkfun4 @changeS o] :: nil; if initon then ObCbAnim o @rotobj else nil; match hd (ObAnchor o) with (objAnchor [h _ _ _] -> set ROT2_dataInit = M3getObjAng session h ) |(_ -> nil); ObCbDestroy o @delete; 0 );; fun IniPlug(file)= set class = getInfo strextr _getpack _checkpack file "name"; PLUGsetinfo thisplug PLUGIN_ONLINE_EDITING|PLUGIN_OBJECT|PLUGIN_RESERVED; PLUGdefineEditor thisplug @dynamicedit; PlugRegister class @newOb nil; 0;;