SuzanneIsland: An island of Real-time rendering effects!
geometry.h
1 #pragma once
2 
3 #include <vector>
4 #include <memory>
5 
6 #include <glm/gtc/type_ptr.hpp>
7 #include <assimp/Importer.hpp>
8 #include <assimp/postprocess.h>
9 #include <assimp/scene.h>
10 
11 #include "sceneobject.hpp"
12 #include "surface.h"
13 #include "shader.h"
14 #include "texture.hpp"
15 #include "camera.h"
16 
17 
19 class Geometry : public SceneObject
20 {
21 public:
22  Geometry(const glm::mat4 &matrix_, const std::string &filePath);
23  virtual ~Geometry();
24 
26  virtual void update(
27  float timeDelta
28  );
29 
31  virtual void draw(Shader *shader, Camera *camera, bool useFrustumCulling, Texture::FilterType filterType, const glm::mat4 &viewMat);
32 
42  glm::mat3 getNormalMatrix() const;
43 
46  glm::vec3 getBBMin();
49  glm::vec3 getBBMax();
50 
52  static int drawnSurfaceCount;
53 private:
55  std::vector<std::shared_ptr<Surface>> surfaces;
56 
58  std::string directoryPath;
59 
60  // pointers to all textures loaded by the surfaces of this geometry, to avoid loading twice
61  static std::vector<std::shared_ptr<Texture>> loadedTextures;
62 
64 
67  void loadSurfaces(
68  const std::string &filePath
69  );
70 
72  void processNode(
73  aiNode *node,
74  const aiScene *scene
75  );
76 
78 
81  void processMesh(
82  aiMesh *mesh,
83  const aiScene *scene
84  );
85 
87 
90  std::shared_ptr<Texture> loadMaterialTexture(
91  aiMaterial *mat,
92  aiTextureType type
93  );
94 };
95 
glm::vec3 getBBMax()
Returns max vertex of axis-aligned bounding box enclosing all surfaces.
Definition: geometry.cpp:29
virtual void update(float timeDelta)
Update the state of the SceneObject.
Definition: geometry.cpp:34
glm::vec3 getBBMin()
Returns min vertex of axis-aligned bounding box enclosing all surfaces.
Definition: geometry.cpp:24
glm::mat3 getNormalMatrix() const
return a the transposed inverse of the modelMatrix.
Definition: geometry.cpp:19
Shader class.
Definition: shader.h:15
A SceneObject that holds Surfaces containing mesh data and textures.
Definition: geometry.h:19
static int drawnSurfaceCount
The number of surfaces being drawn.
Definition: geometry.h:52
virtual void draw(Shader *shader, Camera *camera, bool useFrustumCulling, Texture::FilterType filterType, const glm::mat4 &viewMat)
draw the SceneObject using given shader
Definition: geometry.cpp:37
A base class for all scene objects.
Definition: sceneobject.hpp:15
A Camera is a SceneObject that maintains a view matrix, as well as parameters defining the projection...
Definition: camera.h:20