/* plugin par iri - http://www.irizone.net date : may 2005 name : iriparticles - part CLIENT name : dynparticles - part CLIENT date : february 2007 auteur : iri pour I-Maginer (http://www.i-maginer.fr) */ typeof class = S;; typeof initON = I;; typeof initColor = I;; typeof initSize = [[F F] r1];; typeof colorCycle = I;; typeof sizeCycle = I;; typeof maxSize = I;; typeof typeFX = I;; typeof typeVolEmitter = I;; typeof typeMaskEmitter = I;; typeof typeParticle = I;; typeof vectorA = [F F F];; typeof vectorB = [F F F];; typeof vectorC = [F F F];; var initAlpha = 127;; var initColorDone = 0;; var initSizeDone = 0;; var VAR_DYNEDITOR = 1;; var VAR_DYNACTION = 0;; typeof h3dTopoPart = H3d;; typeof hpart3dMain = [HPart3d r1];; // pour chaque objet de l'ancre typeof hfx3dMain = [HEffect3d r1];; // pour chaque objet de l'ancre typeof hEmitter = H3d;; typeof Objs = [H3d HMat3d];; // objet sélectionné fun setInitSize(l, sizes, life)= if l == nil then sizes else ( set sizes = [atof hd l life]::sizes; setInitSize tl l sizes life+.10.0 );; fun setInitColor(colors, life)= if (ftoi life) > 100 then colors else ( set colors = [initColor life]::colors; setInitColor colors life+.10.0 );; fun startParticles(obj)= M3load session "dms/3d/plugins/iriparticles/particles.m3d" nil; set h3dTopoPart = M3meshGetTopology session (M3getObj session "Topo_Particle"); set hpart3dMain = (M3createParticle session h3dTopoPart PCL_BILLBOARD 96.0 64.0 16.0 256.0 0.0 0.0)::hpart3dMain; // M3setParticleSizes session hpart3dMain [0.0 0.0]::[1.0 5.0]::[2.0 10.0]::[3.0 20.0]::[4.0 30.0]::[6.0 40.0]::[8.0 50.0]::[6.0 80.0]::[4.0 90.0]::[2.0 95.0]::[1.0 100.0]::nil; M3setParticleSpins session hd hpart3dMain [0.2 0.0]::[0.5 30.0]::[0.2 100.0]::nil; M3setParticleColors session hd hpart3dMain [initColor 0.0] :: [initColor 10.0] :: [initColor 20.0] :: [initColor 30.0] :: [initColor 40.0] :: [initColor 50.0] :: [initColor 60.0] :: [initColor 70.0] :: [initColor 80.0] :: [initColor 90.0] :: [initColor 100.0] :: nil; set hfx3dMain = (M3createEffect session EFFECT_CHAOTIC0 [(atof "-2.000000") (atof "-2.000000") (atof "-2.000000")] [2.0 2.0 2.0] [0.0 0.0 0.0])::hfx3dMain; let M3createEmitter session PCL_INFINIT nil [VOLUME_SPHERE [100.0 0.0 0.0] [0.0 0.0 0.0]] -> h3dEmitter in ( M3linkParticleList session h3dEmitter (hd hpart3dMain)::nil; M3linkEffectList session h3dEmitter (hd hfx3dMain)::nil; M3setEmitterState session h3dEmitter PCL_ENABLE; set hEmitter = h3dEmitter; M3link session h3dEmitter obj; );; fun setParticuleMass(mass)= M3setParticle session hd hpart3dMain h3dTopoPart nil nil nil mass nil nil nil;; fun chgColors(colors, col)= if colors == nil then nil else let hd colors -> [c vie] in [col vie] ::chgColors tl colors col;; fun setParticleInitColor(col, h)= let itoh col -> hexcol in let htoi substr hexcol 0 2 -> r in let htoi substr hexcol 2 2 -> g in let htoi substr hexcol 4 2 -> b in let make_rgba r g b initAlpha -> c in if hpart3dMain == nil then ( set initColor = c; startParticles h ) else let M3getParticleColors session hd hpart3dMain -> colors in ( set initColor = c; M3setParticleColors session hd hpart3dMain chgColors colors c );; fun setParticleInitColorAlpha(a, h)= let get_rgba initColor -> [r g b _] in let make_rgba r g b a -> c in if hpart3dMain == nil then ( set initColor = c; set initAlpha = a; startParticles h ) else let M3getParticleColors session hd hpart3dMain -> colors in ( set initColor = c; set initAlpha = a; M3setParticleColors session hd hpart3dMain chgColors colors c );; fun setParticleColorCycle(value, h)= set colorCycle = value; if !value then let M3getParticleColors session hd hpart3dMain -> colors in M3setParticleColors session hd hpart3dMain chgColors colors initColor else 0; if hpart3dMain == nil then startParticles h else 0;; fun setParticlesLife(value, h)= if hpart3dMain == nil then startParticles h else 0; let M3getEmitter session hEmitter -> [ _ _ volume] in let M3getParticle session hd hpart3dMain -> [h mask _ rate poids size spin polarity] in if value == 0.0 then ( M3setParticle session hd hpart3dMain h mask 100000.0 rate poids size spin polarity; M3setEmitter session hEmitter PCL_INFINIT nil volume ) else ( M3setParticle session hd hpart3dMain h mask value rate poids size spin polarity; M3setEmitter session hEmitter nil value volume );; fun setParticulesVolumeSphere(r, h)= let M3getEmitter session hEmitter -> [mask life _] in M3setEmitter session hEmitter mask life [VOLUME_SPHERE [r nil nil] [nil nil nil]];; fun setObjs(l)= if l == nil then 0 else let match hd l with (objAnchor [h _ _ _] -> startParticles h) |(_ -> nil) -> _ in setObjs tl l;; fun cbStart(o, from, action, param, reply)= setObjs ObAnchor o; _DMSevent this (strcatn (ObName o)::".started"::nil) nil nil; 0;; fun destroyParticles(fx, part)= if fx == nil then ( set hfx3dMain = nil; // reset set hpart3dMain = nil; // reset 0 ) else // destroy each fx and particles ( M3delEffect3d session hd fx; M3delPart3d session hd part; destroyParticles tl fx tl part );; fun cbClose(o, from, action, param, reply)= destroyParticles hfx3dMain hpart3dMain; _DMSevent this (strcatn (ObName o)::".stopped"::nil) nil nil; 0;; fun cbEdit(o, from, action, param, reply)= let Objs -> [h m] in dynamicedit nil h m param VAR_DYNACTION; 0;; fun cbClick(o, p)= let p -> [h m btn] in set Objs = [h m]; 0;; fun setColorsPart(colors, l)= if colors == nil then l else let hd colors -> [c life] in let get_rgba c -> [r g b a] in let if r > 245 then 0 else r+10 -> r in let if g > 250 then 0 else g+5 -> g in let if b > 253 then 0 else b+2 -> b in let if a > 122 then 0 else a+5 -> a in ( set l = [make_rgba r g b a life]::l; setColorsPart tl colors l);; fun setSizesPart(sizes, l)= if sizes == nil then l else let hd sizes -> [s life] in let if (ftoi s) > maxSize then 2.0 else s+.10.0 -> s in ( set l = [s life]::l; setSizesPart tl sizes l);; fun cbRender(o, p)= if colorCycle then let 0 -> i in while i <= (sizelist hpart3dMain) do let M3getParticleColors session nth_list hpart3dMain i -> colors in let setColorsPart colors nil -> l in (M3setParticleColors session nth_list hpart3dMain i l; set i = i+1) else if !initColorDone then (set initColorDone = 1; let 0 -> i in while i <= (sizelist hpart3dMain) do (M3setParticleColors session nth_list hpart3dMain i setInitColor nil 0.0; set i = i+1)) else nil; if sizeCycle then let 0 -> i in while i <= (sizelist hpart3dMain) do let M3getParticleSizes session nth_list hpart3dMain i -> sizes in let setSizesPart sizes nil -> l in (M3setParticleSizes session nth_list hpart3dMain i l; set i = i+1) else if !initSizeDone then (set initSizeDone = 1; let 0 -> i in while i <= (sizelist hpart3dMain) do (M3setParticleSizes session nth_list hpart3dMain i initSize; set i = i+1)) else nil; 0;; fun setVector(l)= [atof nth_list l 0 atof nth_list l 1 atof nth_list l 2];; fun newOb(o)= set initON = if !strcmpi hd UgetParam ObUi o "init" "on" then 1 else 0; set initColor = atoi hd UgetParam ObUi o "initColor"; set initSize = setInitSize hd strextr hd UgetParam ObUi o "initSizes" nil 0.0; set colorCycle = if !strcmpi hd UgetParam ObUi o "colorCycle" "on" then 1 else 0; set sizeCycle = if !strcmpi hd UgetParam ObUi o "sizeCycle" "on" then 1 else 0; set maxSize = atoi hd UgetParam ObUi o "maxSize"; set typeFX = atoi hd UgetParam ObUi o "typeFX"; set typeVolEmitter = atoi hd UgetParam ObUi o "typeVolEmitter"; set typeMaskEmitter = atoi hd UgetParam ObUi o "typeMaskEmitter"; set typeParticle = atoi hd UgetParam ObUi o "typeParticle"; set vectorA = setVector hd strextr hd UgetParam ObUi o "vectorA"; set vectorB = setVector hd strextr hd UgetParam ObUi o "vectorB"; set vectorC = setVector hd strextr hd UgetParam ObUi o "vectorC"; // set listObjs = setObjs2 ObAnchor o; ObCbControlClick o @cbClick; ObRegisterAction o (strcatn (ObName o)::".start"::nil) @cbStart; ObRegisterAction o (strcatn (ObName o)::".stop"::nil) @cbClose; ObRegisterAction o (strcatn (ObName o)::".edit"::nil) @cbEdit; ObCbPostRender o @cbRender; if initON then setObjs ObAnchor o else nil; 0;; // :::::: iri ajout édition online fun IniPlug(file)= set class = getInfo strextr _getpack _checkpack file "name"; let if !strcmp _getress "DefaultLanguage" "French" then "french" else "english" -> lang in _load strcatn "dms/3d/plugins/dynparticles/lang/" :: lang :: ".lang" :: nil; PLUGsetinfo thisplug PLUGIN_OBJECT|PLUGIN_RESERVED|PLUGIN_ONLINE_EDITING; PLUGdefineEditor thisplug mkfun5 @dynamicedit VAR_DYNEDITOR; PlugRegister class @newOb nil; 0 ;;