38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#ifndef RAYTRYCPP_SPHERE_H
|
|
#define RAYTRYCPP_SPHERE_H
|
|
|
|
#include "RenderObject.h"
|
|
#include <QDebug>
|
|
|
|
namespace raytry {
|
|
|
|
class Sphere : public RenderObject {
|
|
public:
|
|
Sphere(QVector3D position, float radius);
|
|
Sphere(QVector3D position, float radius, RenderMaterial material);
|
|
Sphere();
|
|
~Sphere() override = default;
|
|
|
|
[[nodiscard]] std::optional<float> intersects(const Ray &ray) const override;
|
|
[[nodiscard]] RenderMaterial material() const override;
|
|
[[nodiscard]] QVector3D calculateNormal(QVector3D hitpoint) const override;
|
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
|
QDebug operator<<(QDebug dbg) const {
|
|
return dbg << "Sphere(" << position << ", radius" << radius << ")";
|
|
}
|
|
friend QDebug operator<<(QDebug dbg, const Sphere& sphere) {
|
|
return sphere.operator<<(std::move(dbg));
|
|
}
|
|
#endif
|
|
|
|
private:
|
|
RenderMaterial mat;
|
|
QVector3D position;
|
|
float radius;
|
|
};
|
|
|
|
}// namespace raytry
|
|
|
|
#endif//RAYTRYCPP_SPHERE_H
|