scene.h

Go to the documentation of this file.
00001 
00002 #ifndef SCENE_H
00003 #define SCENE_H
00004 
00005 #include "raytrace_defs.h"
00006 #include <map>
00007 #include <vector>
00008 #include <string>
00009 #include <Magick++.h>
00010 
00012 const int MAX_DEPTH = 15;
00013 
00014 class Ray;
00015 class Renderable;
00016 class Point3D;
00017 class Material;
00018 class BumpMap;
00019 
00020 //{{{
00024 class Scene {
00025     protected:
00027         static Scene * inst;
00028 
00030         std::vector<Renderable *> scene;
00031 
00033         std::map<std::string, Material *> m_materials;
00034         
00036         std::map<std::string, BumpMap *> m_bumpmaps;
00037         
00039         Point3D camera;
00040 
00042         int pixel_width;
00043 
00045         int pixel_height;
00046 
00048         std::string output_filename;
00049 
00051         int subpixels;
00052 
00054         int max_depth;
00055 
00057         Scene();
00058 
00059 
00060     public:
00066         static Scene * get_instance(std::string scene_file_name = "");
00067 
00069         ~Scene();
00070 
00072         inline std::vector<Renderable *> * get_scene() { return &scene; }
00073 
00081         Renderable * find_collision(const Ray &ray, double &dist) const;
00082 
00086         Point3D get_camera () const { return camera; }
00087         void set_camera (double x, double y, double z) { camera = Point3D(x, y, z); }
00088 
00092         std::string get_output_filename() const { return output_filename; }
00093         void set_output_filename(std::string fname) { output_filename = fname; }
00094 
00096         int get_viewport_pixel_width() const { return pixel_width; }
00097         void set_pixel_width(int pxwidth) { pixel_width = pxwidth; }
00098 
00100         int get_viewport_pixel_height() const { return pixel_height; }
00101         void set_pixel_height(int pxheight) { pixel_height = pxheight; }
00102 
00104         int get_subpixel_sqrt() const { return subpixels; }
00105         void set_subpixel_sqrt(int subpx_sqrt) { subpixels = subpx_sqrt; }
00106 
00108         int get_max_recurse_depth() const { return max_depth; }
00110         void set_max_recurse_depth(int recurse_depth) { max_depth = recurse_depth < MAX_DEPTH? recurse_depth: MAX_DEPTH; }
00111 
00114         Magick::Color get_color(std::string name) { return Magick::Color(name); }
00115 
00118         Material * get_material(std::string name) { return m_materials[name]; }
00119 
00121         void add_material(std::string name, Material * material) { m_materials[name] = material; }
00122         
00124         void add_primitive(Renderable * prim) { scene.push_back(prim); }
00125         
00127         void add_bumpmap(std::string name, BumpMap * bumpmap) { m_bumpmaps[name] = bumpmap; }
00128         
00131         BumpMap * get_bumpmap(std::string name) { return m_bumpmaps[name]; }
00132 
00135         std::string get_geometry();
00136 };
00137 //}}}
00138 
00139 #endif

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