2013-09-07 16:09:19 -07:00
|
|
|
/* object.h
|
|
|
|
*
|
2013-09-10 09:18:05 -07:00
|
|
|
* Declaration of abstract, top-level scene objects. The Object class is the top of this hierarchy. All other scene
|
|
|
|
* objects are based on it. The Shape class defines a visible shape in the scene.
|
2013-09-07 16:09:19 -07:00
|
|
|
*
|
|
|
|
* Eryn Wells <eryn@erynwells.me>
|
|
|
|
*/
|
|
|
|
|
2013-09-10 09:18:05 -07:00
|
|
|
#ifndef __OBJECT_H__
|
|
|
|
#define __OBJECT_H__
|
2013-09-07 16:09:19 -07:00
|
|
|
|
2013-09-22 10:16:15 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
2013-09-07 16:48:50 -07:00
|
|
|
#include "basics.h"
|
2013-09-11 09:05:27 -07:00
|
|
|
#include "material.h"
|
2013-09-07 22:22:27 -07:00
|
|
|
#include "texture.h"
|
2013-09-07 16:48:50 -07:00
|
|
|
|
|
|
|
|
2013-09-10 09:18:05 -07:00
|
|
|
class Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Object();
|
2013-09-10 15:45:13 -07:00
|
|
|
Object(Vector3 o);
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2013-09-10 15:45:13 -07:00
|
|
|
Vector3 get_origin() const;
|
2014-07-19 15:41:17 -07:00
|
|
|
void set_origin(const Vector3& v);
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2013-09-22 10:16:15 -07:00
|
|
|
friend std::ostream &operator<<(std::ostream &os, const Object &o);
|
|
|
|
|
2013-09-10 09:18:05 -07:00
|
|
|
private:
|
|
|
|
Vector3 origin;
|
|
|
|
};
|
2013-09-07 18:26:32 -07:00
|
|
|
|
2013-09-22 10:16:15 -07:00
|
|
|
std::ostream &operator<<(std::ostream &os, const Object &o);
|
|
|
|
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2013-09-10 09:18:05 -07:00
|
|
|
class Shape
|
|
|
|
: public Object
|
|
|
|
{
|
|
|
|
public:
|
2013-09-10 15:45:13 -07:00
|
|
|
Shape();
|
|
|
|
Shape(Vector3 o);
|
2013-09-13 14:14:45 -07:00
|
|
|
virtual ~Shape();
|
2013-09-10 15:45:13 -07:00
|
|
|
|
2014-07-19 14:09:47 -07:00
|
|
|
Material* get_material() const;
|
2013-09-11 09:05:27 -07:00
|
|
|
void set_material(Material *mat);
|
|
|
|
|
2013-09-10 21:04:56 -07:00
|
|
|
virtual int does_intersect(const Ray &ray, float **t) const = 0;
|
2013-09-10 22:32:33 -07:00
|
|
|
virtual bool point_is_on_surface(const Vector3 &p) const = 0;
|
2013-09-10 21:04:56 -07:00
|
|
|
virtual Vector3 compute_normal(const Vector3 &p) const = 0;
|
2013-09-11 09:05:27 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
Material *material;
|
2013-09-10 09:18:05 -07:00
|
|
|
};
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2013-09-07 16:09:19 -07:00
|
|
|
#endif
|