add geometry parser

This commit is contained in:
Shuo Feng 2024-02-18 20:21:43 -05:00
parent 9f63434b12
commit 73b90f7535
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1
3 changed files with 13 additions and 2 deletions

View file

@ -71,9 +71,13 @@ Geometry *Parser::getGeometry(const nlohmann::json &j) {
return g;
}
// TODO: return four corners for rectangles and area lights
// helper function to get four corners of a rectangle
const Matrix<float, 3, 4> getCorners(const nlohmann::json &j) {
return Matrix<float, 3, 4>();
Matrix<float, 3, 4> corners;
for (int i = 0; i < 4; ++i) {
corners.col(i) = getVector3f(j["p" + std::to_string(i + 1)]);
}
return corners;
}
Sphere *Parser::getSphere(const nlohmann::json &j, float ka, float kd, float ks,