erebus

diff liberebus/src/object.cc @ 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.cc	Sun Apr 27 16:02:47 2014 +0300
     1.3 @@ -0,0 +1,60 @@
     1.4 +#include "object.h"
     1.5 +
     1.6 +Object::Object()
     1.7 +{
     1.8 +	name = "<unnamed>";
     1.9 +	inv_xform_valid = false;
    1.10 +}
    1.11 +
    1.12 +ObjType Object::get_type() const
    1.13 +{
    1.14 +	return ObjType::null;
    1.15 +}
    1.16 +
    1.17 +void Object::set_name(const char *name)
    1.18 +{
    1.19 +	this->name = name;
    1.20 +}
    1.21 +
    1.22 +const char *Object::get_name() const
    1.23 +{
    1.24 +	return name.c_str();
    1.25 +}
    1.26 +
    1.27 +void Object::set_xform(const Matrix4x4 &mat)
    1.28 +{
    1.29 +	xform = mat;
    1.30 +	inv_xform_valid = false;
    1.31 +}
    1.32 +
    1.33 +void Object::set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat)
    1.34 +{
    1.35 +	xform = mat;
    1.36 +	inv_xform = inv_mat;
    1.37 +	inv_xform_valid = true;
    1.38 +}
    1.39 +
    1.40 +Matrix4x4 &Object::get_xform()
    1.41 +{
    1.42 +	inv_xform_valid = false;
    1.43 +	return xform;
    1.44 +}
    1.45 +
    1.46 +const Matrix4x4 &Object::get_xform() const
    1.47 +{
    1.48 +	return xform;
    1.49 +}
    1.50 +
    1.51 +const Matrix4x4 &Object::get_inv_xform() const
    1.52 +{
    1.53 +	if(!inv_xform_valid) {
    1.54 +		inv_xform = xform.inverse();
    1.55 +		inv_xform_valid = true;
    1.56 +	}
    1.57 +	return inv_xform;
    1.58 +}
    1.59 +
    1.60 +bool Object::intersect(const Ray &ray, RayHit *hit) const
    1.61 +{
    1.62 +	return false;
    1.63 +}
    1.64 \ No newline at end of file