00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "common.h"
00039
00040 #ifdef HAVE_STRING_H
00041 # include <string.h>
00042 #else
00043 # include <strings.h>
00044 #endif
00045 #include <stdio.h>
00046 #include <stdlib.h>
00047 #include <math.h>
00048 #include "machine.h"
00049 #include "bu.h"
00050 #include "vmath.h"
00051 #include "bn.h"
00052 #include "db.h"
00053 #include "nmg.h"
00054 #include "raytrace.h"
00055 #include "optical.h"
00056 #include "plastic.h"
00057 #include "light.h"
00058
00059
00060 #define PM_MAPS 4
00061
00062 #define PM_GLOBAL 0
00063 #define PM_CAUSTIC 1
00064 #define PM_SHADOW 2
00065 #define PM_IMPORTANCE 3
00066
00067 #define PM_SEM RT_SEM_LAST-1
00068 #define PM_SEM_INIT RT_SEM_LAST
00069
00070
00071
00072
00073 struct Photon {
00074 int Axis;
00075 point_t Pos;
00076 vect_t Dir;
00077 vect_t Normal;
00078 vect_t Power;
00079 vect_t Irrad;
00080 };
00081
00082
00083 struct PSN {
00084 struct Photon P;
00085 fastf_t Dist;
00086 };
00087
00088
00089
00090
00091
00092 struct PhotonSearch {
00093 int Max;
00094 int Found;
00095 vect_t Normal;
00096 fastf_t RadSq;
00097 point_t Pos;
00098 struct PSN *List;
00099 };
00100
00101
00102 struct NearestPhotons {
00103 int Max;
00104 int Found;
00105 vect_t Normal;
00106 fastf_t RadSq;
00107 point_t Pos;
00108 struct Photon *List;
00109 };
00110
00111
00112 struct PNode {
00113 struct Photon P;
00114 struct PNode *L;
00115 struct PNode *R;
00116 int C;
00117 };
00118
00119
00120 struct PhotonMap {
00121 int StoredPhotons;
00122 int MaxPhotons;
00123 struct PNode *Root;
00124 };
00125
00126
00127 struct IrradNode {
00128 point_t Pos;
00129 vect_t RGB;
00130 };
00131
00132
00133 struct IrradCache {
00134 int Num;
00135 struct IrradNode *List;
00136 };
00137
00138
00139 OPTICAL_EXPORT extern int PM_Activated;
00140 OPTICAL_EXPORT extern int PM_Visualize;
00141
00142 OPTICAL_EXPORT BU_EXTERN(void BuildPhotonMap,
00143 (struct application *ap,
00144 point_t eye_pos,
00145 int cpus,
00146 int width,
00147 int height,
00148 int Hypersample,
00149 int GlobalPhotons,
00150 double CausticsPercent,
00151 int Rays,
00152 double AngularTolerance,
00153 int RandomSeed,
00154 int ImportanceMapping,
00155 int IrradianceHypersampling,
00156 int VisualizeIrradiance,
00157 double LightIntensity,
00158 char pmfile[255]));
00159 OPTICAL_EXPORT BU_EXTERN(void IrradianceEstimate,
00160 (struct application *ap,
00161 vect_t irrad,
00162 point_t pos,
00163 vect_t normal,
00164 fastf_t rad,
00165 int np));
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176