UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lighting.h File Reference
#include "common/shared.h"
#include "common/bspfile.h"
#include "common/polylib.h"

Go to the source code of this file.

Data Structures

struct  patch_s
 

Macros

#define MAX_PATCHES   65000 /* larger will cause 32 bit overflows */
 

Typedefs

typedef struct patch_s patch_t
 

Functions

void BuildFacelights (unsigned int facenum)
 
void FinalLightFace (unsigned int facenum)
 Add the indirect lighting on top of the direct lighting and save into final map format. More...
 
void ExportLightmaps (const char *bspFileName)
 Export the day and night lightmap and direction data for the given map. More...
 
void BuildLights (void)
 Create lights out of patches and entity lights. More...
 
void BuildPatches (void)
 Create surface fragments for light-emitting surfaces so that light sources may be computed along them. More...
 
void SubdividePatches (void)
 Iterate all of the head face patches, subdividing them as necessary. More...
 
void CalcTextureReflectivity (void)
 Calculates the texture color that is used for light emitting surfaces. More...
 
void LightWorld (void)
 Build the lightmap out of light entities and surface lights (patches) More...
 
void BuildVertexNormals (void)
 Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces which share a given vertex, and calculating a weighted average of their normals. More...
 
void FreePatches (void)
 After light sources have been created, patches may be freed. More...
 

Variables

patch_tface_patches [MAX_MAP_FACES]
 
vec3_t face_offset [MAX_MAP_FACES]
 

Macro Definition Documentation

#define MAX_PATCHES   65000 /* larger will cause 32 bit overflows */

Definition at line 31 of file lighting.h.

Typedef Documentation

typedef struct patch_s patch_t

Function Documentation

void BuildPatches ( void  )

Create surface fragments for light-emitting surfaces so that light sources may be computed along them.

Definition at line 198 of file patches.cpp.

References BuildPatch(), curTile, EntityForModel(), f, face_offset, dMapTile_t::faces, dBspModel_t::firstface, GetVectorForKey(), HasLight(), i, dMapTile_t::models, dBspModel_t::numfaces, dMapTile_t::nummodels, winding_s::numpoints, OBJZERO, winding_s::p, VectorAdd, VectorCopy, and WindingFromFace().

Referenced by LightWorld().

void BuildVertexNormals ( void  )

Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces which share a given vertex, and calculating a weighted average of their normals.

Definition at line 673 of file lightmap.cpp.

References BuildFaceExtents(), curTile, dMapTile_t::faces, FacesWithVert(), i, MAX_VERT_FACES, extents_s::maxs, extents_s::mins, dBspNormal_t::normal, dBspPlane_t::normal, dMapTile_t::normals, dMapTile_t::numvertexes, dBspSurface_t::planenum, dMapTile_t::planes, scale, dBspSurface_t::side, VectorAdd, VectorClear, VectorLength(), VectorNormalize(), VectorScale, and VectorSubtract.

Referenced by LightWorld(), and main().

void CalcTextureReflectivity ( void  )

Calculates the texture color that is used for light emitting surfaces.

Definition at line 41 of file patches.cpp.

References Com_sprintf(), curTile, i, Img_LoadImage(), MAX_QPATH, dMapTile_t::numtexinfo, Q_streq, dMapTile_t::texinfo, texinfo_s::texture, texture_reflectivity, VectorCopy, VectorSet, VERB_EXTRA, VERB_NORMAL, and Verb_Printf().

Referenced by main().

void ExportLightmaps ( const char *  bspFileName)

Export the day and night lightmap and direction data for the given map.

Note
The bsp file must already be loaded.
Parameters
bspFileNameThe path of the loaded bsp file.

Definition at line 963 of file lightmap.cpp.

References BuildFaceExtents(), Com_FilePath(), Com_Printf(), Com_SkipPath(), Com_StripExtension(), ExportLightmap(), and MAX_QPATH.

Referenced by main().

void FreePatches ( void  )

After light sources have been created, patches may be freed.

Definition at line 325 of file patches.cpp.

References i, MAX_MAP_FACES, Mem_Free, and patch_s::next.

Referenced by LightWorld().

void LightWorld ( void  )

Build the lightmap out of light entities and surface lights (patches)

Note
Call CalcTextureReflectivity before entering this function

Definition at line 34 of file lighting.cpp.

References BuildFacelights(), BuildLights(), BuildPatches(), BuildVertexNormals(), CloseTracingNodes(), config, curTile, FinalLightFace(), FreePatches(), LEVEL_LASTLIGHTBLOCKING, dMapTile_t::lightdata, dMapTile_t::lightdatasize, MakeTracingNodes(), dMapTile_t::numfaces, dMapTile_t::numnodes, RunThreadsOn(), SubdividePatches(), Sys_Error(), and VERB_NORMAL.

Referenced by main().

void SubdividePatches ( void  )

Iterate all of the head face patches, subdividing them as necessary.

Definition at line 312 of file patches.cpp.

References i, MAX_MAP_FACES, and SubdividePatch().

Referenced by LightWorld().

Variable Documentation

vec3_t face_offset[MAX_MAP_FACES]

for rotating bmodels

Definition at line 34 of file lightmap.cpp.

Referenced by BuildFacelights(), and BuildPatches().

patch_t* face_patches[MAX_MAP_FACES]

Definition at line 30 of file patches.cpp.

Referenced by BuildLights().