erebus

view liberebus/src/object.h @ 0:4abdce1361b9

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 27 Apr 2014 16:02:47 +0300
parents
children 474a0244f57d
line source
1 #ifndef OBJECT_H_
2 #define OBJECT_H_
4 #include <string>
5 #include "vmath/ray.h"
7 class Object;
9 struct RayHit {
10 float dist;
11 const Ray world_ray, local_ray;
13 const Object *obj, *subobj;
14 };
16 enum class ObjType { null, geom, camera };
18 class Object {
19 private:
20 std::string name;
21 Matrix4x4 xform;
22 mutable Matrix4x4 inv_xform;
23 mutable bool inv_xform_valid;
25 public:
26 Object();
27 virtual ~Object() = default;
29 virtual ObjType get_type() const;
31 virtual void set_name(const char *name);
32 virtual const char *get_name() const;
34 virtual void set_xform(const Matrix4x4 &mat);
35 virtual void set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat);
37 virtual Matrix4x4 &get_xform(); // invalidates inv_xform
38 virtual const Matrix4x4 &get_xform() const;
39 virtual const Matrix4x4 &get_inv_xform() const;
41 virtual bool intersect(const Ray &ray, RayHit *hit = 0) const;
42 };
44 #endif // OBJECT_H_