tavli

view src/object.h @ 24:0aadb519b5ee

correct highlighting
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 08 Jul 2015 15:11:58 +0300
parents 283eb6e9f0a3
children
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;
14 Material();
15 };
17 struct RenderOps {
18 bool zwrite;
20 RenderOps();
21 void setup() const;
22 };
24 class Object {
25 private:
26 Mesh *mesh;
27 Matrix4x4 matrix;
28 unsigned int tex;
29 Matrix4x4 tex_matrix;
30 unsigned int sdr;
32 public:
33 Material mtl;
34 RenderOps rop;
36 Object();
37 ~Object();
39 Matrix4x4 &xform();
40 const Matrix4x4 &xform() const;
42 Matrix4x4 &tex_xform();
43 const Matrix4x4 &tex_xform() const;
45 void set_mesh(Mesh *m);
46 Mesh *get_mesh() const;
48 void set_texture(unsigned int tex);
49 void set_shader(unsigned int sdr);
51 void draw() const;
52 void draw_wire(const Vector4 &col = Vector4(1, 1, 1, 1)) const;
53 void draw_vertices(const Vector4 &col = Vector4(1, 0.3, 0.2, 1)) const;
54 void draw_normals(float len = 1.0, const Vector4 &col = Vector4(0.1, 0.2, 1.0, 1)) const;
55 void draw_tangents(float len = 1.0, const Vector4 &col = Vector4(0.1, 1.0, 0.2, 1)) const;
57 bool intersect(const Ray &ray, HitPoint *hit) const;
58 };
60 #endif // OBJECT_H_