-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMesh.h
97 lines (76 loc) · 2.31 KB
/
Mesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef _MESH_H_
#define _MESH_H_
#include "glm.h"
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include <GLFW/glfw3.h>
#include <vector>
#include <string>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/string_cast.hpp>
#include <glm/gtx/quaternion.hpp>
#include <iostream>
#include "FBO.h"
// store texture info
struct Texture {
unsigned int id;
std::string type;
std::string path;
};
// store bone info for animation
struct BoneInfo
{
/*id is index in finalBoneMatrices*/
int id;
/*offset matrix transforms vertex from model space to bone space*/
glm::mat4 offset;
};
class Mesh {
private:
// Mesh data
std::vector<glm::vec3> vertices;
std::vector<glm::vec3> normals;
std::vector<glm::vec2> uvs;
std::vector<glm::uvec3> indices;
std::vector<Texture> textures;
// Animation
std::vector<glm::vec3> Tangent;
std::vector<glm::vec3> Bitangent;
//bone indexes which will influence this vertex
std::vector<glm::ivec4> boneIds;
//weights from each bone
std::vector<glm::vec4> weights;
// Buffers + Attribute pointers
GLuint VAO;
GLuint VBO, VBO_N, VBO_UV, VBO_BI, VBO_W, EBO;
// Transformations
glm::mat4 model;
public:
// true if mesh has texture - false otherwise
bool hasTexture;
// for leaves and grass
float speed = 0.0f;
float strength = 0.0f;
// is this mesh a particle?
bool isParticle = false;
// Constructor + Deconstructors
Mesh();
Mesh(std::vector<glm::vec3> vertices, std::vector<glm::vec3> normals,
std::vector<glm::vec2> uvs, std::vector<glm::uvec3> indices,
std::vector<Texture> textures, std::vector<glm::ivec4> b, std::vector<glm::vec4> w);
~Mesh();
// Render mesh
void draw(glm::mat4 view, glm::mat4 projection, glm::mat4 mod, float time, GLuint shader);
void particleDraw(glm::mat4 view, glm::mat4 projection, glm::mat4 mod, float time, GLuint shader);
void debugDraw(glm::mat4 view, glm::mat4 projection, glm::mat4 parent, GLuint shader);
void draw(glm::mat4 view, glm::mat4 projection, glm::mat4 mod, std::vector<glm::mat4> transforms, float time, GLuint shader);
// Render depth map
void draw(std::vector<glm::mat4> transforms, glm::mat4 parent, GLuint shader);
void draw(glm::mat4 parent, float blend, GLuint shader);
void draw(glm::mat4 parent, GLuint shader);
};
#endif