mpri-graphics-project/util/ObjParser.hpp

32 lines
745 B
C++

/** Parses .obj mesh files, outputting a `Mesh` */
#pragma once
#include <fstream>
#include <string>
#include <stdexcept>
#include "../Mesh.hpp"
class ObjParser {
public:
class BadObj : public std::exception {
public:
BadObj(const std::string& path): path(path) {}
const char* what() const noexcept {
return (std::string("Badly formed obj file ")
+ path).c_str();
}
private:
std::string path;
};
ObjParser(const std::string& path);
Mesh parse();
private: //meth
static std::string strip(const std::string& str);
private:
std::string path;
};