Path Tracer
Object3D.h
Go to the documentation of this file.
1 #ifndef DEF_OBJECT3D
2 #define DEF_OBJECT3D
3 
4 #include <string>
5 
6 #include "DiffuseMaterial.h"
7 
121 class Object3D {
122 private:
123  Material* material;
124 
125 protected:
126  double area;
127 
128 public:
129  Object3D();
130  Object3D(Material* material);
131  Object3D(const Object3D& obj);
132  ~Object3D();
133 
134  Material* getMaterial() const;
135  double getArea() const;
136  void setMaterial(Material* material);
137 
138  virtual void computeArea() = 0;
139  virtual Object3D* deepCopy() const = 0;
140 
141  virtual double smallestPositiveIntersection(const Ray& ray) const = 0;
142  virtual DoubleUnitVec3D getNormal(const DoubleVec3D& point) const = 0;
143  virtual DoubleVec3D getRandomPoint() const = 0;
144  virtual std::ostream& getDescription(std::ostream& stream) const = 0;
145  virtual DoubleVec3D getCenter() const = 0;
146  virtual DoubleVec3D getMinCoord() const = 0;
147  virtual DoubleVec3D getMaxCoord() const = 0;
148 
149  virtual std::string getType() const = 0;
150  virtual json getLocationJson() const = 0;
151  virtual void setLocationJson(const json& j) = 0;
152 
153  Object3D& operator=(const Object3D& otherObject);
154 };
155 
156 std::ostream& operator<<(std::ostream& stream, const Object3D& object);
157 
158 #endif
Defines the DiffuseMaterial class.
nlohmann::json json
Definition: InterfaceGestion.h:14
std::ostream & operator<<(std::ostream &stream, const Object3D &object)
Ostream operator.
Definition: Object3D.cpp:24
A three-dimensional unit vector using doubles.
Definition: DoubleUnitVec3D.h:61
A three-dimensional vector using double values.
Definition: DoubleVec3D.h:190
Abstrat class that models a material.
Definition: Material.h:77
Abstract class for a three-dimentional object.
Definition: Object3D.h:121
double getArea() const
Getter for this object's area.
Definition: Object3D.cpp:19
virtual DoubleVec3D getCenter() const =0
Returns this object's center.
virtual std::ostream & getDescription(std::ostream &stream) const =0
Returns this object's description.
double area
Stores the area of this object.
Definition: Object3D.h:126
virtual Object3D * deepCopy() const =0
Makes a deep copy of this object.
Object3D & operator=(const Object3D &otherObject)
Assignment operator.
Definition: Object3D.cpp:28
Material * getMaterial() const
Getter for the Material.
Definition: Object3D.cpp:18
virtual double smallestPositiveIntersection(const Ray &ray) const =0
Computes the smallest positive intersection between the ray and this object.
~Object3D()
Destructor.
Definition: Object3D.cpp:14
virtual DoubleVec3D getMinCoord() const =0
Returns the minimum coordinate of a cuboid containing this object.
void setMaterial(Material *material)
Setter for the Material.
Definition: Object3D.cpp:20
virtual DoubleVec3D getMaxCoord() const =0
Returns the maximum coordinate of a cuboid containing this object.
virtual void setLocationJson(const json &j)=0
Sets this object's location according to json.
virtual void computeArea()=0
Computes this object area.
virtual json getLocationJson() const =0
Converts this objects's location to json.
virtual std::string getType() const =0
Returns this object type.
Object3D()
Default constructor.
Definition: Object3D.cpp:4
virtual DoubleUnitVec3D getNormal(const DoubleVec3D &point) const =0
Computes the normal at a point on the object.
virtual DoubleVec3D getRandomPoint() const =0
Computes a random point on the object.
Combination of an origin and a direction.
Definition: Ray.h:44