/*--------------------------------------------------------------------------------------------- Title:SWExplod.mcr Description:Gaseous/flamable Explosion using Media macro for POV-Ray 3.1 Originator:H. E. Day Date:18 May 1999 Modified:26 May 1999 Modifier:Cliff Bowman, Modification(s): Split file into two peices - a scene file and this macro file. Corrected a couple of apparent 'clock' typos (changed 'clock' to 'EClock'). Increased size of explosion sphere to avoid Media clipping. changed EClock declaration in Explosion macro to #local (to avoid POV declaration error when using shockwave) Added 'Known issues' section to documentation. Added (untested) scene file into the documentation for easy copy/paste use (based on original scene file from H.E.Day). Changed the way 'Explosion' macro deals with result of 'StartGlow' macro to scale relative to ERadius Added 'NoStartGlow' variable which, if declared, prevents StartGlow from being called. It's a bodge that avoid uglies on small radius exposions :) 'KNOWN' REMAINING ISSUES/THOUGHTS ================================= Changing the radius of the explosion doesn't appear to affect the size of streaks or shockwave - so to use those one must use an explosion radius in the region of 1 and scale the results to fit. Scaling the explosion results in undesirable results at times due to Media scaling/density issues. Perhaps code could be changed to avoid global variables altogether. This would make the syntax unwieldy (as more parameters would be needed to *at least* the Explosion macro) but would/could reduce the apparent complexity of scene files using the macro(s). Lens-flare discs (?) can cause dark streaks in early frames. NoStartGlow avoids them but a better fix would be preferred. Possibly provide parameter to turn off the 'glow' effect (overkill on functionality suspected though). USAGE EXAMPLE ============= Copy and paste the following text to a new file and save it as 'SWExplod.pov'. Render it with the number of frames of your choice, with clock values ranging from 0 to 1. //SWExplode.pov #declare EXPClock = pow(clock,1/2); #switch (EXPClock) #range(0.000000001,1) #include "colors.inc" #declare Random = 70; //Random (any) Number. #declare Color = <1,.625,.25>-(<0,.125,.25>*explode_clock);//Red Green Blue value for the overall //color of the explosion (Change to <1,1,1> to get an Alpha Mask). #declare Detail = 1;//Amount of "smoothness". change to < .5 for bigger explosions. #declare Turbulence = .5;//Change to vary the amount of "violence". #declare AnimationAmount = 1.5;//How much does the explosion "change" during //the animation? 1 - 1.75 is good for small explosions, .25 - 1 for larger ones. #declare StreakNumber = 0;//Number of "streaks" flying away. //Include Gaseous Explode Macros #include "SWExplod.mcr" camera { location <0,0,-33> look_at <0,0,0> } light_source {0 rgb 1-clock} //Explosion (,EColor,ERand,EAnimate,ERadius,EClock,EStart,EEnd,EDetail,EShock) union { Explosion (<0,0,0>,Color, //Position,Color Random, //Random Seed AnimationAmount, //Overall Animation degree EXPClock / 0.6, //Radius EXPClock,0,1, //Clock,Start,Stop Detail, //Detail off, //Shockwave 1 ) scale 1 } global_settings {max_trace_level 150} #break #else sphere {<0,0,0>,0.0001 pigment{rgb<0,0,0>}} // Put *something* into the scene if the explosion isn't present to render. #end ---------------------------------------------------------------------------------------------*/ //Start Flare and Glow #macro StartGlow(R,N,S,E,C,RT) #declare GCLock = mod((C-S)/(E-S), 1); #if (GCLock > 0) #if (C < E) #declare C=0; #while (C< N) #declare S = seed(C+R) ; #declare SR = seed(R) ; disc {0,y,1 texture { pigment { cylindrical color_map { [0 rgb <1,.75,.5>*2-((1-EColor)*2*GCLock) transmit 1] [1 rgb <1,.75,.5>*2-((1-EColor)*2*GCLock) transmit .75+.25*GCLock] } turbulence .125 } finish {ambient 1.5 diffuse 0} } scale <.3*(rand(SR)*.75+.25),1,1> rotate 345546*y*23346*rand(C) rotate 36*y+23346*rand(C) rotate y+6*(rand(C)*360) translate (rand(C)*.1)-.05*y rotate -RT*y*GCLock rotate 90*x scale 1.5 } #declare C=C+1 ; #end disc {0,y,1 texture { pigment { cylindrical pigment_map { [0 rgb <1,.75,.5>*2-((1-EColor)*2*GCLock) transmit 1] [.125 bozo color_map {[0 rgb 2-((1-EColor)*2*GCLock) transmit .5+.5*GCLock][1 rgb 2-((1-EColor)*2*GCLock) transmit 1]} scale .5 ] [-.5*GCLock+1 rgb <1,.75,.5>*2-((1-EColor)*2*GCLock) transmit 1*GCLock] } rotate (rand(SR)*360) turbulence .25 scale .75 translate -.5*GCLock*y } finish {ambient 1.25 diffuse 0} } scale 1.25 translate .05*y rotate 90*x } #end #end #end //Streak Macro #macro Streak(SRand,SBright,SLimit,SClock) #declare S1=seed(SRand) ; #declare S2=seed(SRand*45) ; #declare ERandA = (rand(S1)*1) ; #if (SClock > 0) disc {0,y,1 hollow on texture { pigment {spherical pigment_map { [0 rgb 0 transmit 1] [.75 bozo color_map {[0 rgb EColor*1.5 transmit 0][1 rgb EColor*1.5 transmit .875]}translate -5*y*SClock translate SRand/10 scale .125 scale 1/<.25,1,5> ] [1 rgb EColor*1.5] } scale <1,1,-2*SClock+4> translate <0,0,1.5*SClock> } finish {ambient (1*(rand(S1)*1))*(2*(1-SClock)) diffuse 0} } texture { pigment {spherical pigment_map { [0 rgb 0 transmit 1] [.5 rgb EColor*1.5 transmit .5] [1 rgb <1,.75,.25>*3] } scale <1.5,1,.5>/2 translate <0,0,.85> } finish {ambient (1.5*(rand(S1)*1))*(2*(1-SClock)) diffuse 0} } #if (SClock < .5) scale <1,1,1*SClock+.5> #else #end scale <.25*((rand(S2)*1)+.5),1,3*((rand(S2)*.75)+.25)>*((rand(S1)*.5)+1 ) rotate -90*x translate (((rand(S1)*2.5)-1.5)+((rand(S1)*SLimit/2)+SLimit/2)*SClock)*y #declare Seed = seed(SRand) ; rotate (rand(Seed)*2344+(45*SRand*23))*z translate ((rand(S1)*.25)-.125)*z scale .125*SClock+.25 } #end #end //The Explosion #macro Explosion (ETrans,EColor,ES,EAnimate,ERadius,EClocka,EStart,EEnd,EDetail,EShock,ETurb) #local EClock = mod((EClocka - EStart)/(EEnd - EStart), 1); #declare ESeed = seed(ES) ; #declare ERand = rand(ESeed) ; #local EIntensity = (1-(EClock/2))*.25; #local EIntensity2 = (1-EClock)*.25; union { #if (EClock > 0) union { sphere {0, 1.5 hollow on //Oversize (*1.5) sphere to reduce chance of Media being clipped pigment { rgbt 1} interior { media{ intervals 50*EDetail samples 1,2 variance 1/600 confidence .9999 emission EColor*EIntensity/ERadius density { spherical color_map{ [0 rgb 0] [0.124 rgb 0] [0.125 rgb 4] [1 rgb 1] } translate (-2*EAnimate)*EClock*y warp {turbulence .75*ETurb} translate (2*EAnimate)*EClock*y rotate ERand+6787 } density { spherical color_map{ [0 rgb 0] [.249 rgb 0] [0.25 rgb (-5*EClock+6)] [1.0 rgb 1] } translate (1*EAnimate)*EClock*z warp {turbulence .5*ETurb } translate (-1*EAnimate)*EClock*z rotate 323456*ERand+567 } density { bozo color_map{ [0 rgb 0] [0.2*EClock+.0001 rgb 0] [-.2*EClock+.0001 rgb 1] [1.0 rgb 1]} scale .2 translate (1*EAnimate)*EClock warp {turbulence .25*ETurb omega .1} translate (-1*EAnimate)*EClock rotate 3456*ERand } density { bozo color_map{ [0 rgb 0] [0.2*EClock+.0001 rgb 0] [-.2*EClock+.0001 rgb 1] [1.0 rgb 1] } scale .1 translate (-1*EAnimate)*EClock warp {turbulence .25*ETurb omega .125} translate (1*EAnimate)*EClock rotate 56*ERand } #if (EClock <= .5) #else density { bozo color_map{ [1.5*EClock-1 rgb .75] [2*EClock-1 rgb 1] [1.0 rgb 1] } scale .25 translate (.2*EAnimate)*EClock*z warp {turbulence .5*ETurb } translate (-.2*EAnimate)*EClock*z rotate 32*ERand+56 } #end #if (EClock <= .5) #else density { bozo color_map{ [1.9*EClock-1 rgb -1*EClock+1] [2*EClock-1 rgb 1] [1.0 rgb 1] } scale 1 translate (1*EAnimate)*EClock*z warp {turbulence 1*ETurb } translate (-1*EAnimate)*EClock*z rotate 3*ERand+5 } #end } #if (EClock <= .5) media{ emission <1,1,.5>*2*EIntensity/ERadius density { spherical color_map{ [1.5*EClock+0 rgb 0] [1*EClock+0.5 rgb 5] [1.0 rgb 15] } translate (-2.5*EAnimate)*EClock*x warp {turbulence (.25*EClock+1)*ETurb } translate (2.5*EAnimate)*EClock*x rotate ERand-12 } scale 2.5 scale -.5*EClock+.5 } media{ emission <1,1,.5>*2*EIntensity/ERadius density { spherical color_map{ [1.5*EClock+0 rgb 0] [1*EClock+0.5 rgb 2.5] [1.0 rgb 7.5] } translate (-5*EAnimate)*EClock*x warp {turbulence (.5*EClock+1)*ETurb omega .875 } translate (5*EAnimate)*EClock*x rotate ERand } scale 2 scale -.5*EClock+.5 } #end } scale 1.5*EClock+.5 rotate ERand*25 } //Glow around the explosion sphere {0, 1 hollow on pigment { rgbt 1} interior { media{ emission EColor*EIntensity2/ERadius density { spherical color_map{ [0 rgb 0] [.5*EClock+.5 rgb 2] [1.0 rgb 5] } } #if (EClock <= .5) #else density { bozo color_map{ [1.5*EClock-1 rgb .75] [2*EClock-1 rgb 1] [1.0 rgb 2] } scale .25 translate (.2*EAnimate)*EClock*z warp {turbulence .5*ETurb } translate (-.2*EAnimate)*EClock*z rotate 323456*ERand+567567 } #end #if (EClock <= .5) #else density { bozo color_map{ [1.5*EClock-1 rgb -1*EClock+1] [2*EClock-1 rgb 1] [1.0 rgb 2] } scale 1 translate (1*EAnimate)*EClock*z warp {turbulence 1*ETurb } translate (-1*EAnimate)*EClock*z rotate 323456*ERand+567567 } #end } } scale 1 scale 1*EClock+1 rotate ERand*25 } #if (EClock <= .5) #if (EShock = on) #local EClock = EClock * 2 disc {<0,0,0>, y, 1.5 pigment { onion pigment_map { [0 color rgbt <1,.5,0,1>] [.15*EClock+0.5 color rgbt <1,.375,0,1>] [.95 bozo color_map {[0 rgbt <1,1,0,1*EClock>] [1 rgbt <1,.5,0,1*EClock>]} turbulence 1 scale .0675 translate <0,.75*EClock,0>] [1 color rgbt <1,.5,0,1>] } translate <0,-.25*EClock,0> } finish { ambient 3 diffuse 0 } no_shadow hollow rotate 43567*ERand scale 15*EClock+.1 } #end #end scale ERadius translate ETrans rotate ERand*25 } #declare A=0 ; #while (A