add obj parser

This commit is contained in:
2025-01-13 18:09:25 +01:00
parent 0482f34ce5
commit 449f059a07
10 changed files with 10480 additions and 18 deletions

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Triangle.hpp :+: :+: :+: */
/* Triangle.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2024/12/23 19:47:09 by ycontre ### ########.fr */
/* Updated: 2025/01/13 17:59:21 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,7 +53,12 @@ class Triangle : public Object
catch (const std::exception &e) { throw; }
}
Triangle(const glm::vec3& position, const glm::vec3& vertex2, const glm::vec3& vertex3, const int mat_index)
: Object(position, mat_index), _vertex2(vertex2), _vertex3(vertex3) {}
: Object(position, mat_index), _vertex2(vertex2), _vertex3(vertex3) {
_vertex2 -= _position; //optimization
_vertex3 -= _position; //optimization
_normal = glm::normalize(glm::cross(_vertex2, _vertex3)); //optimization
}
const glm::vec3 &getVertex2() const { return (_vertex2); }
const glm::vec3 &getVertex3() const { return (_vertex3); }
@ -68,4 +73,4 @@ class Triangle : public Object
glm::vec3 _normal;
};
#endif
#endif