Lens flares. Opendoor trigger_multiple fixes

This commit is contained in:
Andrei Drexler 2003-09-17 23:49:29 +00:00
parent b5bd3563cc
commit 1f5ee75ddc
6 changed files with 152 additions and 13 deletions

View file

@ -5,6 +5,9 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Log$ // $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 // Revision 1.73 2003/07/30 16:05:46 makro
// no message // no message
// //
@ -2653,4 +2656,8 @@ void CG_DrawActive(stereoFrame_t stereoView)
// draw status bar and other floating elements // draw status bar and other floating elements
CG_Draw2D(); CG_Draw2D();
//Makro - lens flare
if (cgs.numFlares)
CG_AddLensFlare();
} }

View file

@ -5,6 +5,9 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Log$ // $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 // Revision 1.153 2003/09/10 21:40:35 makro
// Cooler breath puffs. Locked r_fastSky on maps with global fog. // Cooler breath puffs. Locked r_fastSky on maps with global fog.
// Some other things I can't remember. // Some other things I can't remember.
@ -891,6 +894,10 @@ typedef struct {
// JBravo: unlagged // JBravo: unlagged
#define NUM_SAVED_STATES (CMD_BACKUP + 2) #define NUM_SAVED_STATES (CMD_BACKUP + 2)
//Makro - lens flares
#define MAX_VISIBLE_FLARES 24
#define NUM_FLARE_SHADERS 3
typedef struct { typedef struct {
int clientFrame; // incremented each frame 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 //Makro - true if the user wants fastsky on. We'll force it to off for maps
//that have a _rq3_fog_color set //that have a _rq3_fog_color set
int wantsFastSky; int wantsFastSky;
//Makro - used for flares
unsigned char flareShaderNum[MAX_VISIBLE_FLARES];
float flareShaderSize[MAX_VISIBLE_FLARES], flareColor[MAX_VISIBLE_FLARES][4];
} cg_t; } cg_t;
//Blaze: struct to hold the func_breakable stuff //Blaze: struct to hold the func_breakable stuff
@ -1605,6 +1615,9 @@ typedef struct {
sfxHandle_t female_treportsound; sfxHandle_t female_treportsound;
sfxHandle_t female_upsound; sfxHandle_t female_upsound;
sfxHandle_t female_click; sfxHandle_t female_click;
//Makro - lens flare shaders
qhandle_t flareShader[NUM_FLARE_SHADERS];
} cgMedia_t; } cgMedia_t;
// The client game static (cgs) structure hold everything // The client game static (cgs) structure hold everything
@ -1701,6 +1714,9 @@ typedef struct {
//Makro - "clear" color //Makro - "clear" color
vec3_t clearColor; vec3_t clearColor;
qboolean clearColorSet; qboolean clearColorSet;
//Makro - sun flares
int lastSunTime, lastSunX, lastSunY, numFlares;
vec3_t sunDir;
} cgs_t; } cgs_t;
//============================================================================== //==============================================================================
@ -2495,4 +2511,4 @@ int CG_NewParticleArea(int num);
void CG_DrawBigPolygon(void); 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_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_ParticleHitGrass(vec3_t org, vec3_t vel, int duration, float x, float y, float speed, float scale);
void CG_AddLensFlare();

View file

@ -5,6 +5,9 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Log$ // $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 // Revision 1.140 2003/09/10 21:40:35 makro
// Cooler breath puffs. Locked r_fastSky on maps with global fog. // Cooler breath puffs. Locked r_fastSky on maps with global fog.
// Some other things I can't remember. // Some other things I can't remember.
@ -2264,6 +2267,10 @@ static void CG_RegisterGraphics(void)
} }
} }
//Makro - lens flare shaders
for (i=0; i<NUM_FLARE_SHADERS; i++)
cgs.media.flareShader[i] = trap_R_RegisterShaderNoMip(va("gfx/2d/flare%.2d", i+1));
// register all the server specified models // register all the server specified models
for (i = 1; i < MAX_MODELS; i++) { for (i = 1; i < MAX_MODELS; i++) {
const char *modelName; const char *modelName;

View file

@ -5,6 +5,9 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Log$ // $Log$
// Revision 1.75 2003/09/17 23:49:29 makro
// Lens flares. Opendoor trigger_multiple fixes
//
// Revision 1.74 2003/09/10 21:40:35 makro // Revision 1.74 2003/09/10 21:40:35 makro
// Cooler breath puffs. Locked r_fastSky on maps with global fog. // Cooler breath puffs. Locked r_fastSky on maps with global fog.
// Some other things I can't remember. // Some other things I can't remember.
@ -440,9 +443,11 @@ static void CG_ParseWarmup(void)
cg.warmup = warmup; cg.warmup = warmup;
} }
//Makro - added //Makro - sky portal and lens flare
void CG_ParseSkyPortal(const char *str) void CG_ParseSkyPortal(const char *str)
{ {
int n;
//sky portal
if (str && str[0] && Q_stricmp(str, "none")) { if (str && str[0] && Q_stricmp(str, "none")) {
cgs.skyPortalOrigin[0] = atof(Info_ValueForKey(str, "x")); cgs.skyPortalOrigin[0] = atof(Info_ValueForKey(str, "x"));
cgs.skyPortalOrigin[1] = atof(Info_ValueForKey(str, "y")); cgs.skyPortalOrigin[1] = atof(Info_ValueForKey(str, "y"));
@ -451,6 +456,35 @@ void CG_ParseSkyPortal(const char *str)
} else { } else {
cgs.skyPortalSet = qfalse; cgs.skyPortalSet = qfalse;
} }
//lens flare
n = atoi(Info_ValueForKey(str, "ln"));
if (n > 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<MAX_VISIBLE_FLARES; i++) {
cg.flareShaderNum[i] = rand() % NUM_FLARE_SHADERS;
//looks yucky, but oh well...
cg.flareShaderSize[i] = sizemin + random() * (sizemax - sizemin) *
(1.0f - dfactor * (1.0f - (i+1) / (float)MAX_VISIBLE_FLARES));
cg.flareColor[i][0] = 0.25f + random() * 0.75f;
cg.flareColor[i][1] = 0.25f + random() * 0.75f;
cg.flareColor[i][2] = 0.25f + random() * 0.75f;
cg.flareColor[i][3] = alphamin + random() * (alphamin - alphamax);
}
} else {
cgs.numFlares = 0;
}
} }
//Makro - added //Makro - added

View file

@ -5,6 +5,9 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Log$ // $Log$
// Revision 1.38 2003/09/17 23:49:29 makro
// Lens flares. Opendoor trigger_multiple fixes
//
// Revision 1.37 2003/09/07 22:19:27 makro // Revision 1.37 2003/09/07 22:19:27 makro
// Typo ! // Typo !
// //
@ -1003,6 +1006,76 @@ static void CG_PlayBufferedSounds(void)
//========================================================================= //=========================================================================
#define FLARE_FADEOUT_TIME 1000
void CG_AddLensFlare()
{
vec3_t dir, dp;
float PI180 = M_PI/180, hfovx = cg.refdef.fov_x/2, hfovy = cg.refdef.fov_y/2,
p, y, cx, cy;
int i, timeDelta = 0;
qboolean visible = qfalse;
VectorCopy(cgs.sunDir, dir);
dp[0] = DotProduct(dir, cg.refdef.viewaxis[0]);
dp[1] = DotProduct(dir, cg.refdef.viewaxis[1]);
dp[2] = DotProduct(dir, cg.refdef.viewaxis[2]);
y = 90 - acos(dp[1])/PI180;
p = 90 - acos(dp[2])/PI180;
//if the sun is in fov
if (dp[0] > 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<cgs.numFlares; i++) {
float color[4];
dp[2] = len / cgs.numFlares * (i+1);
dp[0] = cgs.lastSunX + dp[2] * dir[0];
dp[1] = cgs.lastSunY + dp[2] * dir[1];
color[0] = cg.flareColor[i][0];
color[1] = cg.flareColor[i][1];
color[2] = cg.flareColor[i][2];
color[3] = cg.flareColor[i][3];
if (!visible)
color[3] *= fade;
trap_R_SetColor(color);
CG_DrawPic(dp[0]-cg.flareShaderSize[i]/2.0f, dp[1]-cg.flareShaderSize[i]/2.0f,
cg.flareShaderSize[i], cg.flareShaderSize[i], cgs.media.flareShader[cg.flareShaderNum[i]]);
}
}
}
/* /*
================= =================
CG_DrawActiveFrame CG_DrawActiveFrame
@ -1014,6 +1087,7 @@ void CG_DrawActiveFrame(int serverTime, stereoFrame_t stereoView, qboolean demoP
{ {
int inwater; int inwater;
int skyPortalMode = ADDENTS_NOSKYPORTAL; int skyPortalMode = ADDENTS_NOSKYPORTAL;
float aviDemoFPS = 0;
//Blaze: for cheat detection //Blaze: for cheat detection
int i; int i;
@ -1190,9 +1264,10 @@ void CG_DrawActiveFrame(int serverTime, stereoFrame_t stereoView, qboolean demoP
} }
} }
//Makro - like cl_avidemo, just that it uses JPEG's //Makro - like cl_avidemo, just that it uses JPEG's
if (atof(cg_RQ3_avidemo.string) > 0) { aviDemoFPS = atof(cg_RQ3_avidemo.string);
if (aviDemoFPS > 0) {
//if it's time to take a screenshot //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"); trap_SendConsoleCommand("screenshotJPEG silent\n");
cg.screenshotTime = cg.time; cg.screenshotTime = cg.time;
} }

View file

@ -6,13 +6,13 @@
--------------------Configuration: cgame - Win32 Release-------------------- --------------------Configuration: cgame - Win32 Release--------------------
</h3> </h3>
<h3>Command Lines</h3> <h3>Command Lines</h3>
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 /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 command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP315.tmp"
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP18B.tmp" with contents 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" /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 .\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\q_shared.obj
.\Release\ui_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"
<h3>Output Window</h3> <h3>Output Window</h3>
Compiling... Compiling...
cg_main.c cg_view.c
Linking... Linking...
Creating library Release/cgamex86.lib and object Release/cgamex86.exp 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" /nologo /o"Release/cgame.bsc"
.\Release\bg_misc.sbr .\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_math.sbr
.\Release\q_shared.sbr .\Release\q_shared.sbr
.\Release\ui_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... Creating browse info file...
<h3>Output Window</h3> <h3>Output Window</h3>