mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
change obj parsing to its own object and start polygon triangulation
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/27 14:52:10 by TheRed #+# #+# */
|
||||
/* Updated: 2025/01/08 17:44:56 by ycontre ### ########.fr */
|
||||
/* Updated: 2025/01/16 15:02:34 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -60,7 +60,8 @@ struct Vertex {
|
||||
# include "Shader.hpp"
|
||||
# include "Scene.hpp"
|
||||
# include "SceneParser.hpp"
|
||||
# include "ObjParser.hpp"
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
37
includes/RT/ObjParser.hpp
Normal file
37
includes/RT/ObjParser.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ObjParser.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/16 15:00:49 by tomoron #+# #+# */
|
||||
/* Updated: 2025/01/16 22:00:15 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef OBJPARSER_HPP
|
||||
# define OBJPARSER_HPP
|
||||
|
||||
#include "RT.hpp"
|
||||
|
||||
class ObjParser
|
||||
{
|
||||
public:
|
||||
ObjParser(std::string &filename);
|
||||
~ObjParser();
|
||||
void parse(Scene &scene);
|
||||
|
||||
private:
|
||||
glm::vec3 getVertex(std::stringstream &line);
|
||||
void addFace(std::stringstream &line, std::vector<glm::vec3> &vertices, int mat, Scene &scene);
|
||||
long int checkVertexIndex(int index, size_t size);
|
||||
void parseMtl(std::stringstream &line, std::map<std::string, int> &materials, Scene &scene);
|
||||
void addTriangleFromPolygon(std::vector<glm::vec3> &vertices, Scene &scene);
|
||||
void addTriangle(glm::vec3 v1, glm::vec3 v2, glm::vec3 v3, int mat, Scene &scene);
|
||||
|
||||
std::ifstream _file;
|
||||
std::vector<glm::vec3> vertex;
|
||||
};
|
||||
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/26 21:37:37 by TheRed #+# #+# */
|
||||
/* Updated: 2025/01/15 12:34:11 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/01/16 15:02:01 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -25,11 +25,6 @@ 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, int mat);
|
||||
long int getVertexIndex(std::stringstream &line, size_t size);
|
||||
void parseMtl(std::stringstream &line, std::map<std::string, int> &materials);
|
||||
|
||||
Scene *_scene;
|
||||
|
||||
|
Reference in New Issue
Block a user