Nori

include/nori/scene.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Nori, a simple educational ray tracer
00003 
00004     Copyright (c) 2012 by Wenzel Jakob and Steve Marschner.
00005 
00006     Nori is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License Version 3
00008     as published by the Free Software Foundation.
00009 
00010     Nori is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #if !defined(__SCENE_H)
00020 #define __SCENE_H
00021 
00022 #include <nori/kdtree.h>
00023 
00024 NORI_NAMESPACE_BEGIN
00025 
00026 /**
00027  * \brief Main scene data structure
00028  *
00029  * This class holds information on scene objects and is responsible for
00030  * coordinating rendering jobs. It also provides useful query routines that 
00031  * are mostly used by the \ref Integrator implementations.
00032  */
00033 class Scene : public NoriObject {
00034 public:
00035         /// Construct a new scene object
00036         Scene(const PropertyList &);
00037         
00038         /// Release all memory
00039         virtual ~Scene();
00040 
00041         /// Return a pointer to the scene's kd-tree
00042         inline const KDTree *getKDTree() const { return m_kdtree; }
00043 
00044         /// Return a pointer to the scene's integrator
00045         inline const Integrator *getIntegrator() const { return m_integrator; }
00046         
00047         /// Return a pointer to the scene's camera
00048         inline const Camera *getCamera() const { return m_camera; }
00049         
00050         /// Return a pointer to the scene's sample generator (const version)
00051         inline const Sampler *getSampler() const { return m_sampler; }
00052         
00053         /// Return a pointer to the scene's sample generator
00054         inline Sampler *getSampler() { return m_sampler; }
00055 
00056         /// Return a reference to an array containing all meshes
00057         inline const std::vector<Mesh *> &getMeshes() const { return m_meshes; }
00058 
00059         /**
00060          * \brief Intersect a ray against all triangles stored in the scene
00061          * and return detailed intersection information
00062          *
00063          * \param ray
00064          *    A 3-dimensional ray data structure with minimum/maximum
00065          *    extent information
00066          *
00067          * \param its
00068          *    A detailed intersection record, which will be filled by the
00069          *    intersection query
00070          *
00071          * \return \c true if an intersection was found
00072          */
00073         inline bool rayIntersect(const Ray3f &ray, Intersection &its) const {
00074                 return m_kdtree->rayIntersect(ray, its, false);
00075         }
00076 
00077         /**
00078          * \brief Intersect a ray against all triangles stored in the scene
00079          * and \a only determine whether or not there is an intersection.
00080          * 
00081          * This method much faster than the other ray tracing function,
00082          * but the performance comes at the cost of not providing any
00083          * additional information about the detected intersection 
00084          * (not even its position).
00085          *
00086          * \param ray
00087          *    A 3-dimensional ray data structure with minimum/maximum
00088          *    extent information
00089          *
00090          * \return \c true if an intersection was found
00091          */
00092         inline bool rayIntersect(const Ray3f &ray) const {
00093                 Intersection its; /* Unused */
00094                 return m_kdtree->rayIntersect(ray, its, true);
00095         }
00096 
00097         /**
00098          * \brief Return an axis-aligned box that bounds the scene
00099          */
00100         inline const BoundingBox3f &getBoundingBox() const {
00101                 return m_kdtree->getBoundingBox();
00102         }
00103 
00104         /**
00105          * \brief Inherited from \ref NoriObject::activate()
00106          *
00107          * Initializes the internal data structures (kd-tree,
00108          * luminaire sampling data structures, etc.)
00109          */
00110         void activate();
00111 
00112         /// Add a child object to the scene (meshes, integrators etc.)
00113         void addChild(NoriObject *obj);
00114 
00115         /// Return a brief string summary of the instance (for debugging purposes)
00116         QString toString() const;
00117 
00118         EClassType getClassType() const { return EScene; }
00119 private:
00120         std::vector<Mesh *> m_meshes;
00121         Integrator *m_integrator;
00122         Sampler *m_sampler;
00123         Camera *m_camera;
00124         KDTree *m_kdtree;
00125 };
00126 
00127 NORI_NAMESPACE_END
00128 
00129 #endif /* __SCENE_H */
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines