C++ / OpenCL Raytracer
sphere.h
1 #ifndef SPHERE_H
2 #define SPHERE_H
3 
4 #include "object.h"
5 #include "material.h"
6 class Material;
7 
9 class Sphere : public Object {
10 public:
11  Sphere() {}
18  Sphere(Vector3D cen, double r, Material *pm) : m_vCenter(cen), m_dRadius(r), m_pmCurMat(pm) {};
19  virtual bool Hit(const Ray &r, HitRecord &rec, double tMin, double tMax) const;
20 
21  int clType() const {
22  return 0;
23  }
24  Vector3D clCenter() const {
25  return m_vCenter;
26  }
27  double clRadius() const {
28  return m_dRadius;
29  }
30  Vector3D clBound1() const {
31  return Vector3D(0);
32  }
33  Vector3D clBound2() const {
34  return Vector3D(0);
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  }
40  double m_dRadius;
42 };
43 
44 #endif // SPHERE_H
virtual double MatFuzz() const =0
virtual bool Hit(const Ray &r, HitRecord &rec, double tMin, double tMax) const
Definition: sphere.cpp:9
double y() const
Returns second (Y) location parameter in Vector3D.
Definition: vector.h:41
virtual double MatRef() const =0
Definition: object.h:19
Vector3D clBound2() const
Definition: sphere.h:33
double z() const
Returns third (Z) location parameter in Vector3D.
Definition: vector.h:42
Definition: material.h:9
Material * m_pmCurMat
Pointer to Material that the Sphere should render.
Definition: sphere.h:41
double x() const
Returns first (X) location parameter in Vector3D.
Definition: vector.h:40
virtual int MatType() const =0
Vector3D m_vCenter
Vector3D center of Sphere Object.
Definition: sphere.h:39
Vector3D clCenter() const
Definition: sphere.h:24
Definition: vector.h:16
Definition: sphere.h:9
Sphere(Vector3D cen, double r, Material *pm)
Definition: sphere.h:18
Definition: object.h:27
double clRadius() const
Definition: sphere.h:27
Vector3D clBound1() const
Definition: sphere.h:30
virtual Vector3D MatColor() const =0
int clType() const
Definition: sphere.h:21
Definition: ray.h:7
virtual cl_double8 CurMat() const
Definition: sphere.h:36
double m_dRadius
Radius of Sphere Object.
Definition: sphere.h:40