mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
add obj parser
This commit is contained in:
19
includes/RT/ObjParser.hpp
Normal file
19
includes/RT/ObjParser.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ObjParser.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/13 13:56:04 by tomoron #+# #+# */
|
||||
/* Updated: 2025/01/13 13:56:05 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
class ObjParser
|
||||
{
|
||||
public:
|
||||
ObjParser(std::stringstream RT
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/26 21:37:37 by TheRed #+# #+# */
|
||||
/* Updated: 2024/12/26 21:37:37 by TheRed ### ########.fr */
|
||||
/* Updated: 2025/01/13 17:39:22 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -25,10 +25,14 @@ class SceneParser
|
||||
private:
|
||||
void parseMaterial(std::stringstream &line);
|
||||
void parseCamera(std::stringstream &line);
|
||||
void parseObj(std::stringstream &line);
|
||||
glm::vec3 getVertex(std::stringstream &line);
|
||||
Triangle *getFace(std::stringstream &line, std::vector<glm::vec3> &vertices);
|
||||
long int getVertexIndex(std::stringstream &line, size_t size);
|
||||
|
||||
Scene *_scene;
|
||||
|
||||
std::map<std::string, std::function<Object *(std::stringstream &)>> object_parsers;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user