clray

view src/scene.h @ 22:6c44e4b1726d

OMG alignment is a bitch
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 11 Aug 2010 04:30:35 +0100
parents src/mesh.h@754faf15ba36
children 51f115e337c2
line source
1 #ifndef MESH_H_
2 #define MESH_H_
4 #include <vector>
6 struct Vertex {
7 float pos[4];
8 float normal[4];
9 float tex[4];
10 float padding[4];
11 };
13 struct Face {
14 Vertex v[3];
15 float normal[4];
16 int matid;
17 int padding[3];
19 bool operator ==(const Face &f) const;
20 };
22 struct Material {
23 float kd[4], ks[4];
24 float kr, kt;
25 float spow;
26 float padding;
27 };
29 struct Mesh {
30 std::vector<Face> faces;
31 int matid;
32 };
34 /*enum {
35 KDAXIS_X,
36 KDAXIS_Y,
37 KDAXIS_Z
38 };
40 #define KDCLEAR(node) ((node)->axis = -1)
41 #define KDUSED(node) ((node)->axis >= 0)
42 #define KDPARENT(x) ((x) >> 1)
43 #define KDLEFT(x) ((x) << 1)
44 #define KDRIGHT(x) (((x) << 1) + 1)
46 struct KDNode {
47 int axis;
48 float pt;
49 };*/
51 class Scene {
52 public:
53 std::vector<Mesh*> meshes;
54 std::vector<Material> matlib;
55 //std::vector<KDNode> kdtree;
57 bool add_mesh(Mesh *m);
58 int get_num_meshes() const;
59 int get_num_materials() const;
60 int get_num_faces() const;
62 Material *get_materials();
63 const Material *get_materials() const;
65 bool load(const char *fname);
66 bool load(FILE *fp);
68 //void build_kdtree();
69 };
71 #endif /* MESH_H_ */