00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if defined(_MSC_VER)
00025 #pragma once
00026 #endif
00027
00028 #ifndef PBRT_VOLUMES_EXPONENTIAL_H
00029 #define PBRT_VOLUMES_EXPONENTIAL_H
00030
00031
00032 #include "volume.h"
00033
00034
00035 class ExponentialDensity : public DensityRegion {
00036 public:
00037
00038 ExponentialDensity(const Spectrum &sa, const Spectrum &ss,
00039 float gg, const Spectrum &emit, const BBox &e,
00040 const Transform &v2w, float aa, float bb,
00041 const Vector &up)
00042 : DensityRegion(sa, ss, gg, emit, v2w), extent(e), a(aa), b(bb) {
00043 upDir = Normalize(up);
00044 }
00045 BBox WorldBound() const { return Inverse(WorldToVolume)(extent); }
00046 bool IntersectP(const Ray &r, float *t0, float *t1) const {
00047 Ray ray = WorldToVolume(r);
00048 return extent.IntersectP(ray, t0, t1);
00049 }
00050 float Density(const Point &Pobj) const {
00051 if (!extent.Inside(Pobj)) return 0;
00052 float height = Dot(Pobj - extent.pMin, upDir);
00053 return a * expf(-b * height);
00054 }
00055 private:
00056
00057 BBox extent;
00058 float a, b;
00059 Vector upDir;
00060 };
00061
00062
00063 ExponentialDensity *CreateExponentialVolumeRegion(const Transform &volume2world,
00064 const ParamSet ¶ms);
00065
00066 #endif // PBRT_VOLUMES_EXPONENTIAL_H