C++ / OpenCL Raytracer
box.h
1 #ifndef BOX_H
2 #define BOX_H
3 
4 #include "object.h"
5 #include "material.h"
6 class Material;
7 
9 class Box : public Object {
10 public:
11  Box() {}
18  Box(Vector3D bound1, Vector3D bound2, Material *pm) : m_pmCurMat(pm) { m_vBounds[0] = bound1; m_vBounds[1] = bound2; };
19  virtual bool Hit(const Ray &r, HitRecord &rec, double tMin, double tMax) const;
20 
21  int clType() const {
22  return 1;
23  }
24  Vector3D clCenter() const {
25  return m_vCenter;
26  }
27  double clRadius() const {
28  return 0;
29  }
30  Vector3D clBound1() const {
31  return m_vBounds[0];
32  }
33  Vector3D clBound2() const {
34  return m_vBounds[1];
35  }
36  virtual cl_double8 CurMat() const {
37  return { cl_double(m_pmCurMat->MatColor().x()), cl_double(m_pmCurMat->MatColor().y()), cl_double(m_pmCurMat->MatColor().z()), cl_double(m_pmCurMat->MatFuzz()), cl_double(m_pmCurMat->MatRef()), cl_double(m_pmCurMat->MatType()), 0, 0 };
38  }
39  virtual Vector3D NormalCalc(const Vector3D inter) const;
42  Vector3D m_vCenter = Vector3D((m_vBounds[0].x() + m_vBounds[1].x()) / 2, (m_vBounds[0].y() + m_vBounds[1].y()) / 2, (m_vBounds[0].z() + m_vBounds[1].z()) / 2);
43 
44 };
45 #endif // BOXH
virtual double MatFuzz() const =0
double y() const
Returns second (Y) location parameter in Vector3D.
Definition: vector.h:41
virtual Vector3D NormalCalc(const Vector3D inter) const
Definition: box.cpp:46
virtual cl_double8 CurMat() const
Definition: box.h:36
virtual double MatRef() const =0
virtual bool Hit(const Ray &r, HitRecord &rec, double tMin, double tMax) const
Definition: box.cpp:10
Definition: object.h:19
double z() const
Returns third (Z) location parameter in Vector3D.
Definition: vector.h:42
Box(Vector3D bound1, Vector3D bound2, Material *pm)
Definition: box.h:18
Definition: material.h:9
double clRadius() const
Definition: box.h:27
double x() const
Returns first (X) location parameter in Vector3D.
Definition: vector.h:40
virtual int MatType() const =0
Vector3D clCenter() const
Definition: box.h:24
Definition: vector.h:16
int clType() const
Definition: box.h:21
Definition: object.h:27
Definition: box.h:9
Material * m_pmCurMat
Pointer to Material that the box should render.
Definition: box.h:40
Vector3D clBound2() const
Definition: box.h:33
virtual Vector3D MatColor() const =0
Definition: ray.h:7
Vector3D m_vBounds[2]
Array of Vector3D bounds for box.
Definition: box.h:41
Vector3D m_vCenter
Vector3D center of Box Object.
Definition: box.h:42
Vector3D clBound1() const
Definition: box.h:30