Particle System Extensions to the .ray File Format

In addition to all of the commands of the original .ray file format, your program will need to understand the following extensions. The syntax of the commands is very similar to the other .ray file commands. All units are specified in MKS units, meters for distance, kilograms for mass, seconds for time, and Newtons for force.

Commands:

#particle k
    px py pz
    m d e

This command defines a particle. (px,py,pz) is the position of the particle in world coordinates, m is the mass of the particle (range: 0 to infinity), d is the drag coefficient of the particle (range: 0 to infinity), and e is the elasticity of the particle (range: 0 to 1) . The material index for the particle is specified by k, as with shapes. Particles defined in this way have an infinite lifetime.

#particle_nozzle
    px py pz
    dx dy dz
    s m d e
    t r lt k

This command defines a particle nozzle. A nozzle is a point at (px,py,pz) that shoots particles int the direction (dx,dy,dz) with initial speed s and mass, drag, and elasticity values m, d, e. The angle t defines a cone centered on the velocity vector. Particles may be shot randomly anywhere inside this cone. The rate r is the number of particles created per second. lt is the lifetime of the particle, and k is the material of new particles.

#particle_box
    m11 m21 m31 m41
    m12 m22 m32 m42
    m13 m23 m33 m43
    m14 m24 m34 m44
    dx dy dz
    s m d e
    t r lt k

A particle box acts very similarly to a particle nozzle. The transformation matrix m specifies a transformation from the particle generation coordinates to world coordinates. Particles are created uniformly inside the cube (0,0,0), (1,1,1) in the particle box coordinates, then transformed into world coordinates. The direction vector (dx,dy,dz) is specified in world coordinates. The parameters t, r, lt, and k are defined as above.

#particle_sink
    px py pz
    f r1 r2

A particle sink is a point in space that attracts particles (if f is positive) or repels particles (if f is negative). f is the force on the particle at the sink point. As the distance from the center increases, the force is constant until r1. The force falls off with the square of the distance to the sink until r2. The force of the sink is zero outside the cutoff radius r2.

#particle_globals
    ux uy uz
    g d

This command specifies global parameters that affect all particles. The global up vector is (ux, uy, uz), and g is the gravitational constant. The gravitational force acts opposite of the up vector. Gravity acts in the -y direction by convention. d is the drag constant, which is multiplied by the individual drag coefficients of the particles.