The spica renderer
shape.h
1 
6 #ifdef _MSC_VER
7 #pragma once
8 #endif
9 
10 #ifndef SPICA_SHAPE_H_
11 #define SPICA_SHAPE_H_
12 
13 #include <vector>
14 
15 #include "core/core.hpp"
16 #include "core/common.h"
17 #include "core/cobject.h"
18 #include "core/transform.h"
19 #include "core/render.hpp"
20 
21 namespace spica {
22 
27 enum class ShapeType : int {
28  None,
29  Disk,
30  Plane,
31  Quad,
32  Sphere,
33  Triangle,
34 };
35 
39 class SPICA_EXPORTS Shape : public CObject {
40 public:
41  // Public methods
42  Shape();
43  Shape(const Transform& objectToWorld, ShapeType type);
44  Shape(const Shape& s);
45 
46  virtual ~Shape();
47 
48  Shape& operator=(const Shape& s);
49 
50  virtual bool intersect(const Ray& ray, double* tHit,
51  SurfaceInteraction* isect) const = 0;
52  virtual bool intersect(const Ray& ray) const = 0;
53 
54  virtual Interaction sample(const Point2d& rands) const = 0;
55  virtual Interaction sample(const Interaction& isect,
56  const Point2d& rands) const;
57  virtual double pdf(const Interaction& pObj) const;
58  virtual double pdf(const Interaction& pObj, const Vector3d& dir) const;
59 
60  virtual Bounds3d worldBound() const;
61  virtual Bounds3d objectBound() const = 0;
62 
63  virtual double area() const = 0;
64  virtual std::vector<Triangle> triangulate() const = 0;
65 
66  inline ShapeType type() const { return type_; }
67 
68 protected:
69  // Protected fields
70  Transform objectToWorld_, worldToObject_;
71  ShapeType type_;
72 
73 }; // class Shape
74 
75 } // namespace spica
76 
77 #endif // SPICA_SHAPE_INTERFACE_H_
Definition: interaction.h:68
ShapeType
Shape types.
Definition: shape.h:27
Ray class.
Definition: ray.h:24
Definition: cobject.h:24
The transformation operator class.
Definition: transform.h:17
Definition: interaction.h:23
Abstract shape class.
Definition: shape.h:39