| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
#ifndef RADIOSITY_H |
| 66 |
#define RADIOSITY_H |
| 67 |
|
| 68 |
#include "pserror.h" |
| 69 |
#include "pstypes.h" |
| 70 |
#include "3d.h" |
| 71 |
#include "gr.h" |
| 72 |
|
| 73 |
|
| 74 |
#define SM_HEMICUBE 0 |
| 75 |
#define SM_RAYCAST 1 |
| 76 |
|
| 77 |
|
| 78 |
#define SM_SWITCH_AFTER_SATELLITES 2 |
| 79 |
|
| 80 |
#define MAX_VOLUME_ELEMENTS 500 |
| 81 |
|
| 82 |
struct spectra { |
| 83 |
float r, g, b; |
| 84 |
}; |
| 85 |
|
| 86 |
|
| 87 |
#define EF_IGNORE 1 |
| 88 |
#define EF_SMALL 2 // Don't blend this one into the lightmap - it will corrupt! |
| 89 |
|
| 90 |
struct rad_element { |
| 91 |
vector *verts; |
| 92 |
spectra exitance; |
| 93 |
float area; |
| 94 |
uint8_t num_verts; |
| 95 |
uint8_t flags; |
| 96 |
}; |
| 97 |
|
| 98 |
#define VEF_REVERSE_SHOOT 1 |
| 99 |
|
| 100 |
struct volume_element { |
| 101 |
spectra color; |
| 102 |
vector pos; |
| 103 |
uint8_t flags; |
| 104 |
}; |
| 105 |
|
| 106 |
#define ST_ROOM 0 // This is a room surface |
| 107 |
#define ST_TERRAIN 1 // This is a terrain surface |
| 108 |
#define ST_SATELLITE 2 // This is a sun on the terrain |
| 109 |
#define ST_PORTAL 3 // This surface is a portal, don't consider it |
| 110 |
#define ST_ROOM_OBJECT 4 // This surface is part of an object |
| 111 |
#define ST_TERRAIN_OBJECT 5 // This surface is part of terrain object |
| 112 |
#define ST_EXTERNAL_ROOM 6 // This surface is a room outside |
| 113 |
|
| 114 |
#define SF_TOUCHES_TERRAIN 1 |
| 115 |
#define SF_LIGHTSOURCE 2 |
| 116 |
|
| 117 |
struct rad_surface { |
| 118 |
float area; |
| 119 |
spectra emittance; |
| 120 |
spectra exitance; |
| 121 |
float reflectivity; |
| 122 |
uint8_t xresolution; |
| 123 |
uint8_t yresolution; |
| 124 |
rad_element *elements; |
| 125 |
vector normal; |
| 126 |
vector *verts; |
| 127 |
|
| 128 |
uint8_t surface_type; |
| 129 |
|
| 130 |
int facenum; |
| 131 |
int roomnum; |
| 132 |
uint8_t num_verts; |
| 133 |
uint8_t flags; |
| 134 |
|
| 135 |
float surface_area, element_area; |
| 136 |
|
| 137 |
uint8_t x1, y1, x2, y2; |
| 138 |
}; |
| 139 |
|
| 140 |
struct rad_point { |
| 141 |
vector pos; |
| 142 |
uint8_t code; |
| 143 |
}; |
| 144 |
|
| 145 |
extern float *Room_strongest_value[][4]; |
| 146 |
|
| 147 |
extern int Ignore_terrain; |
| 148 |
extern int Ignore_satellites; |
| 149 |
|
| 150 |
extern float Ignore_limit; |
| 151 |
extern float rad_TotalFlux; |
| 152 |
extern float rad_Convergence; |
| 153 |
|
| 154 |
extern int rad_StepCount; |
| 155 |
extern int rad_MaxStep; |
| 156 |
extern int rad_DoneCalculating; |
| 157 |
|
| 158 |
extern float rad_TotalUnsent; |
| 159 |
|
| 160 |
extern rad_surface *rad_MaxSurface; |
| 161 |
|
| 162 |
extern int rad_NumSurfaces; |
| 163 |
extern int rad_NumElements; |
| 164 |
|
| 165 |
extern float *rad_FormFactors; |
| 166 |
extern rad_surface *rad_Surfaces; |
| 167 |
extern volume_element *Volume_elements[]; |
| 168 |
|
| 169 |
extern int UseVolumeLights; |
| 170 |
extern int Calculate_specular_lighting; |
| 171 |
|
| 172 |
extern int Shoot_from_patch; |
| 173 |
|
| 174 |
|
| 175 |
extern int Do_volume_lighting; |
| 176 |
|
| 177 |
int DoRadiosityRun(int method, rad_surface *light_surfaces, int count); |
| 178 |
|
| 179 |
void InitRadiosityRun(); |
| 180 |
|
| 181 |
|
| 182 |
void InitExitance(); |
| 183 |
|
| 184 |
|
| 185 |
void GetEmittance(rad_surface *surf, spectra *dest); |
| 186 |
|
| 187 |
|
| 188 |
void SetExitanceForSurface(rad_surface *surf); |
| 189 |
|
| 190 |
|
| 191 |
void UpdateUnsentValues(); |
| 192 |
|
| 193 |
|
| 194 |
int DoRadiosityIteration(); |
| 195 |
|
| 196 |
|
| 197 |
void GetCenterOfElement(rad_element *ep, vector *dest); |
| 198 |
|
| 199 |
|
| 200 |
void GetCenterOfSurface(rad_surface *ep, vector *dest); |
| 201 |
|
| 202 |
|
| 203 |
int ShootRayFromPoint(vector *src, vector *dest, rad_surface *src_surf, rad_surface *dest_surf); |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
void ShootMaxSurface(); |
| 209 |
|
| 210 |
|
| 211 |
void CalculateRadiosity(); |
| 212 |
|
| 213 |
|
| 214 |
float GetUnsentFlux(rad_surface *surface); |
| 215 |
|
| 216 |
|
| 217 |
void CloseRadiosityRun(); |
| 218 |
|
| 219 |
|
| 220 |
void SetupFormFactors(); |
| 221 |
|
| 222 |
|
| 223 |
void CalculateArea(); |
| 224 |
|
| 225 |
|
| 226 |
void CountElements(); |
| 227 |
|
| 228 |
|
| 229 |
float GetMaxColor(spectra *sp); |
| 230 |
|
| 231 |
#endif |