Molecule Visualizer
 All Classes Namespaces Files Functions Enumerations Enumerator Macros Groups Pages
scene.h
Go to the documentation of this file.
1 
7 #ifndef SCENE_H
8 #define SCENE_H
9 
10 #include "GL/glew.h"
11 #include "abstractscene.h"
12 #include "ShaderManager.hpp"
13 #include "ModelLoader.hpp"
14 
15 #include <QOpenGLShaderProgram>
16 #include <QOpenGLBuffer>
17 #include <QOpenGLVertexArrayObject>
18 
19 class Scene : public AbstractScene
20 {
21 public:
22 
26  Scene();
27 
31  virtual void initialize();
32 
36  virtual void compileShader();
37 
41  virtual void update(float t);
42 
46  virtual void render();
47 
51  virtual void resize(int width, int height);
52 
58 
59  virtual void rotateAzimuth(float t);
60 
61  virtual void rotatePolar(float t);
62 
63  float m_LightAzimuth;
64  float m_LightPolar;
65  bool m_bContourEnabled;
66  bool m_bContourConstant;
67  bool m_bAmbientOcclusion;
68  bool m_bShadowEnabled;
69  float m_fContourDepthFactor;
70  float m_fContourWidth;
71  float m_fAmbientFactor;
72  float m_fDiffuseFactor;
73  float m_fSpecularFactor;
74  float m_fNearPlane;
75  float m_fAmbientIntensity;
76 
77 public slots:
78 
79  virtual void setAmbientFactor(float ambientFactor);
80 
81  virtual void setDiffuseFactor(float diffuseFactor);
82 
83  virtual void setSpecularFactor(float specularFactor);
84 
85  virtual void setNearPlane(float nearPlane);
86 
87  virtual void setFarPlane(float farPlane);
88 
89  virtual void setAmbientOcclusion(bool value);
90 
91  virtual void setContourEnabled(bool value);
92 
93  virtual void setContourConstant(bool value);
94 
95  virtual void setDepthFactor(float depthFactor);
96 
97  virtual void setContourWidth(float width);
98 
99  virtual void setAmbientIntensity(float value);
100 
101  virtual void setShadowEnabled(bool value);
102 
103  virtual void switchAmbientOcclusionQuality(int quality);
104 
105 private:
106 
111  void drawMolecule();
112 
117  void drawTest();
118 
124  bool loadModelFromPath(const std::string absoluteFilePath);
125 
130  void createSamplingDirections();
131 
136  void generateFBO();
137 
138  void createSamplingViewMatrices();
139 
140  void createShadowCamera();
141 
142  int m_bAmbientOcclusionQuality;
143  int mSamplingDirectionsSize;
144  std::vector<glm::vec3> mSamplingDirectionsLow;
145  std::vector<glm::vec3> mSamplingDirectionsMedium;
146  std::vector<glm::vec3> mSamplingDirectionsHigh;
147  std::vector<glm::mat4> mSamplingViewMatrices;
148  glm::mat4 mSamplingProjectionMatrix;
149 
150  glm::vec3 m_LightDir;
151 
152  GLuint m_VBO_AmbientOcclusion;
153  GLuint m_Texture_DepthMap;
154  GLuint m_Texture_AmbientOcc;
155 
156  GLuint m_vao;
157  GLuint m_vbo;
158  GLuint m_ebo;
159  GLuint m_stdId;
160  GLuint m_ShaderID_DepthMap;
161  GLuint m_ShaderID_AmbOccl;
162 
163  ShaderManager *m_pShaderManager;
164 
165  bool m_bLoaded;
166  ModelLoader *m_pModelLoader;
167 
168  glm::mat4 m_projMatrix;
169  glm::mat4 m_modelViewMatrix;
170 
171  glm::mat4 m_ShadowProjMatrix;
172  glm::mat4 m_ShadowViewMatrix;
173 };
174 
175 #endif // SCENE_H
Definition: abstractscene.h:17
virtual void update(float t)
Overrides the abstract method in AbstractScene.
Definition: scene.cpp:147
Class for a ShaderManager.
virtual void compileShader()
Overrides the abstract method in AbstractScene.
Definition: scene.cpp:112
Scene()
Default constructor.
Definition: scene.cpp:57
Abstract class for a scene.
Definition: ShaderManager.hpp:13
virtual void initialize()
Overrides the abstract method in AbstractScene.
Definition: scene.cpp:88
Definition: scene.h:19
virtual void resize(int width, int height)
Overrides the abstract method in AbstractScene.
Definition: scene.cpp:160
Definition: ModelLoader.hpp:19
Class for a ModelLoader.
virtual void render()
Overrides the abstract method in AbstractScene.
Definition: scene.cpp:152
void renderAmbientOcclusion()
Renders the ambient occlusion effect.
Definition: scene.cpp:245