MobileRT  1.0
A multi platform C++ CPU progressive Ray Tracer.
Scene.hpp
Go to the documentation of this file.
1 #ifndef MOBILERT_SCENE_HPP
2 #define MOBILERT_SCENE_HPP
3 
6 #include "MobileRT/Light.hpp"
7 #include "MobileRT/Material.hpp"
8 #include "MobileRT/Ray.hpp"
12 #include "MobileRT/Utils/Utils.hpp"
13 #include <glm/glm.hpp>
14 #include <vector>
15 
16 namespace MobileRT {
20  class Scene final {
21  public:
22  ::std::vector<Triangle> triangles_ {};
23  ::std::vector<Sphere> spheres_ {};
24  ::std::vector<Plane> planes_ {};
25  ::std::vector<::std::unique_ptr<Light>> lights_ {};
26  ::std::vector<Material> materials_ {};
27 
28  private:
29  static ::MobileRT::AABB getBoxBounds(const AABB &box1, const AABB &box2);
30 
31  public:
32  explicit Scene() = default;
33 
34  Scene(const Scene &scene) = delete;
35 
36  Scene(Scene &&scene) noexcept = default;
37 
38  ~Scene();
39 
40  Scene &operator=(const Scene &scene) = delete;
41 
42  Scene &operator=(Scene &&scene) noexcept = default;
43 
51  template<typename T>
52  static ::MobileRT::AABB getBounds(const ::std::vector<T> &primitives) {
53  ::MobileRT::AABB bounds {::glm::vec3 {RayLengthMax}, ::glm::vec3 {-RayLengthMax}};
54  for (const T &primitive : primitives) {
55  bounds = getBoxBounds(primitive.getAABB(), bounds);
56  }
57  const ::MobileRT::AABB res {
58  bounds.getPointMin() - ::glm::vec3 {Epsilon},
59  bounds.getPointMax() + ::glm::vec3 {Epsilon}
60  };
61  return res;
62  }
63  };
64 }//namespace MobileRT
65 
66 #endif //MOBILERT_SCENE_HPP
const float RayLengthMax
Definition: Constants.hpp:33
Scene()=default
Scene & operator=(const Scene &scene)=delete
::std::vector<::std::unique_ptr< Light > > lights_
Definition: Scene.hpp:25
::std::vector< Sphere > spheres_
Definition: Scene.hpp:23
::std::vector< Material > materials_
Definition: Scene.hpp:26
Definition: Scene.hpp:20
const AABB box1
Definition: TestAABB.cpp:21
::MobileRT::AABB getBoxBounds(const AABB &box1, const AABB &box2)
Definition: Scene.cpp:36
const float Epsilon
Definition: Constants.hpp:22
Definition: AABB.hpp:18
~Scene()
Definition: Scene.cpp:13
::std::vector< Plane > planes_
Definition: Scene.hpp:24
::MobileRT::AABB getBounds(const ::std::vector< T > &primitives)
Definition: Scene.hpp:52
::std::vector< Triangle > triangles_
Definition: Scene.hpp:22
::glm::vec3 getPointMin() const
Definition: AABB.cpp:92
Definition: AABB.cpp:105