toytracer/moving_sphere.h
2020-06-08 23:37:10 +02:00

30 lines
752 B
C++

#ifndef MOVING_SPHERE_H
#define MOVING_SPHERE_H
#include <memory>
#include "hittable.h"
#include "vec3.h"
class Moving_sphere : public Hittable {
public:
Moving_sphere() {}
Moving_sphere(Point3 cen0, Point3 cen1, double t0, double t1, double r, std::shared_ptr<Material> m)
: center0(cen0), center1(cen1), time0(t0), time1(t1), radius(r), mat_ptr(m) {}
virtual bool hit(const Ray& r, double tmin, double tmax, hit_record& rec) const;
virtual bool bounding_box(double t0, double t1, Aabb& output_box) const;
Point3 center(double time) const;
private:
Point3 center0;
Point3 center1;
double time0;
double time1;
double radius;
std::shared_ptr<Material> mat_ptr;
};
#endif // MOVING_SPHERE_H