Esempio n. 1
0
/*
================
CG_AddFireEffect
================
*/
static void CG_AddFireEffect( localEntity_t *le ) {
	refEntity_t			*re;
	trace_t				trace;

	re = &le->refEntity;

	if ( le->pos.trType == TR_STATIONARY ) {
		if ( le->leFlags & LEF_LESSOVERDRAW ) {
			// avoid too much overdraw
			if ( CG_NearbyDrawnLeCount( le, re->origin, le->leType, 52 + !!cg_lowDetailEffects.integer * 24 ) > 0 ) return;
		}
		// add to refresh list
		trap_R_AddRefEntityToScene( re );
		return;
	}

	// calculate position
	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// check for water
	if ( trap_CM_PointContents( re->origin, 0 ) & CONTENTS_WATER ) {
		// do a trace to get water surface normals
		CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_WATER );
		CG_FreeLocalEntity( le );

		CG_MakeExplosion( trace.endpos, trace.plane.normal, 
			cgs.media.ringFlashModel, cgs.media.vaporShader,
			500, qfalse, qtrue );
		return;
	}

	// do a trace sometimes
	if ( le->ti.trailTime++ > 5 ) {
		le->ti.trailTime = 0;

		CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_SHOT );
		VectorCopy( trace.endpos, re->origin );
		VectorCopy( trace.endpos, re->oldorigin );

		// hit something
		if ( trace.fraction < 1.0 ) {
			// free le if another one is nearby, otherwise make it stationary
			if ( CG_CheckDistance( re->origin, le->leType, TR_STATIONARY, re->customShader, 200, 32 ) ) { 
				CG_FreeLocalEntity( le );
				return;
			} else {
				le->pos.trType = TR_STATIONARY;
			}
		}
	}

	if ( le->leFlags & LEF_LESSOVERDRAW ) {
		// avoid too much overdraw
		if ( CG_NearbyDrawnLeCount( le, re->origin, le->leType, 52 + !!cg_lowDetailEffects.integer * 24 ) > 0 ) return;
	}

	// add to refresh list
	trap_R_AddRefEntityToScene( re );
}
Esempio n. 2
0
void CG_AddGore( localEntity_t *le ) {
	vec3_t	newOrigin;
	trace_t	trace;

	if ( le->pos.trType == TR_STATIONARY ) {
		// sink into the ground if near the removal time
		//int		t;
		//float	oldZ;
		
		CG_FreeLocalEntity( le ); // kill it

		return;
	}

	// calculate new position
	BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );

	// trace a line from previous position to new position
	CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );
	if ( trace.fraction == 1.0 ) {
		// still in free fall
		VectorCopy( newOrigin, le->refEntity.origin );

		if ( le->leFlags & LEF_TUMBLE ) {
			vec3_t angles;

			BG_EvaluateTrajectory( &le->angles, cg.time, angles );
			AnglesToAxis( angles, le->refEntity.axis );
		}

		trap_R_AddRefEntityToScene( &le->refEntity );

		CG_SmallBloodTrail( le );
	
		return;
	}

	// if it is in a nodrop zone, remove it
	// this keeps gibs from waiting at the bottom of pits of death
	// and floating levels
	if ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {
		CG_FreeLocalEntity( le );
		return;
	}

	// leave a mark
	CG_GoreMark( le, &trace );

	// do a juicy sound
	CG_SplatSound( le, &trace );

	CG_JustSplat( le, &trace );

	trap_R_AddRefEntityToScene( &le->refEntity );
}
Esempio n. 3
0
/*
===================
CG_AddRefEntity
===================
*/
void CG_AddRefEntity( localEntity_t *le ) {
	if (le->endTime < cg.time) {
		CG_FreeLocalEntity( le );
		return;
	}
	CG_AddRefEntityWithMinLight( &le->refEntity );
}
Esempio n. 4
0
/*
==================
CG_AddPuff
==================
*/
static void CG_AddPuff( localEntity_t *le ) {
	refEntity_t	*re;
	float		c;
	vec3_t		delta;
	float		len;

	re = &le->refEntity;

	// fade / grow time
	c = ( le->endTime - cg.time ) / (float)( le->endTime - le->startTime );

	re->shaderRGBA[0] = le->color[0] * c;
	re->shaderRGBA[1] = le->color[1] * c;
	re->shaderRGBA[2] = le->color[2] * c;

	if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {
		re->radius = le->radius * ( 1.0 - c ) + 8;
	}

	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	trap->R_AddRefEntityToScene( re );
}
Esempio n. 5
0
/*
================
CG_ResetMissileEntity
================
*/
void CG_ResetMissileEntity( centity_t *cent ) {	
	// link trajectory
	cent->ti.trPos = &cent->currentState.pos;
	cent->ti.weapon = cent->currentState.weapon;

	// check for predicted missiles if necessary
	if ( cg.predictWeapons && cent->currentState.clientNum == cg.snap->ps.clientNum ) {
		localEntity_t	*le;

		le = cg_activeLocalEntities.prev;
		for ( ; le != &cg_activeLocalEntities ; le = le->prev ) {
			// the first (and oldest) missile le is the one represented by the new one
			if ( le->leType == LE_MISSILE && weLi[le->ti.weapon].prediction != PR_FLAME ) {
				// set the correct trailTime
				cent->ti.trailTime = le->ti.trailTime;
				VectorCopy( le->ti.lastPos, cent->ti.lastPos );

				// free the local entity
				CG_FreeLocalEntity( le );
				return;
			}
		}	
	}
	// there isn't a predicted missile, use normal trailTime reset
	cent->ti.trailTime = cent->currentState.pos.trTime + TRAIL_DELAY;
	BG_EvaluateTrajectory( cent->ti.trPos, cent->ti.trailTime, cent->ti.lastPos );
}
Esempio n. 6
0
/*
=================
CG_AddFallScaleFade

This is just an optimized CG_AddMoveScaleFade
For blood mists that drift down, fade out, and are
removed if the view passes through them.
There are often 100+ of these, so it needs to be simple.
=================
*/
static void CG_AddFallScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	gfixed		c;
	bvec3_t		delta;
	bfixed		len;

	re = &le->refEntity;

	// fade time
	c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;

	re->shaderRGBA[3] = FIXED_TO_INT(GFIXED(255,0) * c * le->color[3]);

	re->origin[2] = le->pos.trBase[2] - MAKE_BFIXED( GFIXED_1 - c ) * le->pos.trDelta[2];

	re->radius = le->radius * MAKE_BFIXED( GFIXED_1 - c ) + BFIXED(16,0);

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = FIXED_VEC3LEN( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	_CG_trap_R_AddRefEntityToScene( re );
}
Esempio n. 7
0
/*
===================
CG_AllocLocalEntity

Will allways succeed, even if it requires freeing an old active entity
===================
*/
localEntity_t	*CG_AllocLocalEntity( void ) {
	localEntity_t	*le;

	if ( !cg_freeLocalEntities ) {
		// no free entities, so free the one at the end of the chain
		// remove the oldest active entity
		CG_FreeLocalEntity( cg_activeLocalEntities.prev );
	}

	// Ridah, debugging
	localEntCount++;
//	trap_Print( va("AllocLocalEntity: locelEntCount = %d\n", localEntCount) );
	// done.

	le = cg_freeLocalEntities;
	cg_freeLocalEntities = cg_freeLocalEntities->next;

	memset( le, 0, sizeof( *le ) );

	// link into the active list
	le->next = cg_activeLocalEntities.next;
	le->prev = &cg_activeLocalEntities;
	cg_activeLocalEntities.next->prev = le;
	cg_activeLocalEntities.next = le;
	return le;
}
Esempio n. 8
0
/*
=================
CG_AddFallScaleFade

This is just an optimized CG_AddMoveScaleFade
For blood mists that drift down, fade out, and are
removed if the view passes through them.
There are often 100+ of these, so it needs to be simple.
=================
*/
static void CG_AddFallScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	float		c;
	vec3_t		delta;
	float		len;

	re = &le->refEntity;

	// fade time
	c = ( le->endTime - cg.time ) * le->lifeRate;

	re->shaderRGBA[3] = 0xff * c * le->color[3];

	re->origin[2] = le->pos.trBase[2] - ( 1.0 - c ) * le->pos.trDelta[2];

	re->radius = le->radius * ( 1.0 - c ) + 16;

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	trap->R_AddRefEntityToScene( re );
}
Esempio n. 9
0
void CG_AddRefEntity( localEntity_t *le ) {
	if ( le->endTime < cg.time ) {
		CG_FreeLocalEntity( le );
		return;
	}
	SE_R_AddRefEntityToScene( &le->refEntity, MAX_CLIENTS );
}
Esempio n. 10
0
// For forcefields/other rectangular things
void CG_AddOLine( localEntity_t *le ) {
	refEntity_t	*re;
	float		frac, alpha;

	re = &le->refEntity;

	frac = (cg.time - le->startTime) / (float)(le->endTime - le->startTime);
	if ( frac > 1 )
		frac = 1.0f;	// can happen during connection problems
	else if ( frac < 0 )
		frac = 0.0f;

	// Use the liferate to set the scale over time.
	re->data.line.width = le->data.line.width + (le->data.line.dwidth * frac);
	if ( re->data.line.width <= 0 ) {
		CG_FreeLocalEntity( le );
		return;
	}

	// We will assume here that we want additive transparency effects.
	alpha = le->alpha + (le->dalpha * frac);
	re->shaderRGBA[0] = 0xff * alpha;
	re->shaderRGBA[1] = 0xff * alpha;
	re->shaderRGBA[2] = 0xff * alpha;
	re->shaderRGBA[3] = 0xff * alpha;	// Yes, we could apply c to this too, but fading the color is better for lines.

	re->shaderTexCoord.x = 1;
	re->shaderTexCoord.y = 1;

	re->rotation = 90;

	re->reType = RT_ORIENTEDLINE;

	SE_R_AddRefEntityToScene( re, MAX_CLIENTS );
}
Esempio n. 11
0
/*
===================
CG_AddRefEntity
===================
*/
void CG_AddRefEntity( localEntity_t *le ) {
	if (le->endTime < cg.time) {
		CG_FreeLocalEntity( le );
		return;
	}
	trap->R_AddRefEntityToScene( &le->refEntity );
}
Esempio n. 12
0
// For rocket smokes that hang in place, fade out, and are removed if the view passes through them.
//	There are often many of these, so it needs to be simple.
static void CG_AddScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	float		c;
	vector3		delta;
	float		len;
	refdef_t *refdef = CG_GetRefdef();

	re = &le->refEntity;

	// fade / grow time
	c = (le->endTime - cg.time) * le->lifeRate;

	re->shaderRGBA[3] = 0xff * c * le->color[3];
	re->radius = le->radius * (1.0f - c) + 8;

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( &re->origin, &refdef->vieworg, &delta );
	len = VectorLength( &delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	SE_R_AddRefEntityToScene( re, MAX_CLIENTS );
}
Esempio n. 13
0
/*
===================
CG_AddScaleFade

For rocket smokes that hang in place, fade out, and are
removed if the view passes through them.
There are often many of these, so it needs to be simple.
===================
*/
static void CG_AddScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	float		c;
	vec3_t		delta;
	float		len;

	re = &le->refEntity;

	// fade / grow time
	c = ( le->endTime - cg.time ) * le->lifeRate;

	re->shaderRGBA[3] = 0xff * c * le->color[3];
	re->radius = le->radius * ( 1.0 - c ) + 8;

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	CG_AddRefEntityWithMinLight( re );
}
Esempio n. 14
0
/*
===================
CG_AddLine2

For trek, for beams and the like.
===================
*/
void CG_AddLine2( localEntity_t *le )
{
	refEntity_t	*re;
	float		frac, alpha;
	vec3_t		curRGB;

	re = &le->refEntity;

	frac = (cg.time - le->startTime) / ( float ) ( le->endTime - le->startTime );
	if ( frac > 1 ) 
		frac = 1.0;	// can happen during connection problems
	else if (frac < 0)
		frac = 0.0;

	// Use the liferate to set the scale over time.
	re->data.line.width = le->data.line2.width + (le->data.line2.dwidth * frac);
	re->data.line.width2 = le->data.line2.width2 + (le->data.line2.dwidth2 * frac);
	if (re->data.line.width <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}

	// We will assume here that we want additive transparency effects.
	alpha = le->alpha + (le->dalpha * frac);
	VectorMA(le->data.line2.startRGB, frac, le->data.line2.dRGB, curRGB);
	re->shaderRGBA[0] = 0xff * alpha * curRGB[0];
	re->shaderRGBA[1] = 0xff * alpha * curRGB[1];
	re->shaderRGBA[2] = 0xff * alpha * curRGB[2];
	re->shaderRGBA[3] = 0xff * alpha;	// Yes, we could apply c to this too, but fading the color is better for lines.

	re->reType = RT_LINE2;

	trap_R_AddRefEntityToScene( re );
}
Esempio n. 15
0
// This is just an optimized CG_AddMoveScaleFade for blood mists that drift down, fade out, and are removed if the view passes through them.
//	There are often 100+ of these, so it needs to be simple.
static void CG_AddFallScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	float		c;
	vector3		delta;
	float		len;

	re = &le->refEntity;

	// fade time
	c = ( le->endTime - cg.time ) * le->lifeRate;

	re->shaderRGBA[3] = (byte)(255 * c * le->color.a);

	re->origin.z = le->pos.trBase.z - ( 1.0f - c ) * le->pos.trDelta.z;

	re->radius = le->radius * ( 1.0f - c ) + 16;

	// if the view would be "inside" the sprite, kill the sprite so it doesn't add too much overdraw
	VectorSubtract( &re->origin, &cg.refdef.vieworg, &delta );
	len = VectorLength( &delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	trap->R_AddRefEntityToScene( re );
}
Esempio n. 16
0
/*
==================
CG_AddMoveScaleFade
==================
*/
void CG_AddMoveScaleFade( localEntity_t *le )
{
	refEntity_t	*re;
	float		c;
	vec3_t		delta;
	float		len;

	re = &le->refEntity;

	// fade / grow time
	c = ( le->endTime - cg.time ) * le->lifeRate;

	re->shaderRGBA[3] = 0xff * c * le->color[3];

	if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {
		re->data.sprite.radius = le->data.sprite.radius * ( 1.0 - c ) + 8;
	}

	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->data.sprite.radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	trap_R_AddRefEntityToScene( re );
}
Esempio n. 17
0
/*
===================
CG_AddQuad

Of Trek, by Trek, and for Trek
===================
*/
void CG_AddQuad( localEntity_t *le )
{
	refEntity_t	*re;
	float		frac, alpha;
	vec3_t		delta;
	float		len;
	vec3_t		curRGB;

	re = &le->refEntity;

	frac = ( cg.time - le->startTime ) / ( float ) ( le->endTime - le->startTime );
	if ( frac > 1 )
		frac = 1.0;	// can happen during connection problems
	else if (frac < 0)
		frac = 0.0;

	// Use the liferate to set the scale over time.
	re->data.sprite.radius = le->data.sprite.radius + (le->data.sprite.dradius*frac);
	if (re->data.sprite.radius <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->data.sprite.radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	// Calculate the current alpha.
	alpha = le->alpha + (le->dalpha * frac);
	VectorMA(le->data.sprite.startRGB, frac, le->data.sprite.dRGB, curRGB);
	re->shaderRGBA[0] = 0xff * alpha * curRGB[0];
	re->shaderRGBA[1] = 0xff * alpha * curRGB[1];
	re->shaderRGBA[2] = 0xff * alpha * curRGB[2];
	re->shaderRGBA[3] = 0xff;	

	re->reType = RT_ORIENTEDSPRITE;

	trap_R_AddRefEntityToScene( re );
}
Esempio n. 18
0
static void CG_AddSpawner( localEntity_t *le ) 
{
	refEntity_t	*re;
	vec3_t		dir;
	trace_t		trace;

	re = &le->refEntity;
	if (le->leFlags & LEF_MOVE)
	{
		// kef -- do these two lines _before_ copying origin into oldorigin
		VectorSubtract(re->oldorigin, re->origin, dir);
		VectorNormalize(dir);

		VectorCopy(re->origin, re->oldorigin);
		BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

		if (le->leFlags & LEF_USE_COLLISION)
		{
			// trace a line from previous position to new position
			CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, -1, CONTENTS_SOLID );

			if ( trace.fraction != 1.0 ) 
			{	// Hit something.
				// if it is in a nodrop zone, remove it
				// this keeps gibs from waiting at the bottom of pits of death
				// and floating levels
				if ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {
					CG_FreeLocalEntity( le );
					return;
				}

				// reflect the velocity on the trace plane
				CG_ReflectVelocity( le, &trace );
			}
			VectorSubtract(re->oldorigin, re->origin, dir);
			VectorNormalize(dir);
		}
	}

	// kef -- here's where I, in my infinite wisdom, have decided to emulate the singleplayer
	//particle think function
	if (cg.time < le->data.spawner.nextthink)
	{
		return;
	}
	le->data.spawner.nextthink = cg.time + (le->data.spawner.delay + 
		(le->data.spawner.delay*flrandom(-le->data.spawner.variance,le->data.spawner.variance)));

	if (le->data.spawner.thinkFn)
	{
		le->data.spawner.thinkFn(le);
	}
	if (le->data.spawner.dontDie)
	{
		le->endTime = le->endTime + 10000;
	}
}
Esempio n. 19
0
/*
===================
CG_AddCylinder

For trek, cylinder primitive.
===================
*/
void CG_AddCylinder( localEntity_t *le )
{
	refEntity_t	*re;
	float		frac, alpha;

	re = &le->refEntity;

	frac = ( cg.time - le->startTime ) / ( float ) ( le->endTime - le->startTime );
	if ( frac > 1 )
		frac = 1.0;	// can happen during connection problems
	else if (frac < 0)
		frac = 0.0;

	// Use the liferate to set the scale over time.
	re->data.cylinder.height = le->data.cylinder.height + (le->data.cylinder.dheight*frac);
	if (re->data.cylinder.height <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}
	re->data.cylinder.width = le->data.cylinder.width + (le->data.cylinder.dwidth*frac);
	if (re->data.cylinder.width <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}
	re->data.cylinder.width2 = le->data.cylinder.width2 + (le->data.cylinder.dwidth2*frac);
	if (re->data.cylinder.width2 <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}

	// Calculate the current alpha.
	alpha = le->alpha + (le->dalpha * frac);
	re->shaderRGBA[0] = 0xff * alpha;
	re->shaderRGBA[1] = 0xff * alpha;
	re->shaderRGBA[2] = 0xff * alpha;
	re->shaderRGBA[3] = 0xff;	

	re->reType = RT_CYLINDER;

	trap_R_AddRefEntityToScene( re );
}
Esempio n. 20
0
/*
===================
CG_AddScaleFadeSprite

For trek, oriented sprites like blast rings and the like.
===================
*/
void CG_AddScaleFadeSprite( localEntity_t *le )
{
	refEntity_t	*re;
	float		c;
	vec3_t		delta;
	float		len;

	re = &le->refEntity;

	c = ( le->endTime - cg.time ) / ( float ) ( le->endTime - le->startTime );
	if ( c > 1 ) {
		c = 1.0;	// can happen during connection problems
	}

	// Use the liferate to set the scale over time.
	re->data.sprite.radius = le->data.sprite.radius + (le->lifeRate * (cg.time - le->startTime));
	if (re->data.sprite.radius <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->data.sprite.radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	// We will assume here that we want additive transparency effects.
	re->shaderRGBA[0] = 0xff * c;
	re->shaderRGBA[1] = 0xff * c;
	re->shaderRGBA[2] = 0xff * c;
	re->shaderRGBA[3] = 0xff * le->color[3];

	re->reType = RT_ORIENTEDSPRITE;

	trap_R_AddRefEntityToScene( re );
}
Esempio n. 21
0
/*
===================
CG_AddBezier

For trek, for the imod and the...uh...imod.

===================
*/
void CG_AddBezier( localEntity_t *le )
{
	refEntity_t	*re;
	float		frac, alpha;
	float		t = (cg.time - le->startTime)*0.001; // time elapsed since beginning of effect
	vec3_t		vTempPos;

	re = &le->refEntity;

	frac = (cg.time - le->startTime) / ( float ) ( le->endTime - le->startTime );
	if ( frac > 1 ) 
		frac = 1.0;	// can happen during connection problems
	else if (frac < 0)
		frac = 0.0;

	// Use the liferate to set the scale over time.
	re->data.bezier.width = le->data.line.width + (le->data.line.dwidth * frac);
	if (re->data.bezier.width <= 0)
	{
		CG_FreeLocalEntity( le );
		return;
	}

	// We will assume here that we want additive transparency effects.
	alpha = le->alpha + (le->dalpha * frac);
	re->shaderRGBA[0] = 0xff * alpha;
	re->shaderRGBA[1] = 0xff * alpha;
	re->shaderRGBA[2] = 0xff * alpha;
	re->shaderRGBA[3] = 0xff;	// Yes, we could apply c to this too, but fading the color is better for lines.

	re->reType = RT_BEZIER;

	// the refEntity only stores the two control points, so we need to update them here with 
	//the control_velocity and control_acceleration, then store the results in refEntity. 
	//use (cg.time - le->startTime) as a value for elapsed time t, plug it into the position formula:
	//
	// x = x0 + (v0 * t) + (0.5 * a * t * t)
	//
	//...where x is the position at time t, x0 is initial control point position, v0 is control point velocity,
	//and a is control point acceleration
	//

	// update control point 1
	VectorMA(le->data.line.control1, t, le->data.line.control1_velocity, vTempPos);
	VectorMA(vTempPos, (0.5*t*t), le->data.line.control1_acceleration, re->data.bezier.control1);

	// update control point 2
	VectorMA(le->data.line.control2, t, le->data.line.control2_velocity, vTempPos);
	VectorMA(vTempPos, (0.5*t*t), le->data.line.control2_acceleration, re->data.bezier.control2);

	trap_R_AddRefEntityToScene( re );
}
Esempio n. 22
0
/*
* CG_FreeLocalEntities
*/
void CG_FreeLocalEntities( void )
{
	lentity_t *le, *next, *hnode;

	hnode = &cg_localents_headnode;
	for( le = hnode->next; le != hnode; le = next )
	{
		next = le->next;

		le->type = LE_FREE;
		CG_FreeLocalEntity( le );
	}

	CG_ClearLocalEntities();
}
Esempio n. 23
0
/*
=======================================================================================================================================
CG_BubbleThink
=======================================================================================================================================
*/
void CG_BubbleThink(localEntity_t *le) {
	int contents;
	vec3_t newOrigin;
	trace_t trace;

	// calculate new position
	BG_EvaluateTrajectory(&le->pos, cg.time, newOrigin);
	// trace a line from previous position to new position
	CG_Trace(&trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID);

	contents = CG_PointContents(trace.endpos, -1);

	if (!(contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))) {
		// bubble isn't in liquid anymore, remove it
		CG_FreeLocalEntity(le);
		return;
	}

	CG_AddMoveScaleFade(le);
}
Esempio n. 24
0
/*
===================
CG_AllocLocalEntity

Will allways succeed, even if it requires freeing an old active entity
===================
*/
localEntity_t	*CG_AllocLocalEntity( void ) {
	localEntity_t	*le;

	if ( !cg_freeLocalEntities ) {
		// no free entities, so free the one at the end of the chain
		// remove the oldest active entity
		CG_FreeLocalEntity( cg_activeLocalEntities.prev );
	}

	le = cg_freeLocalEntities;
	cg_freeLocalEntities = cg_freeLocalEntities->next;

	memset( le, 0, sizeof( *le ) );

	// link into the active list
	le->next = cg_activeLocalEntities.next;
	le->prev = &cg_activeLocalEntities;
	cg_activeLocalEntities.next->prev = le;
	cg_activeLocalEntities.next = le;
	return le;
}
Esempio n. 25
0
//---------------------------------------------------
static void CG_AddFadeModel( localEntity_t *le )
{
	refEntity_t	*ent = &le->refEntity;

	if ( cg.time < le->startTime )
	{
		CG_FreeLocalEntity( le );
		return;
	}

	float frac = 1.0f - ((float)( cg.time - le->startTime )/(float)( le->endTime - le->startTime ));

	ent->shaderRGBA[0] = le->color[0] * frac;
	ent->shaderRGBA[1] = le->color[1] * frac;
	ent->shaderRGBA[2] = le->color[2] * frac;
	ent->shaderRGBA[3] = le->color[3] * frac;

	EvaluateTrajectory( &le->pos, cg.time, ent->origin );

	// add the entity
	cgi_R_AddRefEntityToScene( ent );
}
Esempio n. 26
0
static void CG_AddMoveScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	float		c;
	vector3		delta;
	float		len;
	refdef_t *refdef = CG_GetRefdef();

	re = &le->refEntity;

	if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {
		// fade / grow time
		c = 1.0f - (float)(le->fadeInTime - cg.time) / (le->fadeInTime - le->startTime);
	}
	else {
		// fade / grow time
		c = (le->endTime - cg.time) * le->lifeRate;
	}

	re->shaderRGBA[3] = 0xff * c * le->color[3];

	if ( !(le->leFlags & LEF_PUFF_DONT_SCALE) ) {
		re->radius = le->radius * (1.0f - c) + 8;
	}

	BG_EvaluateTrajectory( &le->pos, cg.time, &re->origin );

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( &re->origin, &refdef->vieworg, &delta );
	len = VectorLength( &delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	SE_R_AddRefEntityToScene( re, MAX_CLIENTS );
}
Esempio n. 27
0
void CG_AddPressureEntity(localEntity_t * le)
{
	vec3_t velocity;
//	vec3_t origin;
	float alpha;

	// Kill it if LCA.
	if (cg.lca)
		CG_FreeLocalEntity(le);

	alpha = -(cg.time - le->startTime) + (le->endTime - le->startTime);
	alpha /= (le->endTime - le->startTime);

	//steamSound!!!

	// steam:
	if ( le->leFlags != LEF_AIR && le->leFlags != LEF_WATER ) {
		VectorScale(le->pos.trDelta, le->size + rand() % 30, velocity);

		velocity[0] += rand() % 40 - 20;
		velocity[1] += rand() % 40 - 20;
	} else
		VectorScale(le->pos.trDelta, le->size, velocity);

//	VectorCopy(le->pos.trBase, origin);

	if (le->leFlags == LEF_AIR)
		CG_ParticleAir(le->pos.trBase, velocity, le->life + rand() % 120, alpha, 2, 1);
	else if (le->leFlags == LEF_FLAME)
		CG_ParticleSteam(le->pos.trBase, velocity, le->life + rand() % 120, alpha, 2, 1,
				cgs.media.flamePressureShader);
	else if (le->leFlags == LEF_WATER)
		CG_ParticleWater(le->pos.trBase, velocity, le->life + rand() % 120, alpha, 1, 2);
	else
		CG_ParticleSteam(le->pos.trBase, velocity, le->life + rand() % 120, alpha, 2, 1, 
				cgs.media.smokePuffShader);
}
Esempio n. 28
0
/*
==================
CG_AddMoveScaleFade
==================
*/
static void CG_AddMoveScaleFade( localEntity_t *le ) {
	refEntity_t	*re;
	gfixed		c;
	bvec3_t		delta;
	bfixed		len;

	re = &le->refEntity;

	if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {
		// fade / grow time
		c = GFIXED_1 - MAKE_GFIXED( le->fadeInTime - cg.time ) / MAKE_GFIXED( le->fadeInTime - le->startTime );
	}
	else {
		// fade / grow time
		c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;
	}

	re->shaderRGBA[3] = FIXED_TO_INT( GFIXED(255,0) * c * le->color[3] );

	if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {
		re->radius = (le->radius * ( GFIXED_1 - c )) + BFIXED(8,0);
	}

	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = FIXED_VEC3LEN( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	_CG_trap_R_AddRefEntityToScene( re );
}
Esempio n. 29
0
/*
===================
CG_AddLocalEntities

===================
*/
void CG_AddLocalEntities( void ) {
	localEntity_t	*le, *next;

	// walk the list backwards, so any new local entities generated
	// (trails, marks, etc) will be present this frame
	le = cg_activeLocalEntities.prev;
	for ( ; le != &cg_activeLocalEntities ; le = next ) {
		// grab next now, so if the local entity is freed we
		// still have it
		next = le->prev;

		if ( cg.time >= le->endTime ) {
			CG_FreeLocalEntity( le );
			continue;
		}
		switch ( le->leType ) {
		default:
			trap->Error( ERR_DROP, "Bad leType: %i", le->leType );
			break;

		case LE_MARK:
			break;

		case LE_SPRITE_EXPLOSION:
			CG_AddSpriteExplosion( le );
			break;

		case LE_EXPLOSION:
			CG_AddExplosion( le );
			break;

		case LE_FADE_SCALE_MODEL:
			CG_AddFadeScaleModel( le );
			break;

		case LE_FRAGMENT:			// gibs and brass
			CG_AddFragment( le );
			break;

		case LE_PUFF:
			CG_AddPuff( le );
			break;

		case LE_MOVE_SCALE_FADE:		// water bubbles
			CG_AddMoveScaleFade( le );
			break;

		case LE_FADE_RGB:				// teleporters, railtrails
			CG_AddFadeRGB( le );
			break;

		case LE_FALL_SCALE_FADE: // gib blood trails
			CG_AddFallScaleFade( le );
			break;

		case LE_SCALE_FADE:		// rocket trails
			CG_AddScaleFade( le );
			break;

		case LE_SCOREPLUM:
			CG_AddScorePlum( le );
			break;

		case LE_OLINE:
			CG_AddOLine( le );
			break;

		case LE_SHOWREFENTITY:
			CG_AddRefEntity( le );
			break;

		case LE_LINE:					// oriented lines for FX
			CG_AddLine( le );
			break;
		}
	}
}
Esempio n. 30
0
void CG_AddScorePlum( localEntity_t *le ) {
	refEntity_t	*re;
	vec3_t		origin, delta, dir, vec, up = {0, 0, 1};
	float		c, len;
	int			i, score, digits[10], numdigits, negative;

	re = &le->refEntity;

	c = ( le->endTime - cg.time ) * le->lifeRate;

	score = le->radius;
	if (score < 0) {
		re->shaderRGBA[0] = 0xff;
		re->shaderRGBA[1] = 0x11;
		re->shaderRGBA[2] = 0x11;
	}
	else {
		re->shaderRGBA[0] = 0xff;
		re->shaderRGBA[1] = 0xff;
		re->shaderRGBA[2] = 0xff;
		if (score >= 50) {
			re->shaderRGBA[1] = 0;
		} else if (score >= 20) {
			re->shaderRGBA[0] = re->shaderRGBA[1] = 0;
		} else if (score >= 10) {
			re->shaderRGBA[2] = 0;
		} else if (score >= 2) {
			re->shaderRGBA[0] = re->shaderRGBA[2] = 0;
		}

	}
	if (c < 0.25)
		re->shaderRGBA[3] = 0xff * 4 * c;
	else
		re->shaderRGBA[3] = 0xff;

	re->radius = NUMBER_SIZE / 2;

	VectorCopy(le->pos.trBase, origin);
	origin[2] += 110 - c * 100;

	VectorSubtract(cg.refdef.vieworg, origin, dir);
	CrossProduct(dir, up, vec);
	VectorNormalize(vec);

	VectorMA(origin, -10 + 20 * sin(c * 2 * M_PI), vec, origin);

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < 20 ) {
		CG_FreeLocalEntity( le );
		return;
	}

	negative = qfalse;
	if (score < 0) {
		negative = qtrue;
		score = -score;
	}

	for (numdigits = 0; !(numdigits && !score); numdigits++) {
		digits[numdigits] = score % 10;
		score = score / 10;
	}

	if (negative) {
		digits[numdigits] = 10;
		numdigits++;
	}

	for (i = 0; i < numdigits; i++) {
		VectorMA(origin, (float) (((float) numdigits / 2) - i) * NUMBER_SIZE, vec, re->origin);
		re->customShader = cgs.media.numberShaders[digits[numdigits-1-i]];
		trap->R_AddRefEntityToScene( re );
	}
}