erebus

annotate 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
rev   line source
nuclear@0 1 #ifndef OBJECT_H_
nuclear@0 2 #define OBJECT_H_
nuclear@0 3
nuclear@0 4 #include <string>
nuclear@0 5 #include "vmath/ray.h"
nuclear@0 6
nuclear@0 7 class Object;
nuclear@0 8
nuclear@0 9 struct RayHit {
nuclear@0 10 float dist;
nuclear@0 11 const Ray world_ray, local_ray;
nuclear@0 12
nuclear@0 13 const Object *obj, *subobj;
nuclear@0 14 };
nuclear@0 15
nuclear@0 16 enum class ObjType { null, geom, camera };
nuclear@0 17
nuclear@0 18 class Object {
nuclear@0 19 private:
nuclear@0 20 std::string name;
nuclear@0 21 Matrix4x4 xform;
nuclear@0 22 mutable Matrix4x4 inv_xform;
nuclear@0 23 mutable bool inv_xform_valid;
nuclear@0 24
nuclear@0 25 public:
nuclear@0 26 Object();
nuclear@0 27 virtual ~Object() = default;
nuclear@0 28
nuclear@0 29 virtual ObjType get_type() const;
nuclear@0 30
nuclear@0 31 virtual void set_name(const char *name);
nuclear@0 32 virtual const char *get_name() const;
nuclear@0 33
nuclear@0 34 virtual void set_xform(const Matrix4x4 &mat);
nuclear@0 35 virtual void set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat);
nuclear@0 36
nuclear@0 37 virtual Matrix4x4 &get_xform(); // invalidates inv_xform
nuclear@0 38 virtual const Matrix4x4 &get_xform() const;
nuclear@0 39 virtual const Matrix4x4 &get_inv_xform() const;
nuclear@0 40
nuclear@0 41 virtual bool intersect(const Ray &ray, RayHit *hit = 0) const;
nuclear@0 42 };
nuclear@0 43
nuclear@0 44 #endif // OBJECT_H_