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 #include "scene.h"
00028
00029 namespace lux
00030 {
00031
00032
00033 class DistantLight : public Light {
00034 public:
00035
00036 DistantLight(const Transform &light2world, const Spectrum &radiance, float gain, const Vector &dir);
00037 ~DistantLight() { delete LSPD; }
00038 bool IsDeltaLight() const { return true; }
00039 SWCSpectrum Sample_L(const Point &p, Vector *wi, VisibilityTester *) const;
00040 SWCSpectrum Power(const Scene *scene) const {
00041 Point worldCenter;
00042 float worldRadius;
00043 scene->WorldBound().BoundingSphere(&worldCenter,
00044 &worldRadius);
00045 return SWCSpectrum(LSPD) * M_PI * worldRadius * worldRadius;
00046 }
00047 SWCSpectrum Sample_L(const Point &P, float u1, float u2, float u3,
00048 Vector *wo, float *pdf, VisibilityTester *visibility) const;
00049 SWCSpectrum Sample_L(const Scene *scene, float u1, float u2,
00050 float u3, float u4, Ray *ray, float *pdf) const;
00051 float Pdf(const Point &, const Vector &) const;
00052
00053 static Light *CreateLight(const Transform &light2world,
00054 const ParamSet ¶mSet);
00055 private:
00056
00057 Vector lightDir;
00058 SPD *LSPD;
00059 };
00060
00061 }