fixed materials etc (not all), improvements
[hair] / src / mesh.h
1 #ifndef MESH_H_
2 #define MESH_H_
3
4 #include <stdint.h>
5 #include <vector>
6 #include <gmath/gmath.h>
7
8 #define MESH_ALL (0xffffffff)
9
10 enum {
11         MESH_VERTEX = 1,
12         MESH_NORMAL = 2,
13         MESH_COLOR = 4,
14         MESH_INDEX = 8
15 };
16
17 struct Aabb {
18         Vec3 v0;
19         Vec3 v1;
20 };
21
22 struct Material {
23         Vec3 diffuse;
24         Vec3 specular;
25         float shininess;
26
27         unsigned int tex;
28 };
29
30 class Mesh {
31 private:
32         unsigned int vbo_vertices;
33         unsigned int vbo_normals;
34         unsigned int vbo_colors;
35         unsigned int ibo;
36
37         int num_vertices;
38         int num_indices;
39
40 public:
41         Mesh();
42         ~Mesh();
43
44         Aabb bbox;
45         Material mtl;
46
47         std::string name;
48         std::vector<uint16_t> indices;
49         std::vector<Vec3> vertices;
50         std::vector<Vec3> normals;
51         std::vector<Vec3> colors;
52
53         void draw() const;
54         void update_vbo(unsigned int which);
55
56         void calc_bbox();
57 };
58
59 std::vector<Mesh*> load_meshes(const char *fname);
60
61 #endif // MESH_H_