00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "lux.h"
00025 #include "texture.h"
00026 #include "irregular.h"
00027 #include "paramset.h"
00028
00029 namespace lux
00030 {
00031
00032
00033 template <class T>
00034 class IrregularDataFloatTexture : public Texture<T> {
00035 public:
00036
00037 IrregularDataFloatTexture(const T &v) { value = v; }
00038 virtual ~IrregularDataFloatTexture() { }
00039 virtual T Evaluate(const TsPack *tspack, const DifferentialGeometry &) const {
00040 return value;
00041 }
00042 private:
00043 T value;
00044 };
00045
00046 template <class T>
00047 class IrregularDataSpectrumTexture : public Texture<T> {
00048 public:
00049
00050 IrregularDataSpectrumTexture(const int &n, const float *wl, const float *data, float resolution = 5) {
00051 SPD = new IrregularSPD(wl, data, n, resolution);
00052 }
00053 virtual ~IrregularDataSpectrumTexture() { delete SPD; }
00054 virtual T Evaluate(const TsPack *tspack, const DifferentialGeometry &) const {
00055 return SWCSpectrum(tspack, SPD);
00056 }
00057 virtual void SetPower(float power, float area) {
00058 SPD->Scale(power / (area * M_PI * SPD->Y()));
00059 }
00060 private:
00061 IrregularSPD* SPD;
00062 };
00063
00064 class IrregularDataTexture
00065 {
00066 public:
00067 static Texture<float> * CreateFloatTexture(const Transform &tex2world, const TextureParams &tp);
00068 static Texture<SWCSpectrum> * CreateSWCSpectrumTexture(const Transform &tex2world, const TextureParams &tp);
00069 };
00070
00071 }
00072