VECTOR Weatherbox;
VECTOR Wind_direction; //Movement speed and direction
function Weather_part_event(PARTICLE *p)
{
//keep the particle within the box
vec_set(my.x,vector(cycle(my.x,camera.x-Weatherbox.x,camera.x+Weatherbox.x),
cycle(my.y,camera.y-Weatherbox.y,camera.y+Weatherbox.y),
cycle(my.z,camera.z-Weatherbox.z,camera.z+Weatherbox.z)));
//update the movement speed and direction
vec_set(p.vel_x,vector(Wind_direction.x,Wind_direction.y,Wind_direction.z));
p.lifespan = 100; // live forever
}
function Weather_part(PARTICLE *p)
{
//place particles at random positions within the box
vec_set(my.x,vector(camera.x+random(Weatherbox.x*2)-Weatherbox.x,
camera.y+random(Weatherbox.y*2)-Weatherbox.y,
camera.z+random(Weatherbox.z*2)-Weatherbox.z));
p.bmap = rainParticle;
p.size = random(1)+2;
p.flags |= MOVE;
p.event = Weather_part_event;
}
function CreateWeatherParticles()
{
Wind_direction.x = 0;
Wind_direction.y = 0;
Wind_direction.z = -20;
Weatherbox.x = 1000/2;
Weatherbox.y = 1000/2;
Weatherbox.z = 1000/2;
effect(Weather_part,500,nullvector,nullvector);
}