Exemple #1
0
/*
===============
CL_ColorExplosionParticles
===============
*/
void CL_ColorExplosionParticles (vec3_t org, int color8, int run)
{
	int			i;
#ifdef QMAX
	vec3_t color = { color8red(color8), color8green(color8), color8blue(color8)};
#else
	int j;
	cparticle_t	*p;
#endif
	for (i=0 ; i<128 ; i++)
	{
#ifdef QMAX
setupParticle (
			0,	0,	0,
			org[0] + ((rand()%32)-16),	org[1] + ((rand()%32)-16),	org[2] + ((rand()%32)-16),
			(rand()%256)-128,	(rand()%256)-128,	(rand()%256)-128,
			0,		0,		20,
			color[0] + (rand() % run),	color[1] + (rand() % run),	color[2] + (rand() % run),
			0,	0,	0,
			1.0,		-0.4 / (0.6 + frand()*0.2),
			2,			1,			
			particle_generic,
			0,
			NULL,0);
#else
		if (!free_particles)
			return;
		p = free_particles;
		free_particles = p->next;
		p->next = active_particles;
		active_particles = p;

		p->time = cl.time;
		p->color = color8 + (rand() % run);
		for (j=0 ; j<3 ; j++)
		{
			p->org[j] = org[j] + ((rand()%32)-16);
			p->vel[j] = (rand()%256)-128;
		}

		p->accel[0] = p->accel[1] = 0;
		p->accel[2] = -PARTICLE_GRAVITY;
		p->alpha = 1.0;

		p->alphavel = -0.4 / (0.6 + frand()*0.2);
#endif
	}
}
void Attachment::drawParticles(bool force)
{
	glPushMatrix();

	if (model) {
		Model *m = static_cast<Model*>(model);
		if (!m)
			return;
		
		model->reset();
		setupParticle();

		// no need to scale if its already 100%
		if (scale != 1.0f)
			glScalef(scale, scale, scale);

		if (rot != Vec3D(0.0f, 0.0f, 0.0f))
			glRotatef(rot.y, 0.0f, 1.0f, 0.0f);

		//glRotatef(45.0f, 1,0,0);

		if (pos != Vec3D(0.0f, 0.0f, 0.0f))
			glTranslatef(pos.x, pos.y, pos.z);

		if (force)
			m->drawParticles();
		else if (m->hasParticles && m->showParticles) 
			m->drawParticles();
				
	}
	
	// children:
	for (size_t i=0; i<children.size(); i++)
		children[i]->drawParticles();

	glPopMatrix();
}
void LLHUDEffectBeam::render()
{
	if (!mSourceObject)
	{
		markDead();
		return;
	}
	if (mSourceObject->isDead())
	{
		markDead();
		return;
	}

	F32 time = mTimer.getElapsedTimeF32();

	// Kill us if our time is over...
	if (mKillTime < time)
	{
		markDead();
		return;
	}

	LLGLSPipelineAlpha gls_pipeline_alpha;
	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);


	// Interpolate the global fade alpha
	mFadeInterp.update(time);

	if (mTargetObject.notNull() && mTargetObject->mDrawable.notNull())
	{
		// use viewer object position on freshly created objects
		if (mTargetObject->mDrawable->getGeneration() == -1)
		{
			mTargetPos = mTargetObject->getPositionGlobal();
		}
		// otherwise use drawable
		else
		{
			mTargetPos = gAgent.getPosGlobalFromAgent(mTargetObject->mDrawable->getPositionAgent());
		}
	}


	// Init the color of the particles
	LLColor4U coloru = mColor;

	// Draw the particles
	S32 i;
	for (i = 0; i < NUM_POINTS; i++)
	{
		mInterp[i].update(time);
		if (!mInterp[i].isActive())
		{
			continue;
		}
		mInterpFade[i].update(time);

		if (mInterp[i].isDone())
		{
			// Reinitialize the particle when the particle has finished its animation.
			setupParticle(i);
		}

		F32 frac = mInterp[i].getCurFrac();
		F32 scale = 0.025f + fabs(0.05f*sin(2.f*F_PI*(frac - time)));
		scale *= mInterpFade[i].getCurVal();

		LLVector3 pos_agent = gAgent.getPosAgentFromGlobal(mInterp[i].getCurVal());

		F32 alpha = mFadeInterp.getCurVal()*mColor.mV[3];
		alpha *= mInterpFade[i].getCurVal();
		coloru.mV[3] = (U8)alpha;
		glColor4ubv(coloru.mV);

		glPushMatrix();
		glTranslatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]);
		glScalef(scale, scale, scale);
		gSphere.render(0);
		glPopMatrix();
	}
}
Exemple #4
0
void CL_Heatbeam (vec3_t start, vec3_t end)
{
	vec3_t		move;
	vec3_t		vec;
	float		len;
	int			j,k;
	cparticle_t	*p;
	vec3_t		right, up;
	int			i;
	float		d, c, s;
	vec3_t		dir;
	float		ltime;
	float		step = 5.0;

	VectorCopy (start, move);
	VectorSubtract (end, start, vec);
	len = VectorNormalize (vec);

//	MakeNormalVectors (vec, right, up);
	VectorCopy (cl.v_right, right);
	VectorCopy (cl.v_up, up);
	VectorMA (move, -1, right, move);
	VectorMA (move, -1, up, move);

	VectorScale (vec, step, vec);
	ltime = (float) cl.time/1000.0;

//	for (i=0 ; i<len ; i++)
	for (i=0 ; i<len ; i+=step)
	{
		d = i * 0.1 - fmod(ltime,16.0)*M_PI;
		c = cos(d)/1.75;
		s = sin(d)/1.75;
#ifdef DOUBLE_SCREW		
		for (k=-1; k<2; k+=2)
		{
#else
		k=1;
#endif
			if (!free_particles)
				return;

			p = free_particles;
			free_particles = p->next;
			p->next = active_particles;
			active_particles = p;
			
			p->time = cl.time;
			VectorClear (p->accel);

			p->alpha = 0.5;
	//		p->alphavel = -1.0 / (1+frand()*0.2);
			// only last one frame!
			p->alphavel = INSTANT_PARTICLE;
	//		p->color = 0x74 + (rand()&7);
//			p->color = 223 - (rand()&7);
#ifndef QMAX
			p->color = 223;
#endif
//			p->color = 240;

			// trim it so it looks like it's starting at the origin
			if (i < 10)
			{
				VectorScale (right, c*(i/10.0)*k, dir);
				VectorMA (dir, s*(i/10.0)*k, up, dir);
			}
			else
			{
				VectorScale (right, c*k, dir);
				VectorMA (dir, s*k, up, dir);
			}
#ifdef QMAX
			setupParticle (
				       0,	0,	0,
				       move[0]+dir[0]*3,	move[1]+dir[1]*3,	move[2]+dir[2]*3,
				       0,	0,	0,
				       0,		0,		0,
				       200+rand()*50,	200+rand()*25,	rand()*50,
				       0,	0,	0,
				       0.5,		-1000.0,
				       3,			1,			
				       particle_blaster,
				       0,
				       NULL,0);	
#else		
			for (j=0 ; j<3 ; j++)
			{
				p->org[j] = move[j] + dir[j]*3;
	//			p->vel[j] = dir[j]*6;
				p->vel[j] = 0;
			}
#endif
#ifdef DOUBLE_SCREW
		}
#endif
		VectorAdd (move, vec, move);
	}
}
Exemple #5
0
/*
===============
CL_BubbleTrail2 (lets you control the # of bubbles by setting the distance between the spawns)

===============
*/
void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist)
{
	vec3_t		move;
	vec3_t		vec;
	float		len;
	int			i;
#ifndef QMAX
	int j;
	cparticle_t	*p;
#endif
	float		dec;

	VectorCopy (start, move);
	VectorSubtract (end, start, vec);
	len = VectorNormalize (vec);

	dec = dist;
	VectorScale (vec, dec, vec);

	for (i=0 ; i<len ; i+=dec)
	{
#ifdef QMAX
		setupParticle (
			0,	0,	0,
			move[0]+crand()*2,	move[1]+crand()*2,	move[2]+crand()*2,
			crand()*5,	crand()*5,	crand()*5+6,
			0,		0,		0,
			255,	255,	255,
			0,	0,	0,
			0.75,		-1.0 / (1 + frand() * 0.2),
			(frand()>0.25)? 1 : (frand()>0.5) ? 2 : (frand()>0.75) ? 3 : 4,			1,			
			particle_bubble,
			PART_TRANS|PART_SHADED,
			NULL,0);
#else
		if (!free_particles)
		  return;
		
		p = free_particles;
		free_particles = p->next;
		p->next = active_particles;
		active_particles = p;

		VectorClear (p->accel);
		p->time = cl.time;

		p->alpha = 1.0;
		p->alphavel = -1.0 / (1+frand()*0.1);
		p->color = 4 + (rand()&7);
		for (j=0 ; j<3 ; j++)
		{
			p->org[j] = move[j] + crand()*2;
			p->vel[j] = crand()*10;
		}
		p->org[2] -= 4;
//		p->vel[2] += 6;
		p->vel[2] += 20;
#endif
		VectorAdd (move, vec, move);
	}
}
Exemple #6
0
void CL_ForceWall (vec3_t start, vec3_t end, int color8)
{
	vec3_t		move;
	vec3_t		vec;
#ifdef QMAX
	vec3_t color = { color8red(color8), color8green(color8), color8blue(color8)};
#else
	int			j;
	cparticle_t	*p;
#endif

	float		len;

	VectorCopy (start, move);
	VectorSubtract (end, start, vec);
	len = VectorNormalize (vec);

	VectorScale (vec, 4, vec);

	// FIXME: this is a really silly way to have a loop
	while (len > 0)
	{
		len -= 4;

		if (!free_particles)
			return;
		
		if (frand() > 0.3)
		{
#ifdef QMAX
		  setupParticle (
				 0,	0,	0,
				 move[0] + crand()*3,	move[1] + crand()*3,	move[2] + crand()*3,
				 0,	0,	-40 - (crand()*10),
				 0,		0,		0,
				 color[0]+5,	color[1]+5,	color[2]+5,
				 0,	0,	0,
				 1,		-1.0 / (3.0+frand()*0.5),
				 5,			0,			
				 particle_generic,
				 0,
				 NULL,0);
#else	
		  p = free_particles;
		  free_particles = p->next;
		  p->next = active_particles;
		  active_particles = p;
		  VectorClear (p->accel);
		  
		  p->time = cl.time;
		  
		  p->alpha = 1.0;
		  p->alphavel =  -1.0 / (3.0+frand()*0.5);
		  p->color = color8;
		  for (j=0 ; j<3 ; j++)
		    {
		      p->org[j] = move[j] + crand()*3;
		      p->accel[j] = 0;
		    }
		  p->vel[0] = 0;
		  p->vel[1] = 0;
		  p->vel[2] = -40 - (crand()*10);
#endif

		}

		VectorAdd (move, vec, move);
	}
}
Exemple #7
0
/*
======
CL_DebugTrail
======
*/
void CL_DebugTrail (vec3_t start, vec3_t end)
{
	vec3_t		move;
	vec3_t		vec;
	float		len;
#ifndef QMAX
	cparticle_t	*p;
#endif
	float		dec;
	vec3_t		right, up;

	VectorCopy (start, move);
	VectorSubtract (end, start, vec);
	len = VectorNormalize (vec);

	MakeNormalVectors (vec, right, up);

//	VectorScale(vec, RT2_SKIP, vec);

//	dec = 1.0;
//	dec = 0.75;
	dec = 3;
	VectorScale (vec, dec, vec);
	VectorCopy (start, move);

	while (len > 0)
	{
		len -= dec;
#ifdef QMAX
		setupParticle (
			0,	0,	0,
			move[0],	move[1],	move[2],
			0,	0,	0,
			0,		0,		0,
			50,	50,	255,
			0,	0,	0,
			1,		-0.75,
			7.5,			0,			
			particle_generic,
			0,
			NULL,0);
#else
		if (!free_particles)
			return;
		p = free_particles;
		free_particles = p->next;
		p->next = active_particles;
		active_particles = p;

		p->time = cl.time;
		VectorClear (p->accel);
		VectorClear (p->vel);
		p->alpha = 1.0;
		p->alphavel = -0.1;
//		p->alphavel = 0;
		p->color = 0x74 + (rand()&7);
		VectorCopy (move, p->org);
		/*
		for (j=0 ; j<3 ; j++)
		{
			p->org[j] = move[j] + crand()*2;
			p->vel[j] = crand()*3;
			p->accel[j] = 0;
		}
		*/
#endif
		VectorAdd (move, vec, move);
	}

}