From 63aa00f4ca28b3c4528721f79f1c08c7f1f97195 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Wed, 22 Aug 2001 01:39:29 +0000 Subject: Lens flares :) --- src/cgame/cg_ents.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/cgame') diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index dc65015b..0c0d6e9e 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -775,6 +775,52 @@ static void CG_TorchLight( centity_t *cent ) #endif } +/* +========================= +CG_LensFlare +========================= +*/ +static void CG_LensFlare( centity_t *cent ) +{ + refEntity_t flare; + entityState_t *es; + vec3_t forward, delta; + float len; + trace_t tr; + + es = ¢->currentState; + + memset( &flare, 0, sizeof( flare ) ); + + //bunch of geometry + AngleVectors( cent->lerpAngles, forward, NULL, NULL ); + VectorCopy( cent->lerpOrigin, flare.origin ); + VectorSubtract( flare.origin, cg.refdef.vieworg, delta ); + len = VectorLength( delta ); + VectorNormalize( delta ); + + flare.reType = RT_SPRITE; + flare.customShader = cgs.gameShaders[ es->modelindex ]; + flare.shaderRGBA[ 0 ] = 0xFF; + flare.shaderRGBA[ 1 ] = 0xFF; + flare.shaderRGBA[ 2 ] = 0xFF; + flare.shaderRGBA[ 3 ] = 0xFF; + + //can only see the flare when in front of it + flare.radius = len / es->origin2[ 0 ]; + flare.radius *= DotProduct( delta, forward ); + + //if can't see the centre do not draw + CG_Trace( &tr, flare.origin, NULL, NULL, cg.refdef.vieworg, 0, MASK_SHOT ); + if( tr.fraction < 1.0f ) + return; + + if( flare.radius < 0 ) + flare.radius = 0; + + trap_R_AddRefEntityToScene( &flare ); +} + /* ========================= CG_AdjustPositionForMover @@ -959,6 +1005,9 @@ static void CG_AddCEntity( centity_t *cent ) { case ET_ANIMMAPOBJ: CG_animMapObj( cent ); break; + case ET_LENSFLARE: + CG_LensFlare( cent ); + break; } } -- cgit