charles/src/object.h

72 lines
1.8 KiB
C
Raw Normal View History

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>
#include <vector>
2013-09-22 10:16:15 -07:00
2013-09-07 16:48:50 -07:00
#include "basics.h"
#include "material.h"
#include "stats.hh"
2013-09-07 22:22:27 -07:00
#include "texture.h"
#include "types.hh"
#include "basics/basics.hh"
2013-09-07 16:48:50 -07:00
namespace charles {
2013-09-07 16:48:50 -07:00
struct Object
2013-09-10 09:18:05 -07:00
{
typedef std::shared_ptr<Object> Ptr;
Object(const basics::Vector4& origin = basics::Vector4());
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
*/
virtual bool DoesIntersect(const Ray& ray, TVector& t, Stats& stats) const = 0;
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;
virtual void Write(std::ostream& ost) const;
private:
/** 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
/**
* 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);
} /* namespace charles */
2013-09-07 16:09:19 -07:00
#endif