add relative path for materials in obj files and for OBJ elements in scenes

This commit is contained in:
2025-01-21 16:15:07 +01:00
parent 8fbaf4a75c
commit 46ef719f29
16 changed files with 81 additions and 24 deletions

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/16 15:00:49 by tomoron #+# #+# */
/* Updated: 2025/01/18 18:32:42 by tomoron ### ########.fr */
/* Updated: 2025/01/21 16:01:21 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@
class ObjParser
{
public:
ObjParser(std::string &filename);
ObjParser(std::string &filename, std::string &scene_filename);
~ObjParser();
void parse(Scene &scene, glm::vec3 offset, float scale, glm::mat4 transform);
@ -31,10 +31,12 @@ class ObjParser
void parseMtl(std::stringstream &line, Scene &scene);
bool addTriangleFromPolygon(std::vector<glm::vec3> &vertices, int inv);
void addTriangle(glm::vec3 v1, glm::vec3 v2, glm::vec3 v3);
std::string getFilePath(std::string &file);
int pointInTriangle(glm::vec3 pts[3], std::vector<glm::vec3> vertices, size_t cur);
std::vector<std::string> objSplit(std::string str, std::string delim);
void getFaceVertices(std::vector<glm::vec3> &faceVertices, std::stringstream &line);
std::string _filename;
std::ifstream _file;
std::vector<glm::vec3> _vertices;
std::vector<glm::vec2> _textureVertices;