00001 #ifndef RADIOSITYRENDERER_H 00002 #define RADIOSITYRENDERER_H 00003 00011 #include "Triangle.h" 00012 #include "ProgressSubjectMultiStep.h" 00013 00014 class PatchSequenceEnumerator; 00015 class PatchRandomAccessEnumerator; 00016 class PatchCache; 00017 00021 class RadiosityRenderer: public ProgressSubjectMultiStep { 00022 public: 00030 RadiosityRenderer(PatchSequenceEnumerator *patchEnumerator, int stepCount, float formFactorTreshold, long maxCacheSize); 00031 ~RadiosityRenderer(); 00032 00036 virtual int stepCount() const; 00037 00041 virtual int currentStep() const; 00042 00046 virtual int patchCount() const; 00047 00051 virtual int currentPatch() const; 00052 00056 void compute(); 00057 00062 void normalize(); 00063 00068 long int cacheRawSize() const; 00069 00070 private: 00071 int stepCount_; 00072 int currentStep_; 00073 int currentPatch_; 00074 PatchRandomAccessEnumerator *patchEnumerator_; 00075 int patchCount_; 00076 PatchCache *patchCache_; 00077 00078 private: 00079 float colorPeak_; 00080 void updateColorPeak(const Color &c) { 00081 if (colorPeak_ < c.r) 00082 colorPeak_ = c.r; 00083 if (colorPeak_ < c.g) 00084 colorPeak_ = c.g; 00085 if (colorPeak_ < c.b) 00086 colorPeak_ = c.b; 00087 } 00088 void normalize(Color &dest) { 00089 float ratio = 1/colorPeak_; 00090 dest.r *= ratio; 00091 dest.g *= ratio; 00092 dest.b *= ratio; 00093 } 00094 void computeStep(); 00095 }; 00096 00097 #endif // RADIOSITYRENDERER_H