mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-08 07:22:01 +00:00
use p1 to p4 instead of a matrix
This commit is contained in:
parent
f624514714
commit
295bdc0c89
2 changed files with 10 additions and 5 deletions
|
@ -49,14 +49,15 @@ private:
|
||||||
class Rectangle : public Geometry {
|
class Rectangle : public Geometry {
|
||||||
public:
|
public:
|
||||||
Rectangle(float ka, float kd, float ks, const Vector3f &ca, const Vector3f cd,
|
Rectangle(float ka, float kd, float ks, const Vector3f &ca, const Vector3f cd,
|
||||||
const Vector3f &cs, float pc, const Matrix<float, 3, 4> &corners)
|
const Vector3f &cs, float pc, const Vector3f &p1,
|
||||||
: Geometry(Type::RECTANGLE, ka, kd, ks, ca, cd, cs, pc),
|
const Vector3f &p2, const Vector3f &p3, const Vector3f &p4)
|
||||||
corners(corners) {}
|
: Geometry(Type::RECTANGLE, ka, kd, ks, ca, cd, cs, pc), p1(p1), p2(p2),
|
||||||
|
p3(p3), p4(p4) {}
|
||||||
|
|
||||||
bool intersect(const Ray &) const override;
|
bool intersect(const Ray &) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Matrix<float, 3, 4> corners;
|
Vector3f p1, p2, p3, p4;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !GEOMETRY_H_
|
#endif // !GEOMETRY_H_
|
||||||
|
|
|
@ -95,8 +95,12 @@ Rectangle *Parser::getRectangle(const nlohmann::json &j, float ka, float kd,
|
||||||
const Vector3f &cd, const Vector3f &cs,
|
const Vector3f &cd, const Vector3f &cs,
|
||||||
float pc) {
|
float pc) {
|
||||||
Matrix<float, 3, 4> corners = getCorners(j);
|
Matrix<float, 3, 4> corners = getCorners(j);
|
||||||
|
Vector3f p1 = getVector3f(j["p1"]);
|
||||||
|
Vector3f p2 = getVector3f(j["p2"]);
|
||||||
|
Vector3f p3 = getVector3f(j["p3"]);
|
||||||
|
Vector3f p4 = getVector3f(j["p4"]);
|
||||||
|
|
||||||
return new Rectangle(ka, kd, ks, ca, cd, cs, pc, corners);
|
return new Rectangle(ka, kd, ks, ca, cd, cs, pc, p1, p2, p3, p4);
|
||||||
}
|
}
|
||||||
|
|
||||||
Light *Parser::getLight(const nlohmann::json &j) {
|
Light *Parser::getLight(const nlohmann::json &j) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue