From 41ea2d8f94043d49fc26aaaa8030a73dcfdc2da9 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sun, 24 Jan 2021 18:13:44 +0100 Subject: Create rust project --- src/object.hpp | 76 ---------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/object.hpp (limited to 'src/object.hpp') diff --git a/src/object.hpp b/src/object.hpp deleted file mode 100644 index e697ba2..0000000 --- a/src/object.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef OBJECT_H -#define OBJECT_H - -#include -#include "vector.hpp" -#include "ray.hpp" - -class Color : public Vec3d { - public: - Color() {} - Color(const Vec3d &v) : Vec3d(v) {} - Color(double r, double g, double b) : Vec3d(r, g, b) {} - - uint8_t r() { return m_x * 255; } - uint8_t g() { return m_y * 255; } - uint8_t b() { return m_z * 255; } - - Color& operator+=(const Color& op) { - Vec3d::operator+=(op); - return *this; - } - void clamp(); -}; - -// Implements phong BRDF -class Material { - public: - Material(Color color, double defuse, double emissive=0); - - Color reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out, const Color &incol) const; - - Color emits() const { - return m_color * m_emissive; - } - - // Whether the material is reflective - bool reflects() const { return m_defuse > 0; } - private: - Color m_color; - double m_defuse; - double m_emissive; -}; - -class Shape { - public: - Shape(const Material &mat) : m_mat(mat) { } - - virtual Vec3d norm_at(const Vec3d &point, const Vec3d &indir) const = 0; - virtual double intersect(const Ray &ray, bool skip_dist) const = 0; - - const Material &m_mat; -}; - -class Sphere : public Shape { - public: - Sphere(const Material &mat, 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 : public Shape { - public: - Plane(const Material &mat, 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