charles/src/object.cc

106 lines
1.3 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
2013-09-10 09:18:05 -07:00
Object::set_origin(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
}
#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()
: Object()
{ }
2013-09-07 18:26:32 -07:00
/*
* Shape::Shape --
*
* Constructor. Create a new Shape with an origin at o.
*/
Shape::Shape(Vector3 o)
: Object(o)
{ }
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;
}