Particle Animation with Anim8or v0.7


Generating the code for smoke animation by means of a script file

 

BEGIN {

particles            = 2000             # number of particles

startSmoke       = 0                   # starting frame for smoke

x_origin            = 0                   # emitter location

y_origin            = 0                   # emitter location

z_origin            = 0                   # emitter location

x_length            = 1                   # emitter dimension

y_length            = 1                   # emitter dimension

z_length            = 1                   # emitter dimension

  

    # 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()

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 position

startFrame = startSmoke + int(144 * rand())

 

# start frame

printf( "          pointkey { %d (%f %f %f) (0 35.343 0) (0 -35.343 0) \"?\" }\n", 

startFrame, x, y, z )

 

# key frame 2

printf( "          pointkey { %d (%f %f %f) (-1.6632 30.561 1.4553) (1.6632 -30.561 

-1.4553) \"?\" }\n",35+startFrame, x+10*(rand()-0.5), 70.686+y, z+10*(rand()-0.5))

 

            # key frame 3

printf( "          pointkey { %d (%f %f %f) (2.079 23.908 -2.9106) (-2.079 -23.908 

2.9106) \"?\" }\n", 71+startFrame, x-6.6528+15*(rand()-0.5), y+122.25, 5.8212+z+

15*(rand()-0.5))

 

            # key frame 4

printf( "          pointkey { %d (%f %f %f) (2.9106 23.493 -4.3659) (-2.9106 -23.493 

4.3659) \"?\" }\n", 107+startFrame, x+8.316+20*(rand()-0.5), 166.32+y, -11.642+

z+20*(rand()-0.5))

 

            # end frame

printf( "          pointkey { %d (%f %f %f) (-1.6632 24.948 0) (1.6632 -24.948 

0) \"?\" }\n", 143+startFrame, 4.9896+x+25*(rand()-0.5), 216.22+y, -11.642+z+

25*(rand()-0.5))

 

# 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

            printf( "          booleankey { %d 1 \"?\" }\n", 98+startFrame )

     

# hide at end of life

printf( "          booleankey { %d 0 \"?\" }\n", 143+startFrame )

 

# 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 smoking (startSmoke), the location and dimensions of the smoke 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 smoketemplate.an8. Save the file as smoke.an8. Open smoke.an8 in Anim8or, set the proper dimension for object01 (your particle), apply a suitable smoke color, set the length of scene01 at 286 and you may run the animation (from frame 0 to frame 143 + stratFrame). If you are satisfied, construct your scene around the smoke.

 

back               next