ld33_umonster
annotate src/object.h @ 10:1b30bd381667
sweep curve mesh gen and dragon horns
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 27 Aug 2015 05:25:04 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@0 | 1 #ifndef OBJECT_H_ |
nuclear@0 | 2 #define OBJECT_H_ |
nuclear@0 | 3 |
nuclear@0 | 4 #include "mesh.h" |
nuclear@0 | 5 #include "geom.h" |
nuclear@0 | 6 #include "vmath/vmath.h" |
nuclear@0 | 7 |
nuclear@0 | 8 struct Material { |
nuclear@0 | 9 Vector3 diffuse; |
nuclear@0 | 10 Vector3 specular; |
nuclear@0 | 11 float shininess; |
nuclear@0 | 12 float alpha; |
nuclear@0 | 13 |
nuclear@0 | 14 Material(); |
nuclear@0 | 15 }; |
nuclear@0 | 16 |
nuclear@0 | 17 struct RenderOps { |
nuclear@0 | 18 bool zwrite; |
nuclear@0 | 19 bool cast_shadows; |
nuclear@0 | 20 bool transparent; |
nuclear@0 | 21 |
nuclear@0 | 22 RenderOps(); |
nuclear@0 | 23 void setup() const; |
nuclear@0 | 24 }; |
nuclear@0 | 25 |
nuclear@0 | 26 class Object { |
nuclear@0 | 27 private: |
nuclear@0 | 28 Mesh *mesh; |
nuclear@0 | 29 Matrix4x4 matrix; |
nuclear@0 | 30 unsigned int tex; |
nuclear@0 | 31 Matrix4x4 tex_matrix; |
nuclear@0 | 32 unsigned int sdr; |
nuclear@0 | 33 |
nuclear@0 | 34 public: |
nuclear@0 | 35 Material mtl; |
nuclear@0 | 36 RenderOps rop; |
nuclear@0 | 37 |
nuclear@0 | 38 Object(); |
nuclear@0 | 39 ~Object(); |
nuclear@0 | 40 |
nuclear@0 | 41 Matrix4x4 &xform(); |
nuclear@0 | 42 const Matrix4x4 &xform() const; |
nuclear@0 | 43 |
nuclear@0 | 44 Matrix4x4 &tex_xform(); |
nuclear@0 | 45 const Matrix4x4 &tex_xform() const; |
nuclear@0 | 46 |
nuclear@0 | 47 void set_mesh(Mesh *m); |
nuclear@0 | 48 Mesh *get_mesh() const; |
nuclear@0 | 49 |
nuclear@0 | 50 void set_texture(unsigned int tex); |
nuclear@0 | 51 void set_shader(unsigned int sdr); |
nuclear@0 | 52 unsigned int get_shader() const; |
nuclear@0 | 53 |
nuclear@0 | 54 void draw() const; |
nuclear@0 | 55 void draw_wire(const Vector4 &col = Vector4(1, 1, 1, 1)) const; |
nuclear@0 | 56 void draw_vertices(const Vector4 &col = Vector4(1, 0.3, 0.2, 1)) const; |
nuclear@0 | 57 void draw_normals(float len = 1.0, const Vector4 &col = Vector4(0.1, 0.2, 1.0, 1)) const; |
nuclear@0 | 58 void draw_tangents(float len = 1.0, const Vector4 &col = Vector4(0.1, 1.0, 0.2, 1)) const; |
nuclear@0 | 59 |
nuclear@0 | 60 bool intersect(const Ray &ray, HitPoint *hit) const; |
nuclear@0 | 61 }; |
nuclear@0 | 62 |
nuclear@0 | 63 #endif // OBJECT_H_ |