mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-08-13 17:08:04 +00:00
finish geometry class
This commit is contained in:
parent
f1e412f1d1
commit
2568be1eb8
1 changed files with 26 additions and 0 deletions
|
@ -3,14 +3,17 @@
|
||||||
|
|
||||||
#include <Eigen/Core>
|
#include <Eigen/Core>
|
||||||
|
|
||||||
|
using Eigen::Matrix;
|
||||||
using Eigen::Matrix4f;
|
using Eigen::Matrix4f;
|
||||||
using Eigen::Vector3f;
|
using Eigen::Vector3f;
|
||||||
|
|
||||||
|
// Abstract class for Geometries
|
||||||
class Geometry {
|
class Geometry {
|
||||||
public:
|
public:
|
||||||
enum class Type { SPHERE, RECTANGLE };
|
enum class Type { SPHERE, RECTANGLE };
|
||||||
|
|
||||||
virtual ~Geometry() = default;
|
virtual ~Geometry() = default;
|
||||||
|
virtual bool intersect() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Geometry(Type type, float ka, float kd, float ks, const Vector3f &ca,
|
Geometry(Type type, float ka, float kd, float ks, const Vector3f &ca,
|
||||||
|
@ -27,4 +30,27 @@ public:
|
||||||
void setTransform(const Matrix4f &);
|
void setTransform(const Matrix4f &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Sphere : public Geometry {
|
||||||
|
public:
|
||||||
|
Sphere(float ka, float kd, float ks, const Vector3f &ca, const Vector3f &cd,
|
||||||
|
const Vector3f &cs, float pc, float radius, const Vector3f ¢er)
|
||||||
|
: Geometry(Type::SPHERE, ka, kd, ks, ca, cd, cs, pc), radius(radius),
|
||||||
|
center(center) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
float radius;
|
||||||
|
Vector3f center;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Rectangle : public Geometry {
|
||||||
|
public:
|
||||||
|
Rectangle(float ka, float kd, float ks, const Vector3f &ca, const Vector3f cd,
|
||||||
|
const Vector3f &cs, float pc, const Matrix<float, 3, 4> &corners)
|
||||||
|
: Geometry(Type::RECTANGLE, ka, kd, ks, ca, cd, cs, pc),
|
||||||
|
corners(corners) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Matrix<float, 3, 4> corners;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // !GEOMETRY_H_
|
#endif // !GEOMETRY_H_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue