Add Write methods to scene objects

Write methods are polymorphic, overridden by subclasses. There is a single operator<< for Objects that calls the right Write() method for the object. Neat.
This commit is contained in:
Eryn Wells 2014-08-03 17:25:00 -07:00
parent b56bbf4ced
commit 4828cb313f
8 changed files with 64 additions and 1 deletions

View file

@ -47,6 +47,8 @@ struct Object
virtual bool point_is_on_surface(const Vector3 &p) const = 0;
virtual Vector3 compute_normal(const Vector3 &p) const = 0;
virtual void Write(std::ostream& ost) const;
private:
/** The location of this object. */
Vector3 mOrigin;
@ -55,6 +57,16 @@ private:
Material mMaterial;
};
/**
* 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 */
#endif