VisPro  1.0
Project of Visualisierung 2
Mesh.h
Go to the documentation of this file.
1 #pragma once
2 
7 #include "glm.hpp"
8 #include <list>
9 #include <vector>
10 
11 #include "Shader.h"
12 #include "../VisPro/CutawaySurface.h"
13 #include "Face.h"
14 #include "BoundingBox.h"
15 
16 class Mesh {
17 public:
18  glm::mat4 model_matrix;
19 
20  // Constructor + destructor
21  Mesh(std::vector<glm::vec3>& v, std::vector<glm::vec3>& n, std::vector<Face*>& f, std::vector<glm::vec2>& uv, Shader* shader ,glm::mat4& model_m);
22  virtual ~Mesh();
23 
24  // Update methods
28  virtual void update(float delta_t);
29  void rotateLocally(float delta_t, glm::vec3 axis);
30  void rotateAroundCenter(glm::vec3& world_center, float angle, glm::vec3 axis);
31 
32  // Needed for Physics
33  std::vector<glm::vec3> getNormals();
34  std::vector<glm::vec3> getVertices();
35  std::vector<GLuint> getIndices();
36 
37  // Z buffer pass methods
42  void zBufferPass(ZBufferShader* z, glm::mat4& vp);
43 
48  void setUniformsForZBufferPass(ZBufferShader* z, glm::mat4& vp);
49 
52  void renderToZBuffer();
53 
54  // Render pass methods
61  void renderPass(const CutawaySurface* c, glm::mat4& vp, glm::vec3 cam, float clip);
62 
68  void setUniformsForRenderPass(glm::mat4& vp, glm::vec3 cam, float clip);
69 
72  virtual void draw();
73 
74  // Initial settings
75  void setLighting(std::vector<std::shared_ptr<PointLight>> *allLights);
76  void setCutawayDimension(glm::vec2 dim);
77  void setShader(Shader* s);
78 
79  BoundingBox* calcBoundingBoxWithApplying();
80  BoundingBox* calcBoundingBoxWithOutApplying();
81  glm::vec3 getRelativePosition(glm::vec3 p);
82 
83  GLuint f_count; //number of faces
84 private:
85 
86  // Vertex data
87  std::vector<glm::vec3> vertices; // Vertex positions
88  std::vector<glm::vec3> normals; // Vertex normals
89  std::vector<glm::vec2> uvs; // Vertex uv coords
90  std::vector<GLuint> indices; // Vertex indices
91  GLuint v_count, index_count; // Counts
92 
93  // Faces
94  const std::vector<Face*> faces;
95 
96  // Vertex buffer objects
97  GLuint pos_vbo, normal_vbo, uv_vbo, index_vbo;
98 
99  // Vertex array object
100  GLuint vao;
101 
102  // Shader
103  Shader* shader;
104 
105  const float* Mesh::vec3ToFloatArray(std::list<glm::vec3*>& vectors);
106 
107 
108 
109 };
void renderPass(const CutawaySurface *c, glm::mat4 &vp, glm::vec3 cam, float clip)
Definition: Mesh.cpp:130
Definition: Mesh.h:16
void renderToZBuffer()
Definition: Mesh.cpp:124
virtual void draw()
Definition: Mesh.cpp:166
Shader base class file.
void setUniformsForRenderPass(glm::mat4 &vp, glm::vec3 cam, float clip)
Definition: Mesh.cpp:137
virtual void update(float delta_t)
Definition: Mesh.cpp:172
Definition: BoundingBox.h:4
Definition: CutawaySurface.h:14
void zBufferPass(ZBufferShader *z, glm::mat4 &vp)
Definition: Mesh.cpp:112
Definition: Shader.h:18
Definition: ZBufferShader.h:11
void setUniformsForZBufferPass(ZBufferShader *z, glm::mat4 &vp)
Definition: Mesh.cpp:118