Particle Animation with Anim8or v0.7


Generating the code by means of a script file

 

BEGIN {

    stars                            = 3000

    background_radius      = 500

    min_diameter               = 1.3

    max_diameter              = 3

    PI                                = 3.14159259

# initialize the random number generator

             srand()

 

      for ( i = 1; i <= stars; i++ ) {

# define the object

             object = "object01"

             printf( "  objectelement { \"eobject%d\" \"%s\"\n", i, object )

 

# generate random right-ascension and declination values

             theta      = PI*rand()

             fi           = 2*PI*rand()

 

# generate the spherical coordinates

             x = background_radius * sin(theta) * cos(fi)

             y = background_radius * sin(theta) * sin(fi)

 z = background_radius * cos(theta)

       

# place the object into the position

            printf( "    loc { (%f %f %f) }\n", x, y, z )

  

# scale the object

            scale = min_diameter + (max_diameter - min_diameter)*(rand())^3

printf( "    scale { %f }\n", scale )

 

# close the object element

printf( "    }\n" )

      }

}

 
The resulting code for 3,000 objects is copied and pasted in the objectelement section of an empty anim8or project file (template).

 

Working with the awk utility

I used awk95.exe to process the awk script file. Any other awk utility is good for the job. It runs in a DOS window, with this command line at the DOS prompt:

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, 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 3,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 staremplate.an8. Save the file as starry_background.an8

back               next