00001 00005 #ifndef Scene_h 00006 #define Scene_h 00007 00008 #include "Color.h" 00009 #include <string> 00010 #include <vector> 00011 00012 class Background; 00013 class Camera; 00014 class Color; 00015 class Image; 00016 class Light; 00017 class Object; 00018 class RenderContext; 00019 class Ray; 00020 00021 class Scene { 00022 public: 00023 Scene(); 00024 virtual ~Scene(); 00025 00026 inline Object* getObject() const { 00027 return object; 00028 } 00029 void setObject(Object* obj) { 00030 object = obj; 00031 } 00032 00033 inline Background* getBackground() const { 00034 return background; 00035 } 00036 void setBackground(Background* bg) { 00037 background = bg; 00038 } 00039 00040 inline Camera* getCamera() const { 00041 return camera; 00042 } 00043 void setCamera(Camera* cam) { 00044 camera = cam; 00045 } 00046 00047 inline Image* getImage() const { 00048 return image; 00049 } 00050 void setImage(Image* im) { 00051 image = im; 00052 } 00053 00054 void addLight(Light* light) { 00055 lights.push_back(light); 00056 } 00057 const std::vector<Light*>& getLights() const { 00058 return lights; 00059 } 00060 00061 Color getAmbient() const { 00062 return ambient; 00063 } 00064 void setAmbient(const Color& amb) { 00065 ambient = amb; 00066 } 00067 00068 int getMaxRayDepth() const { 00069 return maxRayDepth; 00070 } 00071 void setMaxRayDepth(int rd) { 00072 maxRayDepth = rd; 00073 } 00074 double getMinAttenuation() const { 00075 return minAttenuation; 00076 } 00077 void setMinAttenuation(double atten) { 00078 minAttenuation = atten; 00079 } 00080 00081 void preprocess(); 00082 void render(); 00083 double traceRay(Color& result, const RenderContext& context, const Ray& ray, const Color& attenuation, int depth) const; 00084 double traceRay(Color& result, const RenderContext& context, const Object* obj, const Ray& ray, const Color& attenuation, int depth) const; 00085 00086 private: 00087 Scene(const Scene&); 00088 Scene& operator=(const Scene&); 00089 00090 Background* background; 00091 Camera* camera; 00092 Color ambient; 00093 Image* image; 00094 Object* object; 00095 std::vector<Light*> lights; 00096 int maxRayDepth; 00097 double minAttenuation; 00098 00099 }; 00100 00101 #endif