noisematerial.h

Go to the documentation of this file.
00001 #ifndef NOISEMATERIAL_H
00002 #define NOISEMATERIAL_H
00003 
00004 #include "raytrace_defs.h"
00005 #include "material.h"
00006 #include "pluginfactory.h"
00007 #include "noise.h"
00008 #include "color.h"
00009 
00010 Material * make_noise_material(std::map<std::string, std::string> props);
00011 
00012 
00017 class NoiseMaterial : public Material{
00019     class StaticInit
00020     {
00021         public:
00023             StaticInit()
00024             {
00025                 log_info("Registering as \"noise\" and \"cloud\"");
00026                 MaterialFactory::get_instance()->registerPlugin("noise", sigc::ptr_fun(make_noise_material));
00027                 MaterialFactory::get_instance()->registerPlugin("cloud", sigc::ptr_fun(make_noise_material));
00028             }
00029     };
00030 
00031     protected:
00032 
00033 
00035         Noise m_noise;
00036         
00038         static StaticInit m_init;
00039 
00041         Material * m_material_one;
00043         Material * m_material_two;
00044 
00045         // Amount to scale noise by
00046         double m_scale;
00050         double choose_material(const Point3D& intersection_point) const ;
00051 
00052     public:
00054         NoiseMaterial(Material * one, Material * two, double scale = 1.0)
00055         {
00056             m_material_one = one;
00057             m_material_two = two;
00058             m_scale = scale;
00059         }
00060 
00062         NoiseMaterial(const NoiseMaterial &other)
00063                 :  m_material_one(other.m_material_one),
00064                     m_material_two(other.m_material_two)
00065         {
00066             // TODO: this should really just be a straight copy..
00067         }
00068 
00069 
00070         virtual ~NoiseMaterial() {
00071             //delete m_color;
00072         }
00073 
00075         virtual Magick::Color get_color(const Point3D& intersesction_point) const ; 
00076 
00078         virtual bool is_light(const Point3D& intersesction_point) const ; 
00079 
00081         virtual void set_is_light(bool v); 
00082 
00084         virtual double get_diffuse(const Point3D& intersesction_point) const ; 
00085 
00087         virtual void set_diffuse(double diffuse); 
00088 
00090         virtual double get_reflection(const Point3D& intersesction_point) const; 
00091 
00093         virtual double get_reflectivity(const Point3D& intersesction_point) const ; 
00094 
00099         virtual double get_refraction_index(const Point3D& intersesction_point) const; 
00100 
00102         virtual double get_opacity(const Point3D& intersesction_point) const ; 
00103 
00105         virtual void set_opacity(double opacity) ; 
00106 
00107     public:
00109         static Material * createNoiseMaterial(std::map<std::string, std::string>);
00110 };
00111 
00112 Material * make_noise_material(std::map<std::string, std::string> props) {
00113     Scene * scene = Scene::get_instance();
00114     Material * one = scene->get_material(props["material1"]);
00115     Material * two = scene->get_material(props["material2"]);
00116     double noise_scale = 1.0;
00117     if(props.find("noise_scale") != props.end())
00118     {
00119         noise_scale = (double)strtod(props["noise_scale"].c_str(), NULL);
00120     }
00121     return new NoiseMaterial(one, two,noise_scale);
00122 }
00123 
00124 #endif

Generated on Tue Oct 30 22:12:15 2007 for mbrt by  doxygen 1.5.2