Lens flares

This commit is contained in:
Andrei Drexler 2003-09-18 19:08:40 +00:00
parent 0d5f00a159
commit 0b516b24ce
7 changed files with 104 additions and 135 deletions

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.155 2003/09/18 19:05:10 makro
// Lens flares
//
// Revision 1.154 2003/09/17 23:49:29 makro
// Lens flares. Opendoor trigger_multiple fixes
//
@ -1617,7 +1620,7 @@ typedef struct {
sfxHandle_t female_click;
//Makro - lens flare shaders
qhandle_t flareShader[NUM_FLARE_SHADERS];
qhandle_t flareShader[NUM_FLARE_SHADERS], sunFlareShader;
} cgMedia_t;
// The client game static (cgs) structure hold everything
@ -1715,7 +1718,8 @@ typedef struct {
vec3_t clearColor;
qboolean clearColorSet;
//Makro - sun flares
int lastSunTime, lastSunX, lastSunY, numFlares;
int lastSunTime, lastSunX, lastSunY, numFlares, sunFlareSize;
float sunAlpha;
vec3_t sunDir;
} cgs_t;
@ -2148,6 +2152,9 @@ void CG_SetEntitySoundPosition(centity_t * cent);
#define ADDENTS_NOSKYPORTAL -1
#define ADDENTS_NORMAL 0
#define ADDENTS_SKYPORTAL 1
//Makro - longest define in the history of mankind ?
#define GET_ZOOM_LEVEL ((cg.zoomLevel & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW && (cg.zoomLevel & RQ3_ZOOM_MED) == RQ3_ZOOM_MED) ? 6 : ((cg.zoomLevel & RQ3_ZOOM_MED) == RQ3_ZOOM_MED) ? 4 : ((cg.zoomLevel & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW) ? 2 : 1
void CG_AddPacketEntities(int mode);
void CG_Beam(centity_t * cent);
void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out);

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.142 2003/09/18 19:05:10 makro
// Lens flares
//
// Revision 1.141 2003/09/17 23:49:29 makro
// Lens flares. Opendoor trigger_multiple fixes
//
@ -2270,6 +2273,7 @@ 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));
cgs.media.sunFlareShader = trap_R_RegisterShaderNoMip("gfx/2d/sunflare");
// register all the server specified models
for (i = 1; i < MAX_MODELS; i++) {

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.76 2003/09/18 19:05:10 makro
// Lens flares
//
// Revision 1.75 2003/09/17 23:49:29 makro
// Lens flares. Opendoor trigger_multiple fixes
//
@ -459,17 +462,19 @@ void CG_ParseSkyPortal(const char *str)
//lens flare
n = atoi(Info_ValueForKey(str, "ln"));
if (n > 0) {
float alphamin, alphamax, sizemin, sizemax, dfactor = 0.5f;
float alphamin, alphamax, sizemin, sizemax, dfactor = 0.75f;
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"));
alphamin = Com_Clamp(0.0f, 1.0f, atof(Info_ValueForKey(str, "lamin")));
alphamax = Com_Clamp(0.0f, 1.0f, atof(Info_ValueForKey(str, "lamax")));
sizemin = atof(Info_ValueForKey(str, "lsmin"));
sizemax = atof(Info_ValueForKey(str, "lsmax"));
cgs.sunFlareSize = atoi(Info_ValueForKey(str, "lsun"));
cgs.sunAlpha = Com_Clamp(0.0f, 1.0f, atof(Info_ValueForKey(str, "lsa")));
//generate flare parms
for (i=0; i<MAX_VISIBLE_FLARES; i++) {

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.39 2003/09/18 19:05:10 makro
// Lens flares
//
// Revision 1.38 2003/09/17 23:49:29 makro
// Lens flares. Opendoor trigger_multiple fixes
//
@ -1012,8 +1015,8 @@ static void CG_PlayBufferedSounds(void)
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;
float PI180 = M_PI/180, pitch, yaw, cx, cy,
hfovx = cg.refdef.fov_x/2, hfovy = cg.refdef.fov_y/2;
int i, timeDelta = 0;
qboolean visible = qfalse;
@ -1021,22 +1024,28 @@ void CG_AddLensFlare()
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;
yaw = 90.0f - acos(dp[1])/PI180;
pitch = 90.0f - acos(dp[2])/PI180;
//if the sun is in fov
if (dp[0] > 0 && abs(y) <= hfovx && abs(p) <= hfovy) {
if (dp[0] > 0 && abs(yaw) <= hfovx && abs(pitch) <= 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)
//if we either hit the sky or did a full trace (most likely noclipping)
if ((tr.surfaceFlags & SURF_SKY) || tr.fraction == 1.0f)
{
//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;
//get the screen co-ordinates of the sun
//cx = (1.0f - (float)(y + hfovx)/cg.refdef.fov_x) * 640;
//cy = (1.0f - (float)(p + hfovy)/cg.refdef.fov_y) * 480;
//cx = 320 * (1 - dp[1] / sin(hfovx * PI180));
//cy = 240 * (1 - dp[2] / sin(hfovy * PI180));
//cx = 320 * (1 - (float)yaw / hfovx);
//cy = 240 * (1 - (float)pitch / hfovy);
cx = 320 * (1.0f - dp[1] / (cos(yaw * PI180) * tan(hfovx * PI180)));
cy = 240 * (1.0f - dp[2] / (cos(pitch * PI180) * tan(hfovy * PI180)));
cgs.lastSunX = cx;
cgs.lastSunY = cy;
cgs.lastSunTime = cg.time;
@ -1052,13 +1061,31 @@ void CG_AddLensFlare()
}
//add the sprites
if (visible || cgs.lastSunTime) {
float len = 0, fade = 1.0f;
float len = 0, fade = 1.0f, color[4];
float fovFactor = 1.0f, size, hsize;
if (cg.refdef.fov_x < 90)
fovFactor = 5 - 0.05f * cg.refdef.fov_x;
color[0] = color[1] = color[2] = 1.0f;
color[3] = cgs.sunAlpha;
if (!visible) {
fade = 1.0f - (float)timeDelta / FLARE_FADEOUT_TIME;
color[3] *= fade;
}
//sun
if (cgs.sunFlareSize > 0) {
size = cgs.sunFlareSize * fovFactor;
hsize = size/2;
trap_R_SetColor(color);
CG_DrawPic(cgs.lastSunX - hsize, cgs.lastSunY - hsize, size, size, cgs.media.sunFlareShader);
}
//reflection particles
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];
size = cg.flareShaderSize[i] * fovFactor;
hsize = size/2.0f;
dp[2] = len / cgs.numFlares * (i+1);
dp[0] = cgs.lastSunX + dp[2] * dir[0];
dp[1] = cgs.lastSunY + dp[2] * dir[1];
@ -1069,8 +1096,8 @@ void CG_AddLensFlare()
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_DrawPic(dp[0] - hsize, dp[1] - hsize, size, size,
cgs.media.flareShader[cg.flareShaderNum[i]]);
}
}
}

View file

@ -6,13 +6,13 @@
--------------------Configuration: cgame - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP315.tmp" with contents
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2CC.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_view.c"
]
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
Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2CC.tmp"
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2CD.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\RSP316.tmp" with conte
.\Release\q_shared.obj
.\Release\ui_shared.obj
]
Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP316.tmp"
Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2CD.tmp"
<h3>Output Window</h3>
Compiling...
cg_view.c
Linking...
Creating library Release/cgamex86.lib and object Release/cgamex86.exp
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP31A.tmp" with contents
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2D1.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\RSP31A.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\RSP31A.tmp"
Creating command line "bscmake.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP2D1.tmp"
Creating browse info file...
<h3>Output Window</h3>

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.79 2003/09/18 19:08:40 makro
// Lens flares
//
// Revision 1.78 2003/09/18 00:05:05 makro
// Lens flares. Opendoor trigger_multiple fixes
//
@ -421,7 +424,7 @@ void G_RunDlight(gentity_t * ent)
/*QUAKED misc_lens_flare (0 1 0) (-8 -8 -8) (8 8 8) ?
*/
void Think_Flare_Target(gentity_t *ent)
void Think_SetupFlare(gentity_t *ent)
{
char info[MAX_INFO_STRING]={0};
vec3_t dir;
@ -438,8 +441,8 @@ void Think_Flare_Target(gentity_t *ent)
} else {
VectorCopy(ent->s.origin2, dir);
}
trap_GetConfigstring(CS_SKYPORTAL, info, sizeof(info));
VectorNormalize(dir);
trap_GetConfigstring(CS_SKYPORTAL, info, sizeof(info));
Info_SetValueForKey(info, "ln", va("%d", ent->count));
Info_SetValueForKey(info, "lx", va("%f", dir[0]));
@ -449,6 +452,8 @@ void Think_Flare_Target(gentity_t *ent)
Info_SetValueForKey(info, "lamax", va("%f", ent->health_saved/1000.0f));
Info_SetValueForKey(info, "lsmin", va("%d", ent->damage));
Info_SetValueForKey(info, "lsmax", va("%d", ent->damage_radius));
Info_SetValueForKey(info, "lsun", va("%d", ent->mass));
Info_SetValueForKey(info, "lsa", va("%f", ent->speed));
trap_SetConfigstring(CS_SKYPORTAL, info);
G_FreeEntity(ent, __LINE__, __FILE__);
@ -465,10 +470,26 @@ void SP_misc_lens_flare(gentity_t *ent)
G_SpawnInt("maxsize", "128", &ent->damage_radius);
G_SpawnFloat("alphamin", "0.5", &f);
if (f > 1)
f = 1;
else if (f < 0)
f = 0;
ent->health = f * 1000;
G_SpawnFloat("alphamax", "1", &f);
if (f > 1)
f = 1;
else if (f < 0)
f = 0;
ent->health_saved = f * 1000;
if (ent->health_saved < ent->health) {
int tmp = ent->health_saved;
ent->health_saved = ent->health;
ent->health = tmp;
}
G_SpawnInt("sunsize", "0", &ent->mass);
G_SpawnFloat("sunalpha", "0.5", &ent->speed);
if (!ent->target) {
if (!G_SpawnVector("direction", "0 0 1", ent->s.origin2)) {
@ -476,7 +497,7 @@ void SP_misc_lens_flare(gentity_t *ent)
}
}
ent->think = Think_Flare_Target;
ent->think = Think_SetupFlare;
ent->nextthink = level.time + FRAMETIME;
}
@ -710,9 +731,16 @@ void SP_misc_portal_camera(gentity_t * ent)
void Think_SetupSkyPortal(gentity_t *ent)
{
char info[MAX_INFO_STRING]={0};
trap_GetConfigstring(CS_SKYPORTAL, info, sizeof(info));
qboolean isSet = qfalse;
int n = 0;
if (!info[0]) {
trap_GetConfigstring(CS_SKYPORTAL, info, sizeof(info));
if (info[0]) {
n = atoi(Info_ValueForKey(info, "n"));
if (n)
isSet = qtrue;
}
if (!isSet) {
gentity_t *skyportal = G_Find(NULL, FOFS(targetname), ent->target);
//G_Printf("^1 SKY PORTAL !!!\n");
@ -736,7 +764,7 @@ void Think_SetupSkyPortal(gentity_t *ent)
ent->s.origin2[0] = atof(Info_ValueForKey(info, "x"));
ent->s.origin2[1] = atof(Info_ValueForKey(info, "y"));
ent->s.origin2[2] = atof(Info_ValueForKey(info, "z"));
ent->r.ownerNum = atoi(Info_ValueForKey(info, "n"));
ent->r.ownerNum = n;
}
ent->nextthink = 0;

View file

@ -6,108 +6,6 @@
--------------------Configuration: game - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP322.tmp" with contents
[
/nologo /G6 /ML /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR"c:\reactionoutput/" /Fp"c:\reactionoutput/game.pch" /YX /Fo"c:\reactionoutput/" /Fd"c:\reactionoutput/" /FD /c
"C:\Games\Quake3\rq3source\reaction\game\g_misc.c"
]
Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP322.tmp"
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP323.tmp" with contents
[
kernel32.lib user32.lib winmm.lib /nologo /base:"0x20000000" /subsystem:windows /dll /incremental:no /pdb:"c:\reactionoutput/qagamex86.pdb" /map:"c:\reactionoutput/qagamex86.map" /machine:I386 /def:".\game.def" /out:"..\Release/qagamex86.dll" /implib:"c:\reactionoutput/qagamex86.lib"
\reactionoutput\ai_chat.obj
\reactionoutput\ai_cmd.obj
\reactionoutput\ai_dmnet.obj
\reactionoutput\ai_dmq3.obj
\reactionoutput\ai_main.obj
\reactionoutput\ai_team.obj
\reactionoutput\ai_vcmd.obj
\reactionoutput\bg_misc.obj
\reactionoutput\bg_pmove.obj
\reactionoutput\bg_slidemove.obj
\reactionoutput\g_active.obj
\reactionoutput\g_arenas.obj
\reactionoutput\g_bot.obj
\reactionoutput\g_client.obj
\reactionoutput\g_cmds.obj
\reactionoutput\g_combat.obj
\reactionoutput\g_fileio.obj
\reactionoutput\g_items.obj
\reactionoutput\g_main.obj
\reactionoutput\g_matchmode.obj
\reactionoutput\g_mem.obj
\reactionoutput\g_misc.obj
\reactionoutput\g_missile.obj
\reactionoutput\g_mover.obj
\reactionoutput\g_session.obj
\reactionoutput\g_spawn.obj
\reactionoutput\g_svcmds.obj
\reactionoutput\g_syscalls.obj
\reactionoutput\g_target.obj
\reactionoutput\g_team.obj
\reactionoutput\g_teamplay.obj
\reactionoutput\g_trigger.obj
\reactionoutput\g_unlagged.obj
\reactionoutput\g_utils.obj
\reactionoutput\g_weapon.obj
\reactionoutput\q_math.obj
\reactionoutput\q_shared.obj
\reactionoutput\rxn_game.obj
\reactionoutput\zcam.obj
\reactionoutput\zcam_target.obj
]
Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP323.tmp"
<h3>Output Window</h3>
Compiling...
g_misc.c
Linking...
Creating library c:\reactionoutput/qagamex86.lib and object c:\reactionoutput/qagamex86.exp
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP327.tmp" with contents
[
/nologo /o"c:\reactionoutput/game.bsc"
\reactionoutput\ai_chat.sbr
\reactionoutput\ai_cmd.sbr
\reactionoutput\ai_dmnet.sbr
\reactionoutput\ai_dmq3.sbr
\reactionoutput\ai_main.sbr
\reactionoutput\ai_team.sbr
\reactionoutput\ai_vcmd.sbr
\reactionoutput\bg_misc.sbr
\reactionoutput\bg_pmove.sbr
\reactionoutput\bg_slidemove.sbr
\reactionoutput\g_active.sbr
\reactionoutput\g_arenas.sbr
\reactionoutput\g_bot.sbr
\reactionoutput\g_client.sbr
\reactionoutput\g_cmds.sbr
\reactionoutput\g_combat.sbr
\reactionoutput\g_fileio.sbr
\reactionoutput\g_items.sbr
\reactionoutput\g_main.sbr
\reactionoutput\g_matchmode.sbr
\reactionoutput\g_mem.sbr
\reactionoutput\g_misc.sbr
\reactionoutput\g_missile.sbr
\reactionoutput\g_mover.sbr
\reactionoutput\g_session.sbr
\reactionoutput\g_spawn.sbr
\reactionoutput\g_svcmds.sbr
\reactionoutput\g_syscalls.sbr
\reactionoutput\g_target.sbr
\reactionoutput\g_team.sbr
\reactionoutput\g_teamplay.sbr
\reactionoutput\g_trigger.sbr
\reactionoutput\g_unlagged.sbr
\reactionoutput\g_utils.sbr
\reactionoutput\g_weapon.sbr
\reactionoutput\q_math.sbr
\reactionoutput\q_shared.sbr
\reactionoutput\rxn_game.sbr
\reactionoutput\zcam.sbr
\reactionoutput\zcam_target.sbr]
Creating command line "bscmake.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP327.tmp"
Creating browse info file...
<h3>Output Window</h3>