tavli

view src/object.h @ 11:a8e26f163f99

poulia
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 27 Jun 2015 08:01:51 +0300
parents a0d30f6f20d4
children 283eb6e9f0a3
line source
1 #ifndef OBJECT_H_
2 #define OBJECT_H_
4 #include "mesh.h"
5 #include "geom.h"
6 #include "vmath/vmath.h"
8 struct Material {
9 Vector3 diffuse;
10 Vector3 specular;
11 float shininess;
12 float alpha;
13 };
15 class Object {
16 private:
17 Mesh *mesh;
18 Matrix4x4 matrix;
19 unsigned int tex;
20 Matrix4x4 tex_matrix;
22 public:
23 Material mtl;
25 Object();
26 ~Object();
28 Matrix4x4 &xform();
29 const Matrix4x4 &xform() const;
31 Matrix4x4 &tex_xform();
32 const Matrix4x4 &tex_xform() const;
34 void set_mesh(Mesh *m);
35 Mesh *get_mesh() const;
37 void set_texture(unsigned int tex);
39 void draw() const;
40 void draw_wire(const Vector4 &col = Vector4(1, 1, 1, 1)) const;
41 void draw_vertices(const Vector4 &col = Vector4(1, 0.3, 0.2, 1)) const;
42 void draw_normals(float len = 1.0, const Vector4 &col = Vector4(0.1, 0.2, 1.0, 1)) const;
43 void draw_tangents(float len = 1.0, const Vector4 &col = Vector4(0.1, 1.0, 0.2, 1)) const;
45 bool intersect(const Ray &ray, HitPoint *hit) const;
46 };
48 #endif // OBJECT_H_