charles/src/object.cc

116 lines
1.5 KiB
C++
Raw Normal View History

2013-09-07 16:09:19 -07:00
/* object.c
*
* Definition of generic scene objects.
2013-09-07 16:09:19 -07:00
*
* Eryn Wells <eryn@erynwells.me>
*/
#include <cassert>
#include <cmath>
#include <cstdlib>
2013-09-07 22:22:27 -07:00
2013-09-07 16:48:50 -07:00
#include "basics.h"
#include "material.h"
2013-09-07 16:09:19 -07:00
#include "object.h"
#pragma mark - Objects
2013-09-07 16:48:50 -07:00
/*
2013-09-10 09:18:05 -07:00
* Object::Object --
2013-09-07 16:48:50 -07:00
*
2013-09-10 09:18:05 -07:00
* Default constructor. Create a new Object with an origin at (0, 0, 0).
2013-09-07 16:48:50 -07:00
*/
2013-09-10 09:18:05 -07:00
Object::Object()
: Object(Vector3::Zero)
{ }
/*
* Object::Object --
*
* Constructor. Create a new Object with an origin at o.
*/
Object::Object(Vector3 o)
: origin(o)
2013-09-10 09:18:05 -07:00
{ }
2013-09-07 16:48:50 -07:00
/*
2013-09-10 09:18:05 -07:00
* Object::get_origin --
* Object::set_origin --
2013-09-07 16:48:50 -07:00
*
2013-09-10 09:18:05 -07:00
* Get and set the Object's origin.
2013-09-07 16:48:50 -07:00
*/
Vector3
2013-09-10 09:18:05 -07:00
Object::get_origin()
const
2013-09-07 22:22:27 -07:00
{
2013-09-10 09:18:05 -07:00
return origin;
2013-09-07 22:22:27 -07:00
}
void
2014-07-19 15:41:17 -07:00
Object::set_origin(const Vector3& v)
2013-09-07 22:22:27 -07:00
{
2013-09-10 09:18:05 -07:00
origin = v;
2013-09-07 22:22:27 -07:00
}
2013-09-22 10:16:15 -07:00
std::ostream &
operator<<(std::ostream &os, const Object &o)
{
// Stream objects like this: [Object origin]
os << "[Object " << o.origin << "]";
return os;
}
#pragma mark - Shapes
2013-09-07 18:26:32 -07:00
/*
* Shape::Shape --
2013-09-07 18:26:32 -07:00
*
* Default constructor. Create a new Shape with an origin at (0, 0, 0).
2013-09-07 18:26:32 -07:00
*/
Shape::Shape()
2014-07-19 15:41:17 -07:00
: Shape(Vector3::Zero)
{ }
2013-09-07 18:26:32 -07:00
/*
* Shape::Shape --
*
* Constructor. Create a new Shape with an origin at o.
*/
Shape::Shape(Vector3 o)
2014-07-19 15:41:17 -07:00
: Object(o),
material(NULL)
{ }
2013-09-13 14:14:45 -07:00
/*
* Shape::~Shape() --
*
* Destructor.
*/
Shape::~Shape()
{ }
/*
* Shape::get_material --
* Shape::set_material --
*
* Get and set the Material applied to this shape.
*/
Material*
Shape::get_material()
const
{
return material;
}
void
Shape::set_material(Material *mat)
{
material = mat;
}