summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2001-08-22 01:39:29 +0000
committerTim Angus <tim@ngus.net>2001-08-22 01:39:29 +0000
commit63aa00f4ca28b3c4528721f79f1c08c7f1f97195 (patch)
tree12529739f6c2b84d67b6e1cd2dee671476da49f3 /src/cgame
parent3cd412949b4cc08e83ffde2ac9cdfd506330b21b (diff)
Lens flares :)
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_ents.c49
1 files changed, 49 insertions, 0 deletions
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
@@ -777,6 +777,52 @@ static void CG_TorchLight( centity_t *cent )
/*
=========================
+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 = &cent->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
Also called by client movement prediction code
@@ -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;
}
}