clray

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/scene.h	Wed Aug 11 04:30:35 2010 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +#ifndef MESH_H_
     1.5 +#define MESH_H_
     1.6 +
     1.7 +#include <vector>
     1.8 +
     1.9 +struct Vertex {
    1.10 +	float pos[4];
    1.11 +	float normal[4];
    1.12 +	float tex[4];
    1.13 +	float padding[4];
    1.14 +};
    1.15 +
    1.16 +struct Face {
    1.17 +	Vertex v[3];
    1.18 +	float normal[4];
    1.19 +	int matid;
    1.20 +	int padding[3];
    1.21 +
    1.22 +	bool operator ==(const Face &f) const;
    1.23 +};
    1.24 +
    1.25 +struct Material {
    1.26 +	float kd[4], ks[4];
    1.27 +	float kr, kt;
    1.28 +	float spow;
    1.29 +	float padding;
    1.30 +};
    1.31 +
    1.32 +struct Mesh {
    1.33 +	std::vector<Face> faces;
    1.34 +	int matid;
    1.35 +};
    1.36 +
    1.37 +/*enum {
    1.38 +	KDAXIS_X,
    1.39 +	KDAXIS_Y,
    1.40 +	KDAXIS_Z
    1.41 +};
    1.42 +
    1.43 +#define KDCLEAR(node)	((node)->axis = -1)
    1.44 +#define KDUSED(node)	((node)->axis >= 0)
    1.45 +#define KDPARENT(x)		((x) >> 1)
    1.46 +#define KDLEFT(x)		((x) << 1)
    1.47 +#define KDRIGHT(x)		(((x) << 1) + 1)
    1.48 +
    1.49 +struct KDNode {
    1.50 +	int axis;
    1.51 +	float pt;
    1.52 +};*/
    1.53 +
    1.54 +class Scene {
    1.55 +public:
    1.56 +	std::vector<Mesh*> meshes;
    1.57 +	std::vector<Material> matlib;
    1.58 +	//std::vector<KDNode> kdtree;
    1.59 +
    1.60 +	bool add_mesh(Mesh *m);
    1.61 +	int get_num_meshes() const;
    1.62 +	int get_num_materials() const;
    1.63 +	int get_num_faces() const;
    1.64 +
    1.65 +	Material *get_materials();
    1.66 +	const Material *get_materials() const;
    1.67 +
    1.68 +	bool load(const char *fname);
    1.69 +	bool load(FILE *fp);
    1.70 +
    1.71 +	//void build_kdtree();
    1.72 +};
    1.73 +
    1.74 +#endif	/* MESH_H_ */