00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_DYNLOAD_H
00024 #define LUX_DYNLOAD_H
00025
00026 #include "lux.h"
00027
00028 #include <map>
00029 #include <string>
00030 using std::map;
00031 using std::string;
00032
00033 namespace lux
00034 {
00035
00036
00037 boost::shared_ptr<Shape> MakeShape(const string &name,
00038 const Transform &object2world, bool reverseOrientation,
00039 const ParamSet ¶mSet);
00040 boost::shared_ptr<Material> MakeMaterial(const string &name,
00041 const Transform &mtl2world, const TextureParams &mp);
00042 boost::shared_ptr<Texture<float> > MakeFloatTexture(const string &name,
00043 const Transform &tex2world, const TextureParams &tp);
00044 boost::shared_ptr<Texture<SWCSpectrum> > MakeSWCSpectrumTexture(const string &name,
00045 const Transform &tex2world, const TextureParams &tp);
00046 Light *MakeLight(const string &name, const Transform &light2world,
00047 const ParamSet ¶mSet, const TextureParams &tp);
00048 AreaLight *MakeAreaLight(const string &name,
00049 const Transform &light2world, const ParamSet ¶mSet, const TextureParams &tp,
00050 const boost::shared_ptr<Primitive> &prim);
00051 VolumeRegion *MakeVolumeRegion(const string &name,
00052 const Transform &light2world, const ParamSet ¶mSet);
00053 SurfaceIntegrator *MakeSurfaceIntegrator(const string &name,
00054 const ParamSet ¶mSet);
00055 VolumeIntegrator *MakeVolumeIntegrator(const string &name,
00056 const ParamSet ¶mSet);
00057 boost::shared_ptr<Aggregate> MakeAccelerator(const string &name, const vector<boost::shared_ptr<Primitive> > &prims,
00058 const ParamSet ¶mSet);
00059 Camera *MakeCamera(const string &name, const Transform &world2cam,
00060 const Transform &world2camEnd, const ParamSet ¶mSet, Film *film);
00061 Sampler *MakeSampler(const string &name, const ParamSet ¶mSet,
00062 const Film *film);
00063 Filter *MakeFilter(const string &name, const ParamSet ¶mSet);
00064 ToneMap *MakeToneMap(const string &name, const ParamSet ¶mSet);
00065 Film *MakeFilm(const string &name, const ParamSet ¶mSet, Filter *filt);
00066 PixelSampler *MakePixelSampler(const string &name, const ParamSet ¶mSet);
00067
00068 class DynamicLoader {
00069 template <class T> class RegisterLoader {
00070 public:
00071 RegisterLoader<T>(map<string, T> &store, const string &name, T loader)
00072 {
00073 store[name] = loader;
00074 }
00075 virtual ~RegisterLoader<T>() {}
00076 };
00077
00078 public:
00079 typedef Shape *(*CreateShape)(const Transform&, bool, const ParamSet&);
00080 static map<string, CreateShape> ®isteredShapes();
00081 template <class T> class RegisterShape : public RegisterLoader<CreateShape> {
00082 public:
00083 RegisterShape<T>(const string &name) :
00084 RegisterLoader<CreateShape>(registeredShapes(), name, &T::CreateShape) {}
00085 virtual ~RegisterShape<T>() {}
00086 };
00087
00088 typedef Material *(*CreateMaterial)(const Transform&,
00089 const TextureParams&);
00090 static map<string, CreateMaterial> ®isteredMaterials();
00091 template <class T> class RegisterMaterial : public RegisterLoader<CreateMaterial> {
00092 public:
00093 RegisterMaterial<T>(const string &name) :
00094 RegisterLoader<CreateMaterial>(registeredMaterials(), name, &T::CreateMaterial) {}
00095 virtual ~RegisterMaterial<T>() {}
00096 };
00097
00098 typedef Texture<float> *(*CreateFloatTexture)(const Transform&,
00099 const TextureParams&);
00100 static map<string, CreateFloatTexture> ®isteredFloatTextures();
00101 template <class T> class RegisterFloatTexture : public RegisterLoader<CreateFloatTexture> {
00102 public:
00103 RegisterFloatTexture<T>(const string &name) :
00104 RegisterLoader<CreateFloatTexture>(registeredFloatTextures(), name, &T::CreateFloatTexture) {}
00105 virtual ~RegisterFloatTexture<T>() {}
00106 };
00107
00108 typedef Texture<SWCSpectrum> *(*CreateSWCSpectrumTexture)(const Transform&,
00109 const TextureParams&);
00110 static map<string, CreateSWCSpectrumTexture> ®isteredSWCSpectrumTextures();
00111 template <class T> class RegisterSWCSpectrumTexture : public RegisterLoader<CreateSWCSpectrumTexture> {
00112 public:
00113 RegisterSWCSpectrumTexture<T>(const string &name) :
00114 RegisterLoader<CreateSWCSpectrumTexture>(registeredSWCSpectrumTextures(), name, &T::CreateSWCSpectrumTexture) {}
00115 virtual ~RegisterSWCSpectrumTexture<T>() {}
00116 };
00117
00118 typedef Light *(*CreateLight)(const Transform&, const ParamSet&, const TextureParams &tp);
00119 static map<string, CreateLight> ®isteredLights();
00120 template <class T> class RegisterLight : public RegisterLoader<CreateLight> {
00121 public:
00122 RegisterLight<T>(const string &name) :
00123 RegisterLoader<CreateLight>(registeredLights(), name, &T::CreateLight) {}
00124 virtual ~RegisterLight<T>() {}
00125 };
00126
00127 typedef AreaLight *(*CreateAreaLight)(const Transform&, const ParamSet&, const TextureParams&,
00128 const boost::shared_ptr<Primitive>&);
00129 static map<string, CreateAreaLight> ®isteredAreaLights();
00130 template <class T> class RegisterAreaLight : public RegisterLoader<CreateAreaLight> {
00131 public:
00132 RegisterAreaLight<T>(const string &name) :
00133 RegisterLoader<CreateAreaLight>(registeredAreaLights(), name, &T::CreateAreaLight) {}
00134 virtual ~RegisterAreaLight<T>() {}
00135 };
00136
00137 typedef VolumeRegion *(*CreateVolumeRegion)(const Transform&,
00138 const ParamSet&);
00139 static map<string, CreateVolumeRegion> ®isteredVolumeRegions();
00140 template <class T> class RegisterVolumeRegion : public RegisterLoader<CreateVolumeRegion> {
00141 public:
00142 RegisterVolumeRegion<T>(const string &name) :
00143 RegisterLoader<CreateVolumeRegion>(registeredVolumeRegions(), name, &T::CreateVolumeRegion) {}
00144 virtual ~RegisterVolumeRegion<T>() {}
00145 };
00146
00147 typedef SurfaceIntegrator *(*CreateSurfaceIntegrator)(const ParamSet&);
00148 static map<string, CreateSurfaceIntegrator> ®isteredSurfaceIntegrators();
00149 template <class T> class RegisterSurfaceIntegrator : public RegisterLoader<CreateSurfaceIntegrator> {
00150 public:
00151 RegisterSurfaceIntegrator<T>(const string &name) :
00152 RegisterLoader<CreateSurfaceIntegrator>(registeredSurfaceIntegrators(), name, &T::CreateSurfaceIntegrator) {}
00153 virtual ~RegisterSurfaceIntegrator<T>() {}
00154 };
00155
00156 typedef VolumeIntegrator *(*CreateVolumeIntegrator)(const ParamSet&);
00157 static map<string, CreateVolumeIntegrator> ®isteredVolumeIntegrators();
00158 template <class T> class RegisterVolumeIntegrator : public RegisterLoader<CreateVolumeIntegrator> {
00159 public:
00160 RegisterVolumeIntegrator<T>(const string &name) :
00161 RegisterLoader<CreateVolumeIntegrator>(registeredVolumeIntegrators(), name, &T::CreateVolumeIntegrator) {}
00162 virtual ~RegisterVolumeIntegrator<T>() {}
00163 };
00164
00165 typedef Aggregate *(*CreateAccelerator)(const vector<boost::shared_ptr<Primitive> >&,
00166 const ParamSet&);
00167 static map<string, CreateAccelerator> ®isteredAccelerators();
00168 template <class T> class RegisterAccelerator : public RegisterLoader<CreateAccelerator> {
00169 public:
00170 RegisterAccelerator<T>(const string &name) :
00171 RegisterLoader<CreateAccelerator>(registeredAccelerators(), name, &T::CreateAccelerator) {}
00172 virtual ~RegisterAccelerator<T>() {}
00173 };
00174
00175 typedef Camera *(*CreateCamera)(const Transform&, const Transform&, const ParamSet&,
00176 Film*);
00177 static map<string, CreateCamera> ®isteredCameras();
00178 template <class T> class RegisterCamera : public RegisterLoader<CreateCamera> {
00179 public:
00180 RegisterCamera<T>(const string &name) :
00181 RegisterLoader<CreateCamera>(registeredCameras(), name, &T::CreateCamera) {}
00182 virtual ~RegisterCamera<T>() {}
00183 };
00184
00185 typedef Sampler *(*CreateSampler)(const ParamSet&, const Film*);
00186 static map<string, CreateSampler> ®isteredSamplers();
00187 template <class T> class RegisterSampler : public RegisterLoader<CreateSampler> {
00188 public:
00189 RegisterSampler<T>(const string &name) :
00190 RegisterLoader<CreateSampler>(registeredSamplers(), name, &T::CreateSampler) {}
00191 virtual ~RegisterSampler<T>() {}
00192 };
00193
00194 typedef Filter *(*CreateFilter)(const ParamSet&);
00195 static map<string, CreateFilter> ®isteredFilters();
00196 template <class T> class RegisterFilter : public RegisterLoader<CreateFilter> {
00197 public:
00198 RegisterFilter<T>(const string &name) :
00199 RegisterLoader<CreateFilter>(registeredFilters(), name, &T::CreateFilter) {}
00200 virtual ~RegisterFilter<T>() {}
00201 };
00202
00203 typedef ToneMap *(*CreateToneMap)(const ParamSet&);
00204 static map<string, CreateToneMap> ®isteredToneMaps();
00205 template <class T> class RegisterToneMap : public RegisterLoader<CreateToneMap> {
00206 public:
00207 RegisterToneMap<T>(const string &name) :
00208 RegisterLoader<CreateToneMap>(registeredToneMaps(), name, &T::CreateToneMap) {}
00209 virtual ~RegisterToneMap<T>() {}
00210 };
00211
00212 typedef Film *(*CreateFilm)(const ParamSet&, Filter*);
00213 static map<string, CreateFilm> ®isteredFilms();
00214 template <class T> class RegisterFilm : public RegisterLoader<CreateFilm> {
00215 public:
00216 RegisterFilm<T>(const string &name) :
00217 RegisterLoader<CreateFilm>(registeredFilms(), name, &T::CreateFilm) {}
00218 virtual ~RegisterFilm<T>() {}
00219 };
00220
00221 typedef PixelSampler *(*CreatePixelSampler)(const ParamSet&);
00222 static map<string, CreatePixelSampler> ®isteredPixelSamplers();
00223 template <class T> class RegisterPixelSampler : public RegisterLoader<CreatePixelSampler> {
00224 public:
00225 RegisterPixelSampler<T>(const string &name) :
00226 RegisterLoader<CreatePixelSampler>(registeredPixelSamplers(), name, &T::CreatePixelSampler) {}
00227 virtual ~RegisterPixelSampler<T>() {}
00228 };
00229 };
00230
00231 }
00232
00233 #endif // LUX_DYNLOAD_H