tpower -- The power of the turbulence applied to the explosion
rad -- The radius of the explosion. rad=1 will fill the frame, and possibly go beyond the edges
transx, transy, transz -- Offsets applied to the domains of the turbulence functions
densityscale -- Scale the explosion. Use a scale <1 for a cooler explosion, ==1 for a fully hot explosion frame
The explosion sprite frame will be output to the file filename in .TGA format as an RGBA sprite. Alpha fades out at the edges of the fireball.
There is also a convenience function for generating entire animated sequences of frames using interpolated spline curves. The animatable parameters are specified as splines, and interpolated in sequence, with the frames being spit out as a sequence: , ... where N is the number of frames.
Different results can be achieved by specifying curves for the different properties. This first image is a sequence animating the tpower value from 0 to 0.5, demonstrating how turbulence power affects the fireball. The greater the turbulence, the greater and more chaotic the flame spread:
This sequence details how changing the radius of the spherical function used as the basis of the fireball changes the size of the fireball, and can be used to animate the expansion:
This sequence details how animating the (transx,transy,transz) offset factors for the turbulence functions modifies the appearance of the fireball. Can be used to simulate roiling, turbulent, fluid flame:
And this final sequence shows how animating the densityscale property causes the flame to 'cool off' and dissipate. A scale of 1 makes a fully hot flame, tending toward 0 cools it toward the black and transparent end of the scale:
By combining animations of all these properties through experimentation, a full sequence of explosion from ignition through fireball to cooling incandescent gas can be simulated. The color scale used to color the fireball is found in the file explosioncolorscale.lua and can be tweaked as you see fit. It constructs the global spline curve called cs used by the explosion frame functions, constructing the curve from the table specified in the file. If you do tweak the curve, you can clear a curve's points using the clear() method.
To setup some curves for the animated sequence, you can build them in this fashion:
turbcurve = CCurvef() -- Floating point curvescalecurve = CCurvef() -- Floating point curveradcurve = CCurvef() -- Floating point curvetranscurve = CCurvergbf() -- 3-component floating point curve-- Animate turbulence from 0.25 to 0.5turbcurve:pushPoint(0.25)turbcurve:pushPoint(0.5)-- Animate radius from 0.5 to 1.0radcurve:pushPoint(0.5)radcurve:pushPoint(1.0)-- Animate scale through a broader curve from 1 to 0.1scalecurve:pushPoint(1)scalecurve:pushPoint(1)scalecurve:pushPoint(0.75)scalecurve:pushPoint(0.25)scalecurve:pushPoint(0.1)-- Animate turbulence through a small intervaltranscurve:pushPoint(CRGBf(0,0,0))transcurve:pushPoint(CRGBf(0.2,0.2,0.2))-- now, generate a sequence of frames.explosion_curve("explode", 10, turbcurve, radcurve, transcurve, scalecurve)
The result should be 10 .TGA files named explode1.tga through explode10.tga in the base directory. Open them up in the Gimp to see the progression. If you want to tweak during runtime, the various curves can be cleared with clear() method and repopulated using pushPoint(). There are certainly ways to improve the process, this is just the result of a couple evenings spent experimenting.
In particular, you can edit the way the explosion density function is constructed. In the LUA file, it is simply set up as a hierarchy of noise modules chained together, starting with a simple sphere, applying turbulence and scaling modules, etc... By using different basis functions for the sphere and the turbulence, vastly different effects can be applied. In the file noise.txt is a brief, crude description of the tool's generator capabilities. The noise generator system is based on the system used in libnoise, but heavily modified for greater flexibility in choice of basis functions.
You can also edit the color scale to be more to your liking. This one was cobbled together in a couple minutes by sampling an image constructed using the Gimp's gradient fill, using a custom gradient I whipped together. I'm not entirely satisfied with how it alpha fades at the black end, so it could use some tweaking.
Good luck, and enjoy.