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 "light.h"
00026 #include "shape.h"
00027
00028 namespace lux
00029 {
00030
00031
00032 class SpotLight : public Light {
00033 public:
00034
00035 SpotLight(const Transform &light2world, const Spectrum &, float gain, float width, float fall);
00036 ~SpotLight() { delete LSPD; }
00037 SWCSpectrum Sample_L(const Point &p, Vector *wi, VisibilityTester *vis) const;
00038 bool IsDeltaLight() const { return true; }
00039 float Falloff(const Vector &w) const;
00040 SWCSpectrum Power(const Scene *) const {
00041 return SWCSpectrum(LSPD) * 2.f * M_PI *
00042 (1.f - .5f * (cosFalloffStart + cosTotalWidth));
00043 }
00044 SWCSpectrum Sample_L(const Point &P, float u1, float u2, float u3,
00045 Vector *wo, float *pdf, VisibilityTester *visibility) const;
00046 SWCSpectrum Sample_L(const Scene *scene, float u1, float u2,
00047 float u3, float u4, Ray *ray, float *pdf) const;
00048 float Pdf(const Point &, const Vector &) const;
00049
00050 static Light *CreateLight(const Transform &light2world,
00051 const ParamSet ¶mSet);
00052 private:
00053
00054 float cosTotalWidth, cosFalloffStart;
00055 Point lightPos;
00056 SPD *LSPD;
00057 };
00058
00059 }
00060