mpri-graphics-project/util/ObjParser.hpp

33 lines
745 B
C++
Raw Normal View History

2018-01-28 23:03:57 +01:00
/** Parses .obj mesh files, outputting a `Mesh` */
2018-02-06 19:07:07 +01:00
#pragma once
2018-01-28 23:03:57 +01:00
#include <fstream>
#include <string>
#include <stdexcept>
#include "../Mesh.hpp"
class ObjParser {
public:
2018-02-06 19:08:17 +01:00
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;
};
2018-01-28 23:03:57 +01:00
ObjParser(const std::string& path);
Mesh parse();
2018-02-06 19:08:17 +01:00
private: //meth
static std::string strip(const std::string& str);
2018-01-28 23:03:57 +01:00
private:
std::string path;
};