dbf-halloween2015

view src/object.h @ 0:50683c78264e

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Nov 2015 00:09:12 +0200
parents
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;
19 bool cast_shadows;
20 bool transparent;
22 RenderOps();
23 void setup() const;
24 };
26 class Object {
27 private:
28 Mesh *mesh;
29 Matrix4x4 matrix;
30 unsigned int tex;
31 Matrix4x4 tex_matrix;
32 unsigned int sdr;
34 public:
35 Material mtl;
36 RenderOps rop;
38 Object();
39 ~Object();
41 Matrix4x4 &xform();
42 const Matrix4x4 &xform() const;
44 Matrix4x4 &tex_xform();
45 const Matrix4x4 &tex_xform() const;
47 void set_mesh(Mesh *m);
48 Mesh *get_mesh() const;
50 void set_texture(unsigned int tex);
51 unsigned int get_texture() const;
52 void set_shader(unsigned int sdr);
53 unsigned int get_shader() const;
55 void draw() const;
56 void draw_wire(const Vector4 &col = Vector4(1, 1, 1, 1)) const;
57 void draw_vertices(const Vector4 &col = Vector4(1, 0.3, 0.2, 1)) const;
58 void draw_normals(float len = 1.0, const Vector4 &col = Vector4(0.1, 0.2, 1.0, 1)) const;
59 void draw_tangents(float len = 1.0, const Vector4 &col = Vector4(0.1, 1.0, 0.2, 1)) const;
61 bool intersect(const Ray &ray, HitPoint *hit) const;
62 };
64 #endif // OBJECT_H_