erebus

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/liberebus/src/object.h	Sun Apr 27 16:02:47 2014 +0300
     1.3 @@ -0,0 +1,44 @@
     1.4 +#ifndef OBJECT_H_
     1.5 +#define OBJECT_H_
     1.6 +
     1.7 +#include <string>
     1.8 +#include "vmath/ray.h"
     1.9 +
    1.10 +class Object;
    1.11 +
    1.12 +struct RayHit {
    1.13 +	float dist;
    1.14 +	const Ray world_ray, local_ray;
    1.15 +
    1.16 +	const Object *obj, *subobj;
    1.17 +};
    1.18 +
    1.19 +enum class ObjType { null, geom, camera };
    1.20 +
    1.21 +class Object {
    1.22 +private:
    1.23 +	std::string name;
    1.24 +	Matrix4x4 xform;
    1.25 +	mutable Matrix4x4 inv_xform;
    1.26 +	mutable bool inv_xform_valid;
    1.27 +
    1.28 +public:
    1.29 +	Object();
    1.30 +	virtual ~Object() = default;
    1.31 +
    1.32 +	virtual ObjType get_type() const;
    1.33 +
    1.34 +	virtual void set_name(const char *name);
    1.35 +	virtual const char *get_name() const;
    1.36 +
    1.37 +	virtual void set_xform(const Matrix4x4 &mat);
    1.38 +	virtual void set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat);
    1.39 +
    1.40 +	virtual Matrix4x4 &get_xform();	// invalidates inv_xform
    1.41 +	virtual const Matrix4x4 &get_xform() const;
    1.42 +	virtual const Matrix4x4 &get_inv_xform() const;
    1.43 +
    1.44 +	virtual bool intersect(const Ray &ray, RayHit *hit = 0) const;
    1.45 +};
    1.46 +
    1.47 +#endif	// OBJECT_H_
    1.48 \ No newline at end of file