1 | #pragma once |
---|
2 | #include "Vector.hpp" |
---|
3 | #include "Material.hpp" |
---|
4 | #include "BoundingBox.hpp" |
---|
5 | #include "HitRec.hpp" |
---|
6 | #include "Ray.hpp" |
---|
7 | #include "Transformation.hpp" |
---|
8 | #include <iostream> |
---|
9 | |
---|
10 | class Occluder; |
---|
11 | class Radion; |
---|
12 | |
---|
13 | /*! |
---|
14 | \brief Base interface for all object types that can be ray-traced. |
---|
15 | The most important implementing classes are TriangleMesh and Transformed (usually referring to a TriangleMesh). |
---|
16 | A KDTree will build a hierarchy of Intersectables. |
---|
17 | TraingleMesh::Patch is also an implementing class, and a TriangleMesh contains a KDTree of patches. |
---|
18 | */ |
---|
19 | class Intersectable { |
---|
20 | protected: |
---|
21 | const Material* material; |
---|
22 | public: |
---|
23 | Intersectable(std::istream& isc, Material** materialTable, int nMaterials); |
---|
24 | Intersectable(); |
---|
25 | ~Intersectable(); |
---|
26 | //! bounding box for the kd-tree |
---|
27 | BoundingBox bbox; |
---|
28 | //! result of the last intersection test |
---|
29 | unsigned int lastTestedRayId; |
---|
30 | HitRec lastTestedRayResult; |
---|
31 | |
---|
32 | //! pure virtual function, must be implemented to carry out the intersection test |
---|
33 | virtual bool intersect(const Ray& ray, float& depth, float rayMin, float rayMax)=0; |
---|
34 | virtual bool intersectBackSide(const Ray& ray, float& depth, float rayMin, float rayMax)=0; |
---|
35 | virtual void getTransformedBoundingBox(const Transformation& tf, BoundingBox& bb) {bb = bbox;} |
---|
36 | |
---|
37 | const Material* getMaterial() const {return material;} |
---|
38 | |
---|
39 | //! return the surface area |
---|
40 | virtual float getSurfaceArea(); |
---|
41 | |
---|
42 | //! return a random surface point |
---|
43 | virtual void sampleSurface(Radion& radion); |
---|
44 | }; |
---|