diff options
author | Keuin <[email protected]> | 2022-04-15 12:32:42 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-15 12:32:42 +0800 |
commit | 4193adbbff4a5b633f59f88367fe1b74aec7789b (patch) | |
tree | 25056ac9e028e268193615724dda8c3ac12317d0 /sphere.h | |
parent | 2ed39ad4eb9ebf64768dbf4aeefafc5ebb072ca7 (diff) |
Code Refactor:
- Add material class.
- Move diffuse routine into separate material classes.
Diffstat (limited to 'sphere.h')
-rw-r--r-- | sphere.h | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 ¢er, double radius) : center(center), radius(radius) {} + sphere(const vec3d ¢er, 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} |