diff options
author | Keuin <[email protected]> | 2022-04-12 23:04:25 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-12 23:04:25 +0800 |
commit | 8c3cbfaeec0f3055aba9bfe4b2bdfab7ff93bf1b (patch) | |
tree | 58c032fc5dd4118d42238b03c25663d281513a67 /object.h | |
parent | c30f3650287c95742b3674299f4c3e3549db6f5e (diff) |
Refactor: move hitlist, object, sphere, viewport into single files.
Add bias_ctx for setting sub-pixel sampling bias.
Diffstat (limited to 'object.h')
-rw-r--r-- | object.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/object.h b/object.h new file mode 100644 index 0000000..b6e2bbd --- /dev/null +++ b/object.h @@ -0,0 +1,41 @@ +// +// Created by Keuin on 2022/4/12. +// + +#ifndef RT_OBJECT_H +#define RT_OBJECT_H + +#include "hitlist.h" +#include "viewport.h" +#include "timer.h" +#include "bitmap.h" +#include "ray.h" +#include "vec.h" +#include <cstdlib> +#include <memory> +#include <limits> +#include <vector> +#include <iostream> +#include <cstdint> + +class object { +public: + // Will the given ray hit. Returns time t if hits in range [t1, t2]. + virtual bool hit(const ray3d &r, double &t, double t1, double t2) const = 0; + + // With t2 = infinity + inline bool hit(const ray3d &r, double &t, double t1) const { + return hit(r, t, t1, std::numeric_limits<double>::infinity()); + } + + // Given a point on the surface, returns the normalized outer normal vector on that point. + virtual vec3d normal_vector(const vec3d &where) const = 0; + + // object color, currently not parameterized + virtual pixel8b color() const = 0; + + // subclasses must have virtual destructors + virtual ~object() = default; +}; + +#endif //RT_OBJECT_H |