summaryrefslogtreecommitdiff
path: root/sphere.h
diff options
context:
space:
mode:
Diffstat (limited to 'sphere.h')
-rw-r--r--sphere.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/sphere.h b/sphere.h
index f604b74..fa181e7 100644
--- a/sphere.h
+++ b/sphere.h
@@ -10,6 +10,7 @@
#include "viewport.h"
#include "timer.h"
#include "bitmap.h"
+#include "material.h"
#include "ray.h"
#include "vec.h"
#include <cstdlib>
@@ -19,14 +20,17 @@
#include <iostream>
#include <cstdint>
+class material;
+
class sphere : public object {
vec3d center;
double radius;
+ class material &materi;
public:
sphere() = delete;
- sphere(const vec3d &center, double radius) : center(center), radius(radius) {}
+ sphere(const vec3d &center, double radius, class material &materi) : center(center), radius(radius), materi(materi) {}
~sphere() override = default;
@@ -35,6 +39,10 @@ public:
return (where - center) / radius;
}
+ class material &material() const override {
+ return materi;
+ }
+
bool hit(const ray3d &r, double &t, double t1, double t2) const override {
// Ray: {Source, Direction, time}
// Sphere: {Center, radius}