/* Authors: Arkeon */ /* Last update: 11.03.04 */ /* Version: 1.0 */ typeof class = S;; // - Struct Waves - struct TwaveAnim = [ WAVANIM_H3d : H3d, /* H3d */ WAVANIM_actif : I, WAVANIM_rand : I, WAVANIM_dir : I, WAVANIM_speed : I, WAVANIM_vertix : [[I I I]r1], WAVANIM_wavevertix1 : [[I I I]r1], WAVANIM_wavevertix2 : [[I I I]r1] ]mkWaveAnim;; typeof WaveList = [TwaveAnim r1];; fun MakeWavL1(vertixList, param)= let param -> [waveX waveY waveZ] in if vertixList==nil then nil else let vertixList -> [[x y z] next] in let next -> [[x2 y2 z2] nextL] in [(x-waveX) (y-waveY) (z+waveZ)]::[(x2+waveX) (y2+waveY) (z2-waveZ)]::(MakeWavL1 tl tl vertixList param) ;; fun MakeWavL2(vertixList, param)= let param -> [waveX waveY waveZ] in if vertixList==nil then nil else let vertixList -> [[x y z] next] in let next -> [[x2 y2 z2] nextL] in [(x+waveX) (y+waveY) (z-waveZ)]::[(x2-waveX) (y2-waveY) (z2+waveZ)]::(MakeWavL2 tl tl vertixList param) ;; fun MakeVertixList(param)= let param -> [obj3d x y z Speed]in if (M3getObjType session obj3d)==M3_MESH || (M3getObjType session obj3d)==M3_TOPO then ( let M3listOfVertices session obj3d -> vertixList in let MakeWavL1 vertixList [x y z] -> Wave1 in let MakeWavL2 vertixList [x y z] -> Wave2 in let mkWaveAnim [obj3d 1 0 0 Speed vertixList Wave1 Wave2] -> 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 ( if Wavestr.WAVANIM_dir==0 then ( M3morphVertices session hobj Wavestr.WAVANIM_wavevertix1 Wavestr.WAVANIM_wavevertix2 ((Wavestr.WAVANIM_rand * 65535 / Wavestr.WAVANIM_speed)); set Wavestr.WAVANIM_rand = Wavestr.WAVANIM_rand +1; ) else ( M3morphVertices session hobj Wavestr.WAVANIM_wavevertix2 Wavestr.WAVANIM_wavevertix1 ((Wavestr.WAVANIM_rand * 65535 / Wavestr.WAVANIM_speed)); set Wavestr.WAVANIM_rand = Wavestr.WAVANIM_rand +1; ); if Wavestr.WAVANIM_rand>= Wavestr.WAVANIM_speed then ( set Wavestr.WAVANIM_rand = 0; if Wavestr.WAVANIM_dir==0 then set Wavestr.WAVANIM_dir=1 else set Wavestr.WAVANIM_dir=0; ) else nil; ) 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 -> [vecx vecy vecz Speed] in let findwaves WaveList h 1 0 -> find in if find==0 then MakeVertixList [h vecx 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 "vecX" -> vecx in 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 [vecx vecy vecz Speed]; ObRegisterAction o (strcatn (ObName o)::".stop"::nil) @CBStop; if init==1 then CBStart o nil nil nil nil [vecx 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 ;;