mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Verschiebe generisches Lichthandling aus cl_fx.c in eine eigene Datei
This commit is contained in:
parent
0f8b8df645
commit
5708130e49
4 changed files with 205 additions and 165 deletions
4
Makefile
4
Makefile
|
@ -171,6 +171,7 @@ CLIENT_OBJS = \
|
|||
build/client/cl_fx.o \
|
||||
build/client/cl_input.o \
|
||||
build/client/cl_inv.o \
|
||||
build/client/cl_lights.o \
|
||||
build/client/cl_main.o \
|
||||
build/client/cl_parse.o \
|
||||
build/client/cl_pred.o \
|
||||
|
@ -414,6 +415,9 @@ build/client/cl_input.o : src/client/cl_input.c
|
|||
build/client/cl_inv.o : src/client/cl_inv.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
||||
build/client/cl_lights.o : src/client/cl_lights.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
||||
build/client/cl_main.o : src/client/cl_main.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
* this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* This file implements all specialized client side effects.
|
||||
* E.g. weapon effects, enemy effects, flash, etc.
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "header/client.h"
|
||||
|
@ -28,142 +34,11 @@ static vec3_t avelocities [NUMVERTEXNORMALS];
|
|||
extern struct model_s *cl_mod_smoke;
|
||||
extern struct model_s *cl_mod_flash;
|
||||
|
||||
typedef struct {
|
||||
int length;
|
||||
float value[3];
|
||||
float map[MAX_QPATH];
|
||||
} clightstyle_t;
|
||||
|
||||
clightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
int lastofs;
|
||||
|
||||
cparticle_t *active_particles, *free_particles;
|
||||
cparticle_t particles[MAX_PARTICLES];
|
||||
|
||||
int cl_numparticles = MAX_PARTICLES;
|
||||
|
||||
void CL_ClearLightStyles (void) {
|
||||
memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
|
||||
lastofs = -1;
|
||||
}
|
||||
|
||||
void CL_RunLightStyles (void) {
|
||||
int ofs;
|
||||
int i;
|
||||
clightstyle_t *ls;
|
||||
|
||||
ofs = cl.time / 100;
|
||||
|
||||
if (ofs == lastofs)
|
||||
return;
|
||||
|
||||
lastofs = ofs;
|
||||
|
||||
for (i=0,ls=cl_lightstyle ; i<MAX_LIGHTSTYLES ; i++, ls++) {
|
||||
if (!ls->length) {
|
||||
ls->value[0] = ls->value[1] = ls->value[2] = 1.0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ls->length == 1)
|
||||
ls->value[0] = ls->value[1] = ls->value[2] = ls->map[0];
|
||||
|
||||
else
|
||||
ls->value[0] = ls->value[1] = ls->value[2] = ls->map[ofs%ls->length];
|
||||
}
|
||||
}
|
||||
|
||||
void CL_SetLightstyle (int i) {
|
||||
char *s;
|
||||
int j, k;
|
||||
|
||||
s = cl.configstrings[i+CS_LIGHTS];
|
||||
|
||||
j = (int)strlen (s);
|
||||
cl_lightstyle[i].length = j;
|
||||
|
||||
for (k=0 ; k<j ; k++)
|
||||
cl_lightstyle[i].map[k] = (float)(s[k]-'a')/(float)('m'-'a');
|
||||
}
|
||||
|
||||
void CL_AddLightStyles (void) {
|
||||
int i;
|
||||
clightstyle_t *ls;
|
||||
|
||||
for (i=0,ls=cl_lightstyle ; i<MAX_LIGHTSTYLES ; i++, ls++)
|
||||
V_AddLightStyle (i, ls->value[0], ls->value[1], ls->value[2]);
|
||||
}
|
||||
|
||||
cdlight_t cl_dlights[MAX_DLIGHTS];
|
||||
|
||||
void CL_ClearDlights (void) {
|
||||
memset (cl_dlights, 0, sizeof(cl_dlights));
|
||||
}
|
||||
|
||||
cdlight_t *CL_AllocDlight (int key) {
|
||||
int i;
|
||||
cdlight_t *dl;
|
||||
|
||||
/* first look for an exact key match */
|
||||
if (key) {
|
||||
dl = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (dl->key == key) {
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* then look for anything else */
|
||||
dl = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (dl->die < cl.time) {
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
|
||||
dl = &cl_dlights[0];
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
|
||||
void CL_NewDlight (int key, float x, float y, float z, float radius, float time) {
|
||||
cdlight_t *dl;
|
||||
|
||||
dl = CL_AllocDlight (key);
|
||||
dl->origin[0] = x;
|
||||
dl->origin[1] = y;
|
||||
dl->origin[2] = z;
|
||||
dl->radius = radius;
|
||||
dl->die = cl.time + time;
|
||||
}
|
||||
|
||||
void CL_RunDLights (void) {
|
||||
int i;
|
||||
cdlight_t *dl;
|
||||
|
||||
dl = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
||||
if (dl->die < cl.time) {
|
||||
dl->radius = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
dl->radius -= cls.frametime*dl->decay;
|
||||
|
||||
if (dl->radius < 0)
|
||||
dl->radius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CL_ParseMuzzleFlash (void) {
|
||||
vec3_t fv, rv;
|
||||
cdlight_t *dl;
|
||||
|
@ -815,40 +690,6 @@ void CL_ParseMuzzleFlash2 (void) {
|
|||
}
|
||||
}
|
||||
|
||||
void CL_AddDLights (void) {
|
||||
int i;
|
||||
cdlight_t *dl;
|
||||
|
||||
dl = cl_dlights;
|
||||
|
||||
if(vidref_val == VIDREF_GL) {
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
||||
V_AddLight (dl->origin, dl->radius,
|
||||
dl->color[0], dl->color[1], dl->color[2]);
|
||||
}
|
||||
|
||||
} else {
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
||||
/* negative light in software. only black allowed */
|
||||
if ((dl->color[0] < 0) || (dl->color[1] < 0) || (dl->color[2] < 0)) {
|
||||
dl->radius = -(dl->radius);
|
||||
dl->color[0] = 1;
|
||||
dl->color[1] = 1;
|
||||
dl->color[2] = 1;
|
||||
}
|
||||
|
||||
V_AddLight (dl->origin, dl->radius,
|
||||
dl->color[0], dl->color[1], dl->color[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CL_ClearParticles (void) {
|
||||
int i;
|
||||
|
||||
|
|
192
src/client/cl_lights.c
Normal file
192
src/client/cl_lights.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* This file implements all client side lighting
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "header/client.h"
|
||||
|
||||
typedef struct {
|
||||
int length;
|
||||
float value[3];
|
||||
float map[MAX_QPATH];
|
||||
} clightstyle_t;
|
||||
|
||||
clightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
int lastofs;
|
||||
|
||||
void CL_ClearLightStyles (void) {
|
||||
memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
|
||||
lastofs = -1;
|
||||
}
|
||||
|
||||
void CL_RunLightStyles (void) {
|
||||
int ofs;
|
||||
int i;
|
||||
clightstyle_t *ls;
|
||||
|
||||
ofs = cl.time / 100;
|
||||
|
||||
if (ofs == lastofs)
|
||||
return;
|
||||
|
||||
lastofs = ofs;
|
||||
|
||||
for (i=0,ls=cl_lightstyle ; i<MAX_LIGHTSTYLES ; i++, ls++) {
|
||||
if (!ls->length) {
|
||||
ls->value[0] = ls->value[1] = ls->value[2] = 1.0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ls->length == 1)
|
||||
ls->value[0] = ls->value[1] = ls->value[2] = ls->map[0];
|
||||
|
||||
else
|
||||
ls->value[0] = ls->value[1] = ls->value[2] = ls->map[ofs%ls->length];
|
||||
}
|
||||
}
|
||||
|
||||
void CL_SetLightstyle (int i) {
|
||||
char *s;
|
||||
int j, k;
|
||||
|
||||
s = cl.configstrings[i+CS_LIGHTS];
|
||||
|
||||
j = (int)strlen (s);
|
||||
cl_lightstyle[i].length = j;
|
||||
|
||||
for (k=0 ; k<j ; k++)
|
||||
cl_lightstyle[i].map[k] = (float)(s[k]-'a')/(float)('m'-'a');
|
||||
}
|
||||
|
||||
void CL_AddLightStyles (void) {
|
||||
int i;
|
||||
clightstyle_t *ls;
|
||||
|
||||
for (i=0,ls=cl_lightstyle ; i<MAX_LIGHTSTYLES ; i++, ls++)
|
||||
V_AddLightStyle (i, ls->value[0], ls->value[1], ls->value[2]);
|
||||
}
|
||||
|
||||
cdlight_t cl_dlights[MAX_DLIGHTS];
|
||||
|
||||
void CL_ClearDlights (void) {
|
||||
memset (cl_dlights, 0, sizeof(cl_dlights));
|
||||
}
|
||||
|
||||
cdlight_t *CL_AllocDlight (int key) {
|
||||
int i;
|
||||
cdlight_t *dl;
|
||||
|
||||
/* first look for an exact key match */
|
||||
if (key) {
|
||||
dl = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (dl->key == key) {
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* then look for anything else */
|
||||
dl = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (dl->die < cl.time) {
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
|
||||
dl = &cl_dlights[0];
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
|
||||
void CL_NewDlight (int key, float x, float y, float z, float radius, float time) {
|
||||
cdlight_t *dl;
|
||||
|
||||
dl = CL_AllocDlight (key);
|
||||
dl->origin[0] = x;
|
||||
dl->origin[1] = y;
|
||||
dl->origin[2] = z;
|
||||
dl->radius = radius;
|
||||
dl->die = cl.time + time;
|
||||
}
|
||||
|
||||
void CL_RunDLights (void) {
|
||||
int i;
|
||||
cdlight_t *dl;
|
||||
|
||||
dl = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
||||
if (dl->die < cl.time) {
|
||||
dl->radius = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
dl->radius -= cls.frametime*dl->decay;
|
||||
|
||||
if (dl->radius < 0)
|
||||
dl->radius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CL_AddDLights (void) {
|
||||
int i;
|
||||
cdlight_t *dl;
|
||||
|
||||
dl = cl_dlights;
|
||||
|
||||
if(vidref_val == VIDREF_GL) {
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
||||
V_AddLight (dl->origin, dl->radius,
|
||||
dl->color[0], dl->color[1], dl->color[2]);
|
||||
}
|
||||
|
||||
} else {
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++) {
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
||||
/* negative light in software. only black allowed */
|
||||
if ((dl->color[0] < 0) || (dl->color[1] < 0) || (dl->color[2] < 0)) {
|
||||
dl->radius = -(dl->radius);
|
||||
dl->color[0] = 1;
|
||||
dl->color[1] = 1;
|
||||
dl->color[2] = 1;
|
||||
}
|
||||
|
||||
V_AddLight (dl->origin, dl->radius,
|
||||
dl->color[0], dl->color[1], dl->color[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -438,6 +438,9 @@ void CL_RunParticles (void);
|
|||
void CL_RunDLights (void);
|
||||
void CL_RunLightStyles (void);
|
||||
|
||||
void CL_ClearLightStyles (void);
|
||||
void CL_ClearDlights (void);
|
||||
|
||||
void CL_AddEntities (void);
|
||||
void CL_AddDLights (void);
|
||||
void CL_AddTEnts (void);
|
||||
|
|
Loading…
Reference in a new issue