From 893176a0b18a2281abe09def716ccc3db5583c3f Mon Sep 17 00:00:00 2001 From: Julian T Date: Sun, 26 Jul 2020 12:56:27 +0200 Subject: Implemented object intersection and startet work on render gui --- src/object.hpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/object.hpp') diff --git a/src/object.hpp b/src/object.hpp index 56c6968..3194dac 100644 --- a/src/object.hpp +++ b/src/object.hpp @@ -3,17 +3,41 @@ #include #include "vector.hpp" +#include "ray.hpp" class Material { - Vec3d color; - - double defuse; - double emissive; }; class Object { public: - std::shared_ptr m; + void setMaterial(std::shared_ptr m); + + std::shared_ptr m_mat; + + virtual Vec3d norm_at(const Vec3d &point, const Vec3d &indir) const = 0; + virtual double intersect(const Ray &ray, bool skip_dist) const = 0; +}; + +class Sphere : Object { + public: + Sphere(Vec3d center, double radius); + Vec3d norm_at(const Vec3d &point, const Vec3d &indir) const; + double intersect(const Ray &ray, bool skip_dist) const; + + private: + Vec3d m_center; + double m_radius; +}; + +class Plane : Object { + public: + Plane(Vec3d start, Vec3d norm); + Vec3d norm_at(const Vec3d &point, const Vec3d &indir) const; + double intersect(const Ray &ray, bool skip_dist) const; + + private: + Vec3d m_start; + Vec3d m_norm; }; #endif -- cgit v1.2.3