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>
|
2014-07-25 15:10:29 -07:00
|
|
|
#include <memory>
|
2014-07-20 16:46:49 -07:00
|
|
|
#include <vector>
|
2013-09-22 10:16:15 -07:00
|
|
|
|
2013-09-07 16:48:50 -07:00
|
|
|
#include "basics.h"
|
2013-09-11 09:05:27 -07:00
|
|
|
#include "material.h"
|
2014-08-02 15:21:14 -07:00
|
|
|
#include "stats.hh"
|
2013-09-07 22:22:27 -07:00
|
|
|
#include "texture.h"
|
2014-07-20 16:46:49 -07:00
|
|
|
#include "types.hh"
|
2014-08-09 08:57:41 -07:00
|
|
|
#include "basics/basics.hh"
|
|
|
|
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2014-07-20 16:46:49 -07:00
|
|
|
namespace charles {
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2014-07-20 16:46:49 -07:00
|
|
|
struct Object
|
2013-09-10 09:18:05 -07:00
|
|
|
{
|
2014-07-20 16:46:49 -07:00
|
|
|
typedef std::shared_ptr<Object> Ptr;
|
|
|
|
|
2014-08-09 08:57:41 -07:00
|
|
|
Object(const basics::Vector4& origin = basics::Vector4());
|
2014-07-20 16:46:49 -07:00
|
|
|
virtual ~Object();
|
|
|
|
|
|
|
|
Vector3 GetOrigin() const;
|
|
|
|
void SetOrigin(const Vector3& origin);
|
|
|
|
|
|
|
|
Material& GetMaterial();
|
|
|
|
void SetMaterial(const Material& material);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the given ray intersects with this object. All intersection
|
|
|
|
* t values are returned in the `t` argument, in increasing order.
|
|
|
|
*
|
|
|
|
* @param [in] ray The ray to test for intersection
|
|
|
|
* @param [out] t A vector of all intersection t values
|
|
|
|
* @return `true` if the ray intersects with this object
|
|
|
|
*/
|
2014-08-02 15:21:14 -07:00
|
|
|
virtual bool DoesIntersect(const Ray& ray, TVector& t, Stats& stats) 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
|
|
|
|
2014-08-03 17:25:00 -07:00
|
|
|
virtual void Write(std::ostream& ost) const;
|
|
|
|
|
2013-09-11 09:05:27 -07:00
|
|
|
private:
|
2014-07-20 16:46:49 -07:00
|
|
|
|
|
|
|
/** This object's material, surface properties, etc. */
|
|
|
|
Material mMaterial;
|
2013-09-10 09:18:05 -07:00
|
|
|
};
|
2013-09-07 16:48:50 -07:00
|
|
|
|
2014-08-03 17:25:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a string representation of the Object to an output stream.
|
|
|
|
*
|
|
|
|
* @param [in] ost The output stream
|
|
|
|
* @param [in] object The object
|
|
|
|
* @returns The output stream
|
|
|
|
*/
|
|
|
|
std::ostream& operator<<(std::ostream& ost, const Object& object);
|
|
|
|
|
2014-07-20 16:46:49 -07:00
|
|
|
} /* namespace charles */
|
|
|
|
|
2013-09-07 16:09:19 -07:00
|
|
|
#endif
|