Scene.h
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @class Scene 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 Contains all primitive and material data representing a given 3D scene 00009 <!-------------------------------------------------------------------->**/ 00010 00011 #ifndef SCENE_H_ 00012 #define SCENE_H_ 00013 00014 #include <common/common.h> 00015 #include <materials/Material.h> 00016 #include <stats/samplers/EmitterSampler.h> 00017 00018 struct Ray; 00019 class SurfacePoint; 00020 class ShapeSet; 00021 00022 class Scene { 00023 public: 00024 ///@name Constructors 00025 //@{----------------------------------------------------------------- 00026 00027 inline explicit Scene(ShapeSet *shapeSet = NULL) 00028 : m_shapes(shapeSet), m_lights(NULL), m_background(NULL), 00029 m_emitterSampler(this), m_initted(false) 00030 { } 00031 00032 inline explicit Scene(const MaterialList &materials, 00033 ShapeSet *shapeSet = NULL) 00034 : m_shapes(shapeSet), m_lights(NULL), m_background(NULL), 00035 m_materials(materials), m_emitterSampler(this), m_initted(false) 00036 { } 00037 00038 virtual ~Scene(); 00039 00040 00041 //@}----------------------------------------------------------------- 00042 ///@name Initialization routines 00043 //@{----------------------------------------------------------------- 00044 00045 virtual void init(); 00046 00047 00048 //@}----------------------------------------------------------------- 00049 ///@name Main usage interface 00050 //@{----------------------------------------------------------------- 00051 00052 /** 00053 * @brief 00054 * Tests the given ray with this Shape for intersection. If a valid 00055 * intersection exists, its "t" value will be returned and the given 00056 * SurfacePoint will be initialized with enough data for this Shape to 00057 * later fill in all relevant information lazily (world space normal 00058 * at intersection point, uv coordinates, etc.) 00059 * 00060 * @note if you only care about whether or not an intersection exists 00061 * and don't actually need to know the exact intersection point, 00062 * see the intersects method instead. 00063 * @returns the smallest positive "t" value of any intersections 00064 * found, or INFINITY if no valid intersection exists 00065 */ 00066 virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt); 00067 00068 /** 00069 * @brief 00070 * Used for occlusion/visibility testing where you don't necessarily 00071 * care about anything other than whether or not an intersection exists. 00072 * (generally faster than getIntersection) 00073 * 00074 * @note default implementation defers to getIntersection 00075 * @returns whether or not the given ray intersects this Shape with a 00076 * positive "t" value greater than EPSILON and less than the given 00077 * @p tMax 00078 */ 00079 virtual bool intersects(const Ray &ray, real_t tMax = INFINITY); 00080 00081 /** 00082 * Displays a crude OpenGL preview of this scene 00083 */ 00084 virtual void preview(); 00085 00086 /** 00087 * @returns the environment or background radiance emitted from beyond 00088 * the extents of the scene in direction -w 00089 * 00090 * @note you can think of background emission as a large spherical 00091 * emitter surrounding the entire scene, emitting inwards 00092 */ 00093 virtual SpectralSampleSet getBackgroundRadiance(const Vector3 &w); 00094 00095 00096 //@}----------------------------------------------------------------- 00097 ///@name Accessors / Mutators 00098 //@{----------------------------------------------------------------- 00099 00100 inline ShapeSet *getShapes() { 00101 return m_shapes; 00102 } 00103 00104 inline ShapeSet *getLights() { 00105 return m_lights; 00106 } 00107 00108 inline EmitterSampler getEmitterSampler() const { 00109 return m_emitterSampler; 00110 } 00111 00112 inline Material *getDefaultMaterial() { 00113 ASSERT(m_materials.size() > 0); 00114 00115 return m_materials.back(); 00116 } 00117 00118 inline MaterialList &getMaterials() { 00119 return m_materials; 00120 } 00121 00122 inline Emitter *getBackground() { 00123 return m_background; 00124 } 00125 00126 inline void setBackground(Emitter *emitter) { 00127 m_background = emitter; 00128 } 00129 00130 inline bool isInitialized() const { 00131 return m_initted; 00132 } 00133 00134 00135 //@}----------------------------------------------------------------- 00136 00137 protected: 00138 ShapeSet *m_shapes; 00139 ShapeSet *m_lights; 00140 Emitter *m_background; 00141 00142 MaterialList m_materials; 00143 EmitterSampler m_emitterSampler; 00144 bool m_initted; 00145 }; 00146 00147 #endif // SCENE_H_ 00148
Generated on 28 Feb 2009 for Milton by
1.5.6