Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

light.h (3691B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 GNU General Public License for more details.
     16 
     17 You should have received a copy of the GNU General Public License
     18 along with Foobar; if not, write to the Free Software
     19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20 ===========================================================================
     21 */
     22 
     23 #include "cmdlib.h"
     24 #include "mathlib.h"
     25 #include "bspfile.h"
     26 #include "polylib.h"
     27 #include "imagelib.h"
     28 #include "threads.h"
     29 #include "scriplib.h"
     30 
     31 #include "shaders.h"
     32 #include "mesh.h"
     33 
     34 
     35 
     36 typedef enum
     37 {
     38 	emit_point,
     39 	emit_area,
     40 	emit_spotlight,
     41 	emit_sun
     42 } emittype_t;
     43 
     44 #define	MAX_LIGHT_EDGES		8
     45 typedef struct light_s
     46 {
     47 	struct light_s *next;
     48 	emittype_t	type;
     49 	struct shaderInfo_s	*si;
     50 
     51 	vec3_t		origin;
     52 	vec3_t		normal;		// for surfaces, spotlights, and suns
     53 	float		dist;		// plane location along normal
     54 
     55 	qboolean	linearLight;
     56 	int			photons;
     57 	int			style;
     58 	vec3_t		color;
     59 	float		radiusByDist;	// for spotlights
     60 
     61 	qboolean	twosided;		// fog lights both sides
     62 
     63 	winding_t	*w;
     64 	vec3_t		emitColor;		// full out-of-gamut value
     65 } light_t;
     66 
     67 
     68 extern	float	lightscale;
     69 extern	float	ambient;
     70 extern	float	maxlight;
     71 extern	float	direct_scale;
     72 extern	float	entity_scale;
     73 
     74 extern	qboolean	noSurfaces;
     75 
     76 //===============================================================
     77 
     78 // light_trace.c
     79 
     80 // a facet is a subdivided element of a patch aproximation or model
     81 typedef struct cFacet_s {
     82 	float	surface[4];
     83 	int		numBoundaries;		// either 3 or 4, anything less is degenerate
     84 	float	boundaries[4][4];	// positive is outside the bounds
     85 
     86 	vec3_t	points[4];			// needed for area light subdivision
     87 
     88 	float	textureMatrix[2][4];	// compute texture coordinates at point of impact for translucency
     89 } cFacet_t;
     90 
     91 typedef struct {
     92 	vec3_t		mins, maxs;
     93 	vec3_t		origin;
     94 	float		radius;
     95 
     96 	qboolean	patch;
     97 
     98 	int			numFacets;
     99 	cFacet_t	*facets;
    100 
    101 	shaderInfo_t	*shader;		// for translucency
    102 } surfaceTest_t;
    103 
    104 
    105 typedef struct {
    106 	vec3_t		filter;				// starts out 1.0, 1.0, 1.0, may be reduced if
    107 									// transparent surfaces are crossed
    108 
    109 	vec3_t		hit;				// the impact point of a completely opaque surface
    110 	float		hitFraction;		// 0 = at start, 1.0 = at end
    111 	qboolean	passSolid;
    112 } trace_t;
    113 
    114 extern	surfaceTest_t	*surfaceTest[MAX_MAP_DRAW_SURFS];
    115 
    116 void	InitTrace( void );
    117 
    118 // traceWork_t is only a parameter to crutch up poor large local allocations on
    119 // winNT and macOS.  It should be allocated in the worker function, but never
    120 // looked at.
    121 typedef struct {
    122 	vec3_t		start, end;
    123 	int			numOpenLeafs;
    124 	int			openLeafNumbers[MAX_MAP_LEAFS];
    125 	trace_t		*trace;
    126 	int			patchshadows;
    127 } traceWork_t;
    128 
    129 void TraceLine( const vec3_t start, const vec3_t stop, trace_t *trace,
    130 			   qboolean testAll, traceWork_t *tw );
    131 qboolean PointInSolid( vec3_t start );
    132 
    133 //===============================================================
    134 
    135 //===============================================================
    136 
    137 
    138 typedef struct {
    139 	int		textureNum;
    140 	int		x, y, width, height;
    141 
    142 	// for patches
    143 	qboolean	patch;
    144 	mesh_t		mesh;
    145 
    146 	// for faces
    147 	vec3_t	origin;
    148 	vec3_t	vecs[3];
    149 } lightmap_t;
    150 
    151