diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2024-05-16 08:03:42 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2024-05-16 08:03:42 -0400 |
commit | fdc2d91285cd9548a3c95f1bdfb75c70ccfffff6 (patch) | |
tree | 65e460dccf3336228d8b0803e334c9ab2f4bf582 /object.h | |
parent | 549fe1388c9dd641c698d4a2ea0a1e6f754df534 (diff) |
abstract objects
Diffstat (limited to 'object.h')
-rw-r--r-- | object.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/object.h b/object.h new file mode 100644 index 0000000..5db620e --- /dev/null +++ b/object.h @@ -0,0 +1,32 @@ +#ifndef OBJECT_H +#define OBJECT_H + +#include "color.h" +#include "ray.h" +#include "vec3.h" + +#include <optional> +#include <tuple> + +enum class Material : int { + Lambertian = 0, + Metal, + Dielectric, + Undefined +}; + +struct Object +{ + point3 center; + Material M; + color tint; + + Object(point3 center_, Material M_, color tint_): + center(center_), M(M_), tint(tint_) {} + + virtual std::pair<color, ray> scatter(const ray& r, double root) const = 0; + virtual std::optional<double> hit(const ray& r, double tmin, double tmax) const = 0; +}; + +#endif // OBJECT_H + |