From 37ba01987444bd4d3766cea958b5e686bec3661a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 5 May 2000 11:26:13 +0000 Subject: [PATCH] add r_firecolor command. sets the color of the rocket trail fire and dlight. Also, change dlights and fires so the color can be set with a pointer assignment (optional). --- common/cl_ents.c | 3 +++ common/client.h | 5 +++-- common/gl_rmisc.c | 6 +++++- common/gl_rpart.c | 42 ++++++++++++++++++++++++++++++++++-------- common/glquake.h | 3 ++- 5 files changed, 47 insertions(+), 12 deletions(-) diff --git a/common/cl_ents.c b/common/cl_ents.c index 0f86547..430b90c 100644 --- a/common/cl_ents.c +++ b/common/cl_ents.c @@ -74,6 +74,7 @@ dlight_t *CL_AllocDlight (int key) { memset (dl, 0, sizeof(*dl)); dl->key = key; + dl->color = dl->_color; return dl; } } @@ -87,6 +88,7 @@ dlight_t *CL_AllocDlight (int key) { memset (dl, 0, sizeof(*dl)); dl->key = key; + dl->color = dl->_color; return dl; } } @@ -94,6 +96,7 @@ dlight_t *CL_AllocDlight (int key) dl = &cl_dlights[0]; memset (dl, 0, sizeof(*dl)); dl->key = key; + dl->color = dl->_color; return dl; } diff --git a/common/client.h b/common/client.h index 9f8b804..6765534 100644 --- a/common/client.h +++ b/common/client.h @@ -145,14 +145,15 @@ typedef struct #define MAX_DLIGHTS 32 typedef struct { - int key; // so entities can reuse same entry + int key; // so entities can reuse same entry vec3_t origin; float radius; float die; // stop lighting after this time float decay; // drop this each second float minlight; // don't add when contributing less qboolean dark; - float color[4]; + float _color[4]; + float *color; } dlight_t; typedef struct diff --git a/common/gl_rmisc.c b/common/gl_rmisc.c index 1b1efe4..c362e6d 100644 --- a/common/gl_rmisc.c +++ b/common/gl_rmisc.c @@ -37,7 +37,9 @@ #include #include -extern void R_InitBubble(); +void R_InitBubble(); + +void R_FireColor_f(); extern cvar_t *r_clearcolor; @@ -195,6 +197,8 @@ void R_Init (void) Cmd_AddCommand ("envmap", R_Envmap_f); Cmd_AddCommand ("pointfile", R_ReadPointFile_f); + Cmd_AddCommand ("r_firecolor", R_FireColor_f); + r_norefresh = Cvar_Get ("r_norefresh", "0", CVAR_NONE, "None"); r_lightmap = Cvar_Get ("r_lightmap", "0", CVAR_NONE, diff --git a/common/gl_rpart.c b/common/gl_rpart.c index b19befb..475e273 100644 --- a/common/gl_rpart.c +++ b/common/gl_rpart.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #define MAX_PARTICLES 2048 // max particles at once #define ABSOLUTE_MIN_PARTICLES 512 // min particle clamp @@ -868,6 +870,9 @@ void R_DrawParticles (void) Nifty ball of fire GL effect. Kinda a meshing of the dlight and particle engine code. */ +float r_firecolor_flame[4]={0.9,0.7,0.3,1.0}; +float r_firecolor_light[4]={0.9,0.7,0.3,0.66}; + void R_AddFire (vec3_t start, vec3_t end, entity_t *ent) { @@ -892,19 +897,13 @@ R_AddFire (vec3_t start, vec3_t end, entity_t *ent) f->size = 20; f->die = cl.time + 0.5; f->decay = -1; - f->color[0] = 0.9; - f->color[1] = 0.7; - f->color[2] = 0.3; - f->color[3] = 1.0; + f->color=r_firecolor_flame; dl = CL_AllocDlight (key); VectorCopy (end, dl->origin); dl->radius = 200; dl->die = cl.time + 0.5; - dl->color[0] = 0.9; - dl->color[1] = 0.7; - dl->color[2] = 0.3; - dl->color[3] = 0.66; + dl->color=r_firecolor_light; } } @@ -926,6 +925,7 @@ R_AllocFire (int key) { memset (f, 0, sizeof(*f)); f->key = key; + f->color = f->_color; return f; } } @@ -937,6 +937,7 @@ R_AllocFire (int key) { memset (f, 0, sizeof(*f)); f->key = key; + f->color = f->_color; return f; } } @@ -944,6 +945,7 @@ R_AllocFire (int key) f = &r_fires[0]; memset (f, 0, sizeof(*f)); f->key = key; + f->color = f->_color; return f; } @@ -1036,3 +1038,27 @@ R_UpdateFires (void) glDepthMask (1); } +void +R_FireColor_f() +{ + int i; + + if (Cmd_Argc() == 1) { + Con_Printf ("r_firecolor %f %f %f %f %f\n", + r_firecolor_flame[0], + r_firecolor_flame[1], + r_firecolor_flame[2], + r_firecolor_flame[3], + r_firecolor_light[3]); + return; + } + if (Cmd_Argc() !=6) { + Con_Printf ("Usage r_firecolor R G B Af Al\n"); + return; + } + for (i=0; i<4; i++) { + r_firecolor_flame[i]=atof(Cmd_Argv(i+1)); + r_firecolor_light[i]=r_firecolor_flame[i]; + } + r_firecolor_light[3]=atof(Cmd_Argv(i+1)); +} diff --git a/common/glquake.h b/common/glquake.h index 3df9c67..58ff93b 100644 --- a/common/glquake.h +++ b/common/glquake.h @@ -254,7 +254,8 @@ typedef struct { float size; float die, decay; // duration settings float minlight; // lighting threshold - float color[4]; // RGBA + float _color[4]; // RGBA + float *color; } fire_t; void R_AddFire (vec3_t, vec3_t, entity_t *ent);