Particle Animation with Anim8or v0.7
Generating the
code for snowing animation by means of a script file
BEGIN
{
particles
= 2000
# number of flakes
startSnow = 0
# starting frame
falling = 50
# no. of frames a flake is falling
x_shift
= 0
# higher value means stronger wind
z_shift = 0
# higher value means stronger wind
variation = 20
# max. variation from the mean path
ground_level = 5
# Y coordinate of the ground
x_origin
= 0
# birth area location
y_origin
= 160
# birth area location
z_origin
= 0
# birth area location
x_length
= 300
# birth area x-length
y_length
= 0
# birth area y-length
z_length
= -200
# birth area z-length
# initialise the random number generator
srand()
for ( i = 1; i <= particles; i++ ) {
# define the object
object = "object01"
printf( " objectelement
{ \"eobject%d\" \"%s\"\n", i, object )
# generate the position
x = x_origin + (x_length * rand() - x_length / 2)
y = y_origin + y_length * rand()
z = z_origin + z_length * rand()
# place the object in position
printf( " loc
{ (%f %f %f) }\n", x, y, z )
# create a track
printf( "
controller { \"position\"\n" )
printf( "
track {\n" )
# generate first frame
startFrame = startSnow + int(144 * rand())
# start frame
printf( "
pointkey { %d (%f %f %f) (0 0 0) (0 0 0) \"?\" }\n",
startFrame, x, y, z )
# generate end frame position
x = x + x_shift + variation*(rand()-0.5)
y = ground_level
z = z + z_shift + variation*(rand()-0.5)
# end frame
printf(
"
pointkey { %d (%f %f %f) (0 0 0) (0 0 0) \"?\" }\n",
startFrame+falling, x, y, z)
# close the track
printf( "
}\n" )
# close the position controller
printf( "
}\n" )
# the visibility controller
printf( "
controller { \"visibility\"\n" )
printf( "
track {\n" )
# initially invisible
if (startFrame > 0)
printf( " booleankey { 0 0 \"?\"
}\n" )
# to avoid phantom-key problem
if (startFrame > 98)
printf( "
booleankey { 98 0 \"?\" }\n" )
printf( "
booleankey { %d 1 \"?\" }\n", startFrame )
# to avoid phantom-key problem
if ((startFrame+falling) < 98)
printf( "
booleankey { %d 1 \"?\" }\n", 98)
# close the track
printf( "
}\n" )
# close the visibility controller
printf( "
}\n" )
# close the object element
printf( " }\n"
)
}
}
You can set your own parameters for the animation: number of particles, the starting frame for snowing (startSnow), wind effect, location and dimensions of the snow flakes emitter (box).
Type in a DOS window the following command line:
Your Path\awk95 –f Script file > Code file
where
Your Path is the path to awk95.exe, -f is a switch, Script file
is the name of the file containing the awk script (given above), located in the
same folder with awk95.exe and Code file is the name of the file
generated by awk95.exe containing the code for 2,000 objectelements. Simply open
Code file (generated in the same folder with awk95.exe) with a text
editor, copy the whole code and insert it in snowtemplate.an8. Save the
file as snowing.an8. Open snowing.an8 in Anim8or, set the proper
dimension for object01 (your particle), apply a suitable snow color, set the fog
parameters, set the length of scene01 at 144+startSnow and you may run the
animation (from frame 0 to frame 143 + stratSnow).