PGR Copakond OpenGL Engine - Bowling
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
1#ifndef PGR_SEM_COPAKOND_MESH_H
2#define PGR_SEM_COPAKOND_MESH_H
3
4#include <memory>
5
6#include "../pgr-portable.h"
9
10namespace copakond {
12 struct SubMesh {
13 std::shared_ptr<Material> material;
14 unsigned int indexOffset;
15 unsigned int indexCount;
16 };
17
19 class Mesh : public Geometry {
20 protected:
21 static int globalMeshCounter;
22 int id;
23 int _isVertexWave = false;
24 bool _visible = true;
25
26 GLuint _shaderProgram = 0;
27 GLuint _vboVertices = 0;
28 GLuint _vboNormals = 0;
29 GLuint _vao = 0;
30
31 GLsizei _numVertices = 0;
32
33 std::vector<float> _vertices = std::vector<float>();
34 std::shared_ptr<Material> _material = std::make_shared<Material>();
35 std::vector<SubMesh> _subMeshes;
36
37 void _SetId();
38
39 public:
40 Mesh();
41 Mesh(const glm::vec3 &position);
42 Mesh(const glm::vec3 &position, const glm::vec3 &rotation);
43 Mesh(const glm::vec3 &position, const glm::vec3 &rotation, const glm::vec3 &scale);
44 virtual ~Mesh();
45
46 void setVertices(const std::vector<float> &vertices);
47
49 void setMaterial(const std::shared_ptr<Material> &material);
50 const std::vector<SubMesh>& getSubMeshes() const { return _subMeshes; }
51 std::shared_ptr<Material> getMaterial();
52
53 GLuint getVao() const { return _vao; }
54 GLsizei getNumVertices() const { return _numVertices; }
55
60 virtual void init(GLuint shader);
61 virtual void draw(float deltaTime);
62 int getId() const { return id; }
63
65 bool isVertexWave() const { return _isVertexWave; }
66
67 void hide() { _visible = false; }
68 void show() { _visible = true; }
69 void setVisible(bool visible) { _visible = visible; }
70 bool isVisible() const { return _visible; }
71 };
72}
73
74#endif //PGR_SEM_COPAKOND_MESH_H
glm::vec3 & rotation()
Definition geometry.h:61
Geometry()
Definition geometry.cpp:4
glm::vec3 & scale()
Definition geometry.h:62
glm::vec3 & position()
Definition geometry.h:60
GLuint _shaderProgram
Definition mesh.h:26
void hide()
Definition mesh.h:67
int _isVertexWave
Definition mesh.h:23
std::vector< SubMesh > _subMeshes
Definition mesh.h:35
std::shared_ptr< Material > getMaterial()
Definition mesh.cpp:36
bool _visible
Definition mesh.h:24
void setVertices(const std::vector< float > &vertices)
Definition mesh.cpp:26
std::shared_ptr< Material > _material
Definition mesh.h:34
GLuint _vboNormals
Definition mesh.h:28
GLuint _vao
Definition mesh.h:29
const std::vector< SubMesh > & getSubMeshes() const
Definition mesh.h:50
void show()
Definition mesh.h:68
int id
Definition mesh.h:22
GLuint getVao() const
Definition mesh.h:53
GLuint _vboVertices
Definition mesh.h:27
bool isVertexWave() const
Definition mesh.h:65
int getId() const
Definition mesh.h:62
static int globalMeshCounter
Definition mesh.h:21
bool isVisible() const
Definition mesh.h:70
virtual ~Mesh()
Definition mesh.cpp:20
void setMaterial(const std::shared_ptr< Material > &material)
Applies a material to the entire mesh and all its submeshes.
Definition mesh.cpp:30
void setVertexWave(bool isVertexWave)
Definition mesh.h:64
GLsizei _numVertices
Definition mesh.h:31
void setVisible(bool visible)
Definition mesh.h:69
GLsizei getNumVertices() const
Definition mesh.h:54
Mesh()
Definition mesh.cpp:12
std::vector< float > _vertices
Definition mesh.h:33
void _SetId()
Definition mesh.cpp:8
PGR Semestral work with sample scenes and bowling. doxygen was generated with a help of LLM.
Definition bezier.cpp:3
Shader * shader
Definition main.cpp:37
void init()
Initializes OpenGL context, scene data, and sets up GLUT callbacks.
Definition main.cpp:42
void draw()
Main render loop. Handles updates, physics, and rendering of all scene elements.
Definition main.cpp:97
Represents a part of a mesh that uses a specific material.
Definition mesh.h:12
unsigned int indexOffset
Definition mesh.h:14
unsigned int indexCount
Definition mesh.h:15
std::shared_ptr< Material > material
Definition mesh.h:13