From 1f5ee75ddcf996a206fc37d7e22685c57b700806 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Wed, 17 Sep 2003 23:49:29 +0000 Subject: [PATCH] Lens flares. Opendoor trigger_multiple fixes --- reaction/cgame/cg_draw.c | 7 +++ reaction/cgame/cg_local.h | 18 +++++++- reaction/cgame/cg_main.c | 7 +++ reaction/cgame/cg_servercmds.c | 36 ++++++++++++++- reaction/cgame/cg_view.c | 81 ++++++++++++++++++++++++++++++++-- reaction/cgame/cgame.plg | 16 +++---- 6 files changed, 152 insertions(+), 13 deletions(-) diff --git a/reaction/cgame/cg_draw.c b/reaction/cgame/cg_draw.c index fdb9c69f..f87d40e3 100644 --- a/reaction/cgame/cg_draw.c +++ b/reaction/cgame/cg_draw.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.74 2003/09/17 23:49:29 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.73 2003/07/30 16:05:46 makro // no message // @@ -2653,4 +2656,8 @@ void CG_DrawActive(stereoFrame_t stereoView) // draw status bar and other floating elements CG_Draw2D(); + + //Makro - lens flare + if (cgs.numFlares) + CG_AddLensFlare(); } diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index 7ce6cd38..3772c6bc 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.154 2003/09/17 23:49:29 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.153 2003/09/10 21:40:35 makro // Cooler breath puffs. Locked r_fastSky on maps with global fog. // Some other things I can't remember. @@ -891,6 +894,10 @@ typedef struct { // JBravo: unlagged #define NUM_SAVED_STATES (CMD_BACKUP + 2) +//Makro - lens flares +#define MAX_VISIBLE_FLARES 24 +#define NUM_FLARE_SHADERS 3 + typedef struct { int clientFrame; // incremented each frame @@ -1144,6 +1151,9 @@ typedef struct { //Makro - true if the user wants fastsky on. We'll force it to off for maps //that have a _rq3_fog_color set int wantsFastSky; + //Makro - used for flares + unsigned char flareShaderNum[MAX_VISIBLE_FLARES]; + float flareShaderSize[MAX_VISIBLE_FLARES], flareColor[MAX_VISIBLE_FLARES][4]; } cg_t; //Blaze: struct to hold the func_breakable stuff @@ -1605,6 +1615,9 @@ typedef struct { sfxHandle_t female_treportsound; sfxHandle_t female_upsound; sfxHandle_t female_click; + + //Makro - lens flare shaders + qhandle_t flareShader[NUM_FLARE_SHADERS]; } cgMedia_t; // The client game static (cgs) structure hold everything @@ -1701,6 +1714,9 @@ typedef struct { //Makro - "clear" color vec3_t clearColor; qboolean clearColorSet; + //Makro - sun flares + int lastSunTime, lastSunX, lastSunY, numFlares; + vec3_t sunDir; } cgs_t; //============================================================================== @@ -2495,4 +2511,4 @@ int CG_NewParticleArea(int num); void CG_DrawBigPolygon(void); void CG_ParticleHitSnow(vec3_t org, vec3_t vel, int duration, float x, float y, float speed, float scale); void CG_ParticleHitGrass(vec3_t org, vec3_t vel, int duration, float x, float y, float speed, float scale); - +void CG_AddLensFlare(); diff --git a/reaction/cgame/cg_main.c b/reaction/cgame/cg_main.c index cc8f9749..7c8eff83 100644 --- a/reaction/cgame/cg_main.c +++ b/reaction/cgame/cg_main.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.141 2003/09/17 23:49:29 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.140 2003/09/10 21:40:35 makro // Cooler breath puffs. Locked r_fastSky on maps with global fog. // Some other things I can't remember. @@ -2264,6 +2267,10 @@ static void CG_RegisterGraphics(void) } } + //Makro - lens flare shaders + for (i=0; i 0) { + float alphamin, alphamax, sizemin, sizemax, dfactor = 0.5f; + int i; + + cgs.numFlares = n; + cgs.sunDir[0] = atof(Info_ValueForKey(str, "lx")); + cgs.sunDir[1] = atof(Info_ValueForKey(str, "ly")); + cgs.sunDir[2] = atof(Info_ValueForKey(str, "lz")); + alphamin = atof(Info_ValueForKey(str, "lamin")); + alphamax = atof(Info_ValueForKey(str, "lamax")); + sizemin = atof(Info_ValueForKey(str, "lsmin")); + sizemax = atof(Info_ValueForKey(str, "lsmax")); + + //generate flare parms + for (i=0; i 0 && abs(y) <= hfovx && abs(p) <= hfovy) { + //do a trace + vec3_t end; + trace_t tr; + + VectorMA(cg.refdef.vieworg, 16384, dir, end); + CG_Trace(&tr, cg.refdef.vieworg, NULL, NULL, end, 0, CONTENTS_SOLID); + //if we hit the sky + if (tr.surfaceFlags & SURF_SKY) + { + //get the screen co-ordinates for the sun + cx = (1.0f - (float)(y + hfovx)/cg.refdef.fov_x) * 640; + cy = (1.0f - (float)(p + hfovy)/cg.refdef.fov_y) * 480; + cgs.lastSunX = cx; + cgs.lastSunY = cy; + cgs.lastSunTime = cg.time; + visible = qtrue; + } + //Note - we could do more traces if we hit transparent objects instead + //of the sky for example, but that would slow things down + } + if (!visible && cgs.lastSunTime) { + timeDelta = cg.time - cgs.lastSunTime; + if (timeDelta > FLARE_FADEOUT_TIME) + cgs.lastSunTime = 0; + } + //add the sprites + if (visible || cgs.lastSunTime) { + float len = 0, fade = 1.0f; + VectorSet(dir, 320-cgs.lastSunX, 240-cgs.lastSunY, 0); + len = 2 * VectorNormalize(dir); + if (!visible) + fade = 1.0f - (float)timeDelta / FLARE_FADEOUT_TIME; + for (i=0; i 0) { + aviDemoFPS = atof(cg_RQ3_avidemo.string); + if (aviDemoFPS > 0) { //if it's time to take a screenshot - if (cg.time > cg.screenshotTime + (int) (1000.0f / atof(cg_RQ3_avidemo.string))) { + if (cg.time > cg.screenshotTime + (int) (1000.0f / aviDemoFPS)) { trap_SendConsoleCommand("screenshotJPEG silent\n"); cg.screenshotTime = cg.time; } diff --git a/reaction/cgame/cgame.plg b/reaction/cgame/cgame.plg index b1011b96..9d3b84c9 100644 --- a/reaction/cgame/cgame.plg +++ b/reaction/cgame/cgame.plg @@ -6,13 +6,13 @@ --------------------Configuration: cgame - Win32 Release--------------------

Command Lines

-Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18A.tmp" with contents +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP315.tmp" with contents [ /nologo /G6 /ML /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR"Release/" /Fp"Release/cgame.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c -"C:\Games\Quake3\rq3source\reaction\cgame\cg_main.c" +"C:\Games\Quake3\rq3source\reaction\cgame\cg_view.c" ] -Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18A.tmp" -Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18B.tmp" with contents +Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP315.tmp" +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP316.tmp" with contents [ /nologo /base:"0x30000000" /subsystem:windows /dll /incremental:no /pdb:"Release/cgamex86.pdb" /map:"Release/cgamex86.map" /machine:I386 /def:".\cgame.def" /out:"../Release/cgamex86.dll" /implib:"Release/cgamex86.lib" .\Release\bg_misc.obj @@ -43,13 +43,13 @@ Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18B.tmp" with conte .\Release\q_shared.obj .\Release\ui_shared.obj ] -Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18B.tmp" +Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP316.tmp"

Output Window

Compiling... -cg_main.c +cg_view.c Linking... Creating library Release/cgamex86.lib and object Release/cgamex86.exp -Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18F.tmp" with contents +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP31A.tmp" with contents [ /nologo /o"Release/cgame.bsc" .\Release\bg_misc.sbr @@ -79,7 +79,7 @@ Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18F.tmp" with conte .\Release\q_math.sbr .\Release\q_shared.sbr .\Release\ui_shared.sbr] -Creating command line "bscmake.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18F.tmp" +Creating command line "bscmake.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP31A.tmp" Creating browse info file...

Output Window