ComputerGraphik TU WIEN
scene.hpp
Go to the documentation of this file.
1 #ifndef SCENE_HPP
2 #define SCENE_HPP
3 
4 #include <map>
5 #include <string>
6 #include <memory>
7 #include <vector>
8 
9 class Debug;
10 class Model;
11 class Light;
12 class Shader;
13 class Camera;
14 class Texture;
15 class SelectorGPU;
16 class SelectorQuadTree;
17 class SceneObject;
18 class SunVolumetric;
19 class CubeMapObject;
20 class LightCamera;
21 class MouseSemantics;
22 class SelectorBase;
23 class Legend;
24 class BubbleCursor;
25 struct GLFWwindow;
26 
28 
71 class Scene {
72 public:
73  enum { SentinelPre = 0,
74  SentinelDraw = 1000,
76  SentinelPost = 2000,
78 
79  typedef std::map<std::size_t, std::shared_ptr<SceneObject> >::const_iterator ConstIterator;
80 
81  Scene(GLFWwindow* window);
82  ~Scene();
83 
84  void init(const std::string& scenePath);
85 
86  void clearRender();
87  void remRender(std::shared_ptr<SceneObject>& object);
88  void getRender(size_t idx, std::shared_ptr<SceneObject>& object) const;
89  size_t pushRender(std::shared_ptr<SceneObject>& object, size_t idx = SentinelUnordered);
90  size_t insertRender(std::shared_ptr<SceneObject>& object, size_t idx = SentinelUnordered);
91 
92  Shader* getShader(const std::string& name) const;
93  void addShader(const std::string& name, std::unique_ptr<Shader>& shader);
94  void changeRenderShader(const std::string& from, const std::string& to);
95 
96  GLFWwindow* getWindow() const { return window; }
97  std::shared_ptr<Light> getLight() const { return light; }
98  std::shared_ptr<Camera> getCamera() const { return camera; }
99  std::shared_ptr<SceneObject> getRootNode() const { return rootNode; }
100  std::shared_ptr<CubeMapObject> getCubeMapObject() const { return cmObject; }
101  std::shared_ptr<LightCamera> getLightCam() const { return lightCam; }
102  std::shared_ptr<SunVolumetric> getSunVolumetric() const { return sunVolumetric; }
103  std::shared_ptr<MouseSemantics> getMouseSemantics() const { return mouseSemantics; }
104  std::shared_ptr<SelectorBase> getActiveSelector() const { return activeSelector; }
105  std::shared_ptr<Legend> getLegend() const { return legend; }
106  std::shared_ptr<BubbleCursor> getBubbleCursor() const { return bubbleCursor; }
107  bool getObject(const std::string& name, std::shared_ptr<SceneObject>& object, size_t pos = 1) const;
108 
109  void setWindow(GLFWwindow* val) { window = val; }
110  void setLight(std::shared_ptr<Light> val) { light = val; }
111  void setCamera(std::shared_ptr<Camera> val) { camera = val; }
112  void setRootNode(std::shared_ptr<SceneObject> root) { rootNode = root; }
113  void setCubeMapObject(std::shared_ptr<CubeMapObject> val) { cmObject = val; }
114  void setLightCam(std::shared_ptr<LightCamera> val) { lightCam = val; }
115  void setSunVolumetric(std::shared_ptr<SunVolumetric> val) { sunVolumetric = val; }
116  void setMouseSemantics(std::shared_ptr<MouseSemantics> val) { mouseSemantics = val; }
117  void setActiveSelector(std::shared_ptr<SelectorBase> val) { activeSelector = val; }
118  void setLegend(std::shared_ptr<Legend> val) { legend = val; }
119  void setBubbleCursor(std::shared_ptr<BubbleCursor> val) { bubbleCursor = val; }
120 
121  ConstIterator end() const { return renderList.cend(); }
122  ConstIterator begin() const { return renderList.cbegin(); }
123  ConstIterator end(size_t idx) const { return renderList.lower_bound(idx); }
124  ConstIterator begin(size_t idx) const { return renderList.lower_bound(idx); }
125  //static void draw(const ConstIterator& it) { it->second->draw(it->first); }
126  static std::shared_ptr<SceneObject> get(const ConstIterator& it) { return it->second; }
127 
128 private:
129  friend class Debug; //direct access to textures
130  friend class AssimpLoader; //direct access to models and textures
131 
132  GLFWwindow* window;
133  std::shared_ptr<Light> light;
134  std::shared_ptr<Camera> camera;
135  std::shared_ptr<CubeMapObject> cmObject;
136  std::shared_ptr<LightCamera> lightCam;
137  std::shared_ptr<SunVolumetric> sunVolumetric;
138  std::shared_ptr<MouseSemantics> mouseSemantics;
139  std::shared_ptr<SelectorBase> activeSelector;
140  std::shared_ptr<Legend> legend;
141  std::shared_ptr<BubbleCursor> bubbleCursor;
142 
143  std::shared_ptr<SceneObject> rootNode;
144  std::map<std::string, std::unique_ptr<Model> > models;
145  std::map<std::string, std::unique_ptr<Shader> > shaders;
146  std::map<std::string, std::unique_ptr<Texture> > textures;
147  std::map<std::size_t, std::shared_ptr<SceneObject> > renderList;
148 
149  bool getObjectRecursive(const std::string& name, std::shared_ptr<SceneObject>& object, size_t& pos) const;
150 };
151 
152 #endif //SCENE_HPP
GLFWwindow * getWindow() const
Definition: scene.hpp:96
void setLightCam(std::shared_ptr< LightCamera > val)
Definition: scene.hpp:114
std::shared_ptr< Legend > getLegend() const
Definition: scene.hpp:105
Definition: scene.hpp:73
std::shared_ptr< Camera > camera
Definition: scene.hpp:134
Definition: sunVolumetric.hpp:14
void remRender(std::shared_ptr< SceneObject > &object)
Definition: scene.cpp:94
The class which is responsible for loading all the details to build up a scene.
Definition: assimpLoader.hpp:23
Displays a Legend that contains text.
Definition: legend.hpp:105
Encapsulates a graphical object model in the GPU.
Definition: model.hpp:14
std::shared_ptr< LightCamera > getLightCam() const
Definition: scene.hpp:101
std::map< std::string, std::unique_ptr< Shader > > shaders
Definition: scene.hpp:145
std::shared_ptr< SunVolumetric > sunVolumetric
Definition: scene.hpp:137
std::shared_ptr< Light > getLight() const
Definition: scene.hpp:97
void setWindow(GLFWwindow *val)
Definition: scene.hpp:109
ConstIterator begin() const
Definition: scene.hpp:122
Used for further implementations of light in the scene (Sun is a direct derivation).
Definition: light.hpp:16
void setBubbleCursor(std::shared_ptr< BubbleCursor > val)
Definition: scene.hpp:119
std::shared_ptr< Light > light
Definition: scene.hpp:133
std::shared_ptr< SelectorBase > activeSelector
Definition: scene.hpp:139
void clearRender()
Definition: scene.cpp:77
~Scene()
Definition: scene.cpp:41
std::shared_ptr< LightCamera > lightCam
Definition: scene.hpp:136
std::map< std::string, std::unique_ptr< Texture > > textures
Definition: scene.hpp:146
std::shared_ptr< SelectorBase > getActiveSelector() const
Definition: scene.hpp:104
void setSunVolumetric(std::shared_ptr< SunVolumetric > val)
Definition: scene.hpp:115
Implements the camera movement with user input.
Definition: camera.hpp:11
void setMouseSemantics(std::shared_ptr< MouseSemantics > val)
Definition: scene.hpp:116
Shader * getShader(const std::string &name) const
Definition: scene.cpp:170
ConstIterator end(size_t idx) const
Definition: scene.hpp:123
std::shared_ptr< SunVolumetric > getSunVolumetric() const
Definition: scene.hpp:102
void changeRenderShader(const std::string &from, const std::string &to)
Definition: scene.cpp:82
Definition: lightCamera.hpp:13
std::shared_ptr< SceneObject > rootNode
Definition: scene.hpp:143
Definition: scene.hpp:76
std::shared_ptr< Legend > legend
Definition: scene.hpp:140
std::shared_ptr< CubeMapObject > cmObject
Definition: scene.hpp:135
Scene(GLFWwindow *window)
Definition: scene.cpp:33
Encapsulates the Rendering Engine, holds a complete scene and it's assets.
Definition: scene.hpp:71
Definition: scene.hpp:75
void setCamera(std::shared_ptr< Camera > val)
Definition: scene.hpp:111
void addShader(const std::string &name, std::unique_ptr< Shader > &shader)
Definition: scene.cpp:178
void setCubeMapObject(std::shared_ptr< CubeMapObject > val)
Definition: scene.hpp:113
std::map< std::size_t, std::shared_ptr< SceneObject > > renderList
Definition: scene.hpp:147
std::shared_ptr< MouseSemantics > getMouseSemantics() const
Definition: scene.hpp:103
std::shared_ptr< SceneObject > getRootNode() const
Definition: scene.hpp:99
std::shared_ptr< BubbleCursor > getBubbleCursor() const
Definition: scene.hpp:106
Encapsulates a texture in the GPU.
Definition: texture.hpp:10
bool getObject(const std::string &name, std::shared_ptr< SceneObject > &object, size_t pos=1) const
Definition: scene.cpp:51
void setLight(std::shared_ptr< Light > val)
Definition: scene.hpp:110
std::shared_ptr< MouseSemantics > mouseSemantics
Definition: scene.hpp:138
void init(const std::string &scenePath)
Definition: scene.cpp:46
size_t insertRender(std::shared_ptr< SceneObject > &object, size_t idx=SentinelUnordered)
Definition: scene.cpp:147
void getRender(size_t idx, std::shared_ptr< SceneObject > &object) const
Definition: scene.cpp:122
This class is rendering multiple circles (called bubbles in the paper) that are randomly placed on th...
Definition: bubbleCursor.hpp:47
Encapsulates a shader program.
Definition: shader.hpp:9
Definition: scene.hpp:77
std::map< std::size_t, std::shared_ptr< SceneObject > >::const_iterator ConstIterator
Definition: scene.hpp:79
GLFWwindow * window
Definition: scene.hpp:132
ConstIterator end() const
Definition: scene.hpp:121
std::shared_ptr< CubeMapObject > getCubeMapObject() const
Definition: scene.hpp:100
Implements the QuadTree based object selection.
Definition: selectorQuadTree.hpp:105
The base class of the objects which are rendered.
Definition: sceneObject.hpp:30
void setLegend(std::shared_ptr< Legend > val)
Definition: scene.hpp:118
Definition: scene.hpp:74
The switches to experiment OpenGL performance and quality are implemented here.
Definition: debug.hpp:11
void setRootNode(std::shared_ptr< SceneObject > root)
Definition: scene.hpp:112
Base class for selectors.
Definition: selectorBase.hpp:15
The class which handles the drawing of the cursor as well as the semantic scaling function that trans...
Definition: mouseSemantics.hpp:49
void setActiveSelector(std::shared_ptr< SelectorBase > val)
Definition: scene.hpp:117
bool getObjectRecursive(const std::string &name, std::shared_ptr< SceneObject > &object, size_t &pos) const
Definition: scene.cpp:60
size_t pushRender(std::shared_ptr< SceneObject > &object, size_t idx=SentinelUnordered)
Definition: scene.cpp:133
ConstIterator begin(size_t idx) const
Definition: scene.hpp:124
Implements the GPU based object selection.
Definition: selectorGPU.hpp:41
Definition: cubeMapObject.hpp:14
std::shared_ptr< BubbleCursor > bubbleCursor
Definition: scene.hpp:141
std::shared_ptr< Camera > getCamera() const
Definition: scene.hpp:98
std::map< std::string, std::unique_ptr< Model > > models
Definition: scene.hpp:144