-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMesh.h
77 lines (60 loc) · 1.76 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
#ifndef _MESH_H
#define _MESH_H
#include <vector>
#include <list>
#include <memory>
//#include <map>
#include <unordered_map>
#include "math/common.h"
#include "Material.h"
#include "ResourceCache.h"
#include <assimp/assimp.hpp>
#include <assimp/aiScene.h>
#include <assimp/aiPostProcess.h>
#include "Light.h"
#include "IRealtime.h"
class Light;
class Mesh : public IRealtime
{
public:
struct Face
{
unsigned int indices[3];
};
struct Edge
{
unsigned int indices[2];
};
std::string name;
std::vector<glm::vec3> bitangents;
std::vector<glm::vec3> tangents;
std::vector<glm::vec3> vertices;
//std::vector<Bone> bones;
std::vector<Face> faces;
std::vector<std::shared_ptr<Material>> materials;
std::vector<glm::vec3> normals;
std::vector<std::vector<glm::vec3>> UVs;
std::vector<std::shared_ptr<Mesh>> LOD;
float minimum_lod;
bool error;
//bool bMaterialAlloc;
enum {
F_DOUBLE_SIDED = BIT(0)
};
unsigned int flags;
//unsigned int refs; // currently unused
Mesh(std::string n = "", float minlod = 0.1f);
Mesh(std::string fn, ResourceCache<Texture>& tex_map, std::string override_name = "", float minlod = 0.1f);
virtual ~Mesh();
Mesh* getLOD(float quality = 1.0f) const;
virtual bool load(std::string fn, ResourceCache<Texture>& tex_map);
enum {
RENDER_LOD = BIT(0)
};
virtual void logic(unsigned int advance);
void render(unsigned int flags = 0, float quality = 1.0f) const;
bool loadModel(const aiMesh* aimesh);
bool good() const { return !vertices.empty(); } // this could be improved, but it works for now
// TODO: add Mesh::allocate like Material::allocate for usage with ResourceCaches
};
#endif