/* Authors: Arkeon / Bob le Gob */ /* Ripple code: Bob le Gob */ /* Last update: 11.03.04 */ /* Version: 1.0 */ typeof class = S;; var iCoolFramerate = 32;; typeof iRefTiming = I;; // - Struct Waves - struct TwaveAnim = [ WAVANIM_H3d : H3d, /* H3d */ WAVANIM_actif : I, WAVANIM_rand : I, WAVANIM_speed : I, iWaveX : I, iWaveZ : I, iWaveL : I, iWaveA : I, iWaveTot : I, iWaveMov : I, fWaveL : F, fWaveA : F, iTabSiz : I, tSin : tab F, tCoord : tab [I I I], tDist : tab I, tAlt : tab I ]mkWaveAnim;; typeof WaveList = [TwaveAnim r1];; typeof f2PI = F;; fun Pow2(n) = n * n;; fun MakeVertixList(param)= let param -> [obj3d iWaveL iWaveA Speed]in if (M3getObjType session obj3d)==M3_MESH || (M3getObjType session obj3d)==M3_TOPO then ( let 0 -> iWaveX in let 0 -> iWaveZ in let 0 -> iWaveTot in let iWaveL / (iCoolFramerate) -> iWaveMov in let itof iWaveL -> fWaveL in let itof iWaveA -> fWaveA in let mktab iWaveL nil -> tSin in let listtotab M3listOfVertices session obj3d -> tCoord in let sizetab tCoord -> iTabSiz in let mktab iTabSiz nil -> tDist in let mktab iTabSiz nil -> tAlt in ( let 0 -> i in while (i < iWaveL) do ( set tSin.i = sin (((itof i) *. f2PI) /. fWaveL); set i = i + 1; ); let 0 -> i in while (i < iTabSiz) do ( let tCoord.i -> [x y z] in ( set tDist.i = ftoi sqrt itof ((Pow2 (x - iWaveX)) + (Pow2 (z - iWaveZ))); set tAlt.i = y; ); set i = i + 1; ); let mkWaveAnim [obj3d 1 0 (Speed+1) iWaveX iWaveZ iWaveL iWaveA iWaveTot iWaveMov fWaveL fWaveA iTabSiz tSin tCoord tDist tAlt] -> mkwave in ( set WaveList = mkwave::WaveList; 0; ); ); ) else nil; 0;; fun cbTime_PlayWave (Wavestr)= let Wavestr.WAVANIM_H3d -> hobj in if Wavestr.WAVANIM_actif==1 then ( set Wavestr.iWaveTot = Wavestr.iWaveTot + ((Wavestr.WAVANIM_speed * Wavestr.iWaveMov) / iRefTiming); let 0 -> i in while (i < Wavestr.iTabSiz) do ( let Wavestr.tCoord.i -> [x _ z] in let mod (Wavestr.iWaveTot + Wavestr.tDist.i) Wavestr.iWaveL -> offset in set Wavestr.tCoord.i = [x (Wavestr.tAlt.i + ftoi (Wavestr.fWaveA *. Wavestr.tSin.offset)) z]; set i = i + 1; ); M3setVertices session hobj tabtolist Wavestr.tCoord; ) else nil; 0 ;; fun cbTime_PlayWaveList (l)= if l == nil then nil else let l -> [elem next] in ( cbTime_PlayWave elem; cbTime_PlayWaveList next; ); 0 ;; fun PlayWave (o)= cbTime_PlayWaveList WaveList; 0 ;; fun findwaves(l, obj3d, state, find)= if l ==nil then find else let l -> [first next] in if first.WAVANIM_H3d == obj3d then ( set first.WAVANIM_actif = state; findwaves next obj3d 1 1 ) else findwaves next obj3d 0 0 ;; fun MakeObj(l, param) = if l==nil then nil else let l->[x n] in let match x with (objAnchor [h _ _ _] -> let param -> [vecy vecz Speed] in let findwaves WaveList h 1 0 -> find in if find==0 then MakeVertixList [h vecy vecz Speed] else nil ) |(_->nil) -> y in if y==nil then MakeObj n param else y::MakeObj n param ;; fun DelObj(l, param) = if l==nil then nil else let l->[x n] in let match x with (objAnchor [h _ _ _] -> findwaves WaveList h 0 0 ) |(_->nil) -> y in if y==nil then MakeObj n param else y::MakeObj n param ;; fun CBStart (o, from, action, linkparam, reply, param)= MakeObj ObAnchor o param; 0 ;; fun CBStop (o, from, action, linkparam, reply)= DelObj ObAnchor o nil; 0 ;; fun newOb(o) = let atoi hd UgetParam ObUi o "vecY" -> vecy in let atoi hd UgetParam ObUi o "vecZ" -> vecz in let atoi hd UgetParam ObUi o "Speed" -> Speed in let if !strcmp hd UgetParam ObUi o "init" "on" then 1 else 0 -> init in ( ObRegisterAction o (strcatn (ObName o)::".start"::nil) mkfun6 @CBStart [vecy vecz Speed]; ObRegisterAction o (strcatn (ObName o)::".stop"::nil) @CBStop; set f2PI = 2.0 *. PIf; set iRefTiming = 1000 / iCoolFramerate; if init==1 then CBStart o nil nil nil nil [vecy vecz Speed] else nil; ObCbAnim o @PlayWave; ); 0 ;; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PLUGsetinfo thisplug PLUGIN_ONLINE_EDITING|PLUGIN_OBJECT|PLUGIN_NOTRESERVED; PlugRegister class @newOb nil; 0 ;;