示例#1
0
/* set rain particle values */
static void setpartrain(firestruct * fs, rain * r, float dt)
{
    r->age += dt;

    vadds(r->vel,dt,r->acc);
    vadds(r->pos,dt,r->vel);

    if(r->pos[0]<fs->min[0])
	r->pos[0]=fs->max[0]-(fs->min[0]-r->pos[0]);
    if(r->pos[2]<fs->min[2])
	r->pos[2]=fs->max[2]-(fs->min[2]-r->pos[2]);

    if(r->pos[0]>fs->max[0])
	r->pos[0]=fs->min[0]+(r->pos[0]-fs->max[0]);
    if(r->pos[2]>fs->max[2])
	r->pos[2]=fs->min[2]+(r->pos[2]-fs->max[2]);

    vequ(r->oldpos,r->pos);
    vadds(r->oldpos,-(r->partLength),r->vel);
    if(r->pos[1]<fs->min[1])
    	setnewrain(fs, r);
}
示例#2
0
/* initialise new rain particle */
static void setnewrain(firestruct * fs, rain * r)
{
    r->age=0.0f;

    vinit(r->acc,0.0f,-0.98f,0.0f);
    vinit(r->vel,0.0f,0.0f,0.0f);

    r->partLength=0.2f;

    vinit(r->oldpos,fs->min[0]+(fs->max[0]-fs->min[0])*vrnd(),
                    fs->max[1]+0.2f*fs->max[1]*vrnd(),
                    fs->min[2]+(fs->max[2]-fs->min[2])*vrnd());
    vequ(r->pos,r->oldpos);
    vadds(r->oldpos,-(r->partLength),r->vel);

    r->pos[1]=(fs->max[1]-fs->min[1])*vrnd()+fs->min[1];
    r->oldpos[1]=r->pos[1]-r->partLength*r->vel[1];
}
示例#3
0
static void
setpart(part * p)
{
   float fact;

   if (p->p[0][1] < 0.1) {
      setnewpart(p);
      return;
   }

   p->v[1] += AGRAV * dt;

   vadds(p->p[0], dt, p->v);
   vadds(p->p[1], dt, p->v);
   vadds(p->p[2], dt, p->v);

   p->age++;

   if ((p->age) > maxage) {
      vequ(p->c[0], blu2);
      vequ(p->c[1], blu2);
      vequ(p->c[2], blu2);
   }
   else {
      fact = 1.0 / maxage;
      vadds(p->c[0], fact, blu2);
      vclamp(p->c[0]);
      p->c[0][3] = fact * (maxage - p->age);

      vadds(p->c[1], fact, blu2);
      vclamp(p->c[1]);
      p->c[1][3] = fact * (maxage - p->age);

      vadds(p->c[2], fact, blu2);
      vclamp(p->c[2]);
      p->c[2][3] = fact * (maxage - p->age);
   }
}
示例#4
0
/* set fire particle values */
static void setpart(firestruct * fs, part * p)
{
    float fact;

    if (p->p[0][1] < 0.1) {
	setnewpart(fs, p);
	return;
    }

    p->v[1] += AGRAV * fs->dt;

    vadds(p->p[0], fs->dt, p->v);
    vadds(p->p[1], fs->dt, p->v);
    vadds(p->p[2], fs->dt, p->v);

    p->age++;

    if ((p->age) > fs->maxage) {
	vequ(p->c[0], partcol2);
	vequ(p->c[1], partcol2);
	vequ(p->c[2], partcol2);
    } else {
	fact = 1.0 / fs->maxage;
	vadds(p->c[0], fact, partcol2);
	vclamp(p->c[0]);
	p->c[0][3] = fact * (fs->maxage - p->age);

	vadds(p->c[1], fact, partcol2);
	vclamp(p->c[1]);
	p->c[1][3] = fact * (fs->maxage - p->age);

	vadds(p->c[2], fact, partcol2);
	vclamp(p->c[2]);
	p->c[2][3] = fact * (fs->maxage - p->age);
    }
}