Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Scene.hpp
1#pragma once
2
3#include "scene/Object.hpp"
4#include "scene/Material.hpp"
5#include "scene/LightProbe.hpp"
6#include "lights/Light.hpp"
7
8#include "resources/ResourcesManager.hpp"
9#include "input/Camera.hpp"
10#include "system/Codable.hpp"
11
12#include "Common.hpp"
13
18class Scene {
19
20public:
21
25 explicit Scene(const std::string & name);
26
31 bool init(Storage options);
32
37 void update(double fullTime, double frameTime);
38
42 std::vector<KeyValues> encode() const;
43
47 const BoundingBox & boundingBox() const { return _bbox; }
48
52 const Camera & viewpoint() const { return _camera; }
53
57 void setViewpoint(const Camera & cam) { _camera = cam; }
58
60 bool animated() const { return _animated; }
61
63 bool transparent() const { return _transparent; }
64
65 std::vector<Object> objects;
66 std::vector<Material> materials;
67 std::vector<std::shared_ptr<Light>> lights;
68
70 enum class Background {
71 COLOR,
72 IMAGE,
73 SKYBOX,
75 };
77 std::unique_ptr<Object> background;
78 std::vector<LightProbe> probes;
79
81 Scene(const Scene &) = delete;
82
86 Scene & operator=(const Scene &) = delete;
87
89 Scene(Scene &&) = delete;
90
94 Scene & operator=(Scene &&) = delete;
95
96private:
102 bool loadObject(const KeyValues & params, Storage options);
103
109 bool loadMaterial(const KeyValues & params, Storage options);
110
116 bool loadLight(const KeyValues & params, Storage options);
117
123 bool loadCamera(const KeyValues & params, Storage options);
124
130 bool loadBackground(const KeyValues & params, Storage options);
131
137 bool loadProbe(const KeyValues & params, Storage options);
138
144 bool loadScene(const KeyValues & params, Storage options);
145
150 void computeBoundingBoxes(BoundingBox & globalBox, BoundingBox & casterBox);
151
155 glm::mat4 _sceneModel = glm::mat4(1.0f);
156 std::string _name;
157 bool _loaded = false;
158 bool _animated = false;
159 bool _transparent = false;
160};
Represent the smallest axis-aligne box containing a given object or region of space.
Definition: Bounds.hpp:28
This class represents a camera as used in real-time rendering APIs. It provides a view and projection...
Definition: Camera.hpp:11
Represent a surface material, including textures describing the surface parameters.
Definition: Material.hpp:72
Represents a 3D environment composed of objects, a background and additional environment lighting inf...
Definition: Scene.hpp:18
Camera _camera
The initial viewpoint on the scene.
Definition: Scene.hpp:153
bool _loaded
Has the scene already been loaded from disk.
Definition: Scene.hpp:157
bool loadMaterial(const KeyValues &params, Storage options)
Definition: Scene.cpp:138
Material _backgroundMaterial
Background material, containing the optional textures to use.
Definition: Scene.hpp:152
void update(double fullTime, double frameTime)
Definition: Scene.cpp:309
std::vector< KeyValues > encode() const
Definition: Scene.cpp:224
Background backgroundMode
The background mode (see enum).
Definition: Scene.hpp:76
std::vector< LightProbe > probes
Reflection probes.
Definition: Scene.hpp:78
Background
The background mode to use for a scene.
Definition: Scene.hpp:70
@ COLOR
Use a unique color as background.
@ IMAGE
Use a 2D texture image as background (will be stretched).
@ ATMOSPHERE
Use a realtime atmospheric scattering simulation.
@ SKYBOX
Use a skybox/cubemap as background.
void computeBoundingBoxes(BoundingBox &globalBox, BoundingBox &casterBox)
Definition: Scene.cpp:287
bool loadScene(const KeyValues &params, Storage options)
Definition: Scene.cpp:218
std::unique_ptr< Object > background
Background object, containing the geometry to use.
Definition: Scene.hpp:77
bool loadProbe(const KeyValues &params, Storage options)
Definition: Scene.cpp:213
bool animated() const
Definition: Scene.hpp:60
void setViewpoint(const Camera &cam)
Definition: Scene.hpp:57
BoundingBox _bbox
The scene bounding box.
Definition: Scene.hpp:154
const Camera & viewpoint() const
Definition: Scene.hpp:52
std::vector< Material > materials
The materials in the scene.
Definition: Scene.hpp:66
bool transparent() const
Definition: Scene.hpp:63
Scene(const Scene &)=delete
bool loadLight(const KeyValues &params, Storage options)
Definition: Scene.cpp:143
const BoundingBox & boundingBox() const
Definition: Scene.hpp:47
Scene & operator=(Scene &&)=delete
std::vector< Object > objects
The objects in the scene.
Definition: Scene.hpp:65
Scene & operator=(const Scene &)=delete
bool loadCamera(const KeyValues &params, Storage options)
Definition: Scene.cpp:152
bool loadObject(const KeyValues &params, Storage options)
Definition: Scene.cpp:133
Scene(Scene &&)=delete
std::vector< std::shared_ptr< Light > > lights
Lights present in the scene.
Definition: Scene.hpp:67
glm::mat4 _sceneModel
The scene global transformation.
Definition: Scene.hpp:155
bool _transparent
Is the scene containing transparent objects.
Definition: Scene.hpp:159
bool _animated
Is the scene using animations.
Definition: Scene.hpp:158
bool init(Storage options)
Definition: Scene.cpp:31
bool loadBackground(const KeyValues &params, Storage options)
Definition: Scene.cpp:156
std::string _name
The scene file name.
Definition: Scene.hpp:156
Storage
Storage and loading options.
Definition: ResourcesManager.hpp:14
Represent a key-values tuple.
Definition: Config.hpp:9