ld33_umonster

view src/object.h @ 7:92d662deb66e

capsule distance seems broken
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Aug 2015 00:38:00 +0300
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 void set_shader(unsigned int sdr);
52 unsigned int get_shader() const;
54 void draw() const;
55 void draw_wire(const Vector4 &col = Vector4(1, 1, 1, 1)) const;
56 void draw_vertices(const Vector4 &col = Vector4(1, 0.3, 0.2, 1)) const;
57 void draw_normals(float len = 1.0, const Vector4 &col = Vector4(0.1, 0.2, 1.0, 1)) const;
58 void draw_tangents(float len = 1.0, const Vector4 &col = Vector4(0.1, 1.0, 0.2, 1)) const;
60 bool intersect(const Ray &ray, HitPoint *hit) const;
61 };
63 #endif // OBJECT_H_