|
ModelViewer 0.1
Template for CPP projects
|
Class for loading OBJ models. More...
#include <ObjLoader.hpp>


Public Member Functions | |
| ObjLoader () | |
| Constructor. | |
| ~ObjLoader () override=default | |
| Destructor. | |
| bool | loadModel (const std::string &filepath) override |
| Load an OBJ model from a file. | |
| QQuick3DGeometry * | geometry () const override |
| Get the geometry of the loaded model. | |
| material::MTLMaterial * | material () const override |
| Get the material of the loaded model. | |
| const std::vector< geometry::Vector3 > & | getVertices () const |
| const std::vector< geometry::TextureCoordinate > & | getTextureCoords () const |
| const std::vector< geometry::Vector3 > & | getNormals () const |
| const std::vector< geometry::FaceIndex > & | getFaces () const |
| const std::string & | getModelPath () const |
Public Member Functions inherited from model_viewer::loaders::ILoader | |
| virtual | ~ILoader ()=default |
| Virtual destructor. | |
Private Member Functions | |
| void | reset () |
| Reset the OBJ loader state. | |
| void | parseModel (std::ifstream &file) |
| Parse an OBJ file line by line. | |
| void | setModelData () |
| Set the model data to the geometry. | |
| void | resetObj () |
| Reset the OBJ model state. | |
| void | parseVertice (const std::string &line) |
| Parse a vertice line from the OBJ file. | |
| void | parseNormal (const std::string &line) |
| Parse a normal vertice line from the OBJ file. | |
| void | parseTextureCoordinate (const std::string &line) |
| Parse a texture coordinate vertice line from the OBJ file. | |
| void | parseFace (const std::string &line) |
| Parse a face line from the OBJ file. | |
| geometry::FaceIndex | parseFaceIndex (const std::string &token) |
| Parse a face index token from the OBJ file. | |
| void | retrieveMaterial (const std::string &line) |
| Retrieve material from a material library line and call material's parsing method. | |
Private Attributes | |
| std::vector< geometry::Vector3 > | _vertices |
| Vertices of the model. | |
| std::vector< geometry::TextureCoordinate > | _textureCoords |
| Texture coordinates of the model. | |
| std::vector< geometry::Vector3 > | _normals |
| Normals of the model. | |
| std::vector< geometry::FaceIndex > | _faces |
| Faces of the model. | |
| std::string | _modelPath |
| Path to the model file. | |
| std::unordered_map< std::string, std::function< void(const std::string &)> > | _parseFunctions |
| Map of parsing functions for different OBJ line prefixes. | |
| std::unique_ptr< geometry::ObjGeometry > | _geometry |
| Geometry of the model. | |
| std::unique_ptr< material::MTLMaterial > | _material |
| Material of the model. | |
Class for loading OBJ models.
| model_viewer::loaders::ObjLoader::ObjLoader | ( | ) |
Constructor.
References _parseFunctions, parseFace(), parseNormal(), parseTextureCoordinate(), parseVertice(), and retrieveMaterial().

|
overridedefault |
Destructor.
|
inlineoverridevirtual |
Get the geometry of the loaded model.
Implements model_viewer::loaders::ILoader.
References _geometry.
|
inline |
References _faces.
|
inline |
References _modelPath.
|
inline |
References _normals.
|
inline |
References _textureCoords.
|
inline |
References _vertices.
|
overridevirtual |
Load an OBJ model from a file.
| filepath | Path to the OBJ file |
Implements model_viewer::loaders::ILoader.
References _modelPath, model_viewer::string_helpers::normalizePath(), parseModel(), reset(), and setModelData().

|
inlineoverridevirtual |
Get the material of the loaded model.
Implements model_viewer::loaders::ILoader.
References _material.
|
private |
Parse a face line from the OBJ file.
| line | Line to parse |
References _faces, and parseFaceIndex().
Referenced by ObjLoader().


|
private |
Parse a face index token from the OBJ file.
| token | Token to parse |
References model_viewer::geometry::FaceIndex::v, model_viewer::geometry::FaceIndex::vn, and model_viewer::geometry::FaceIndex::vt.
Referenced by parseFace().

|
private |
Parse an OBJ file line by line.
| file | Input file stream to parse |
References _parseFunctions, and model_viewer::string_helpers::trim_copy().
Referenced by loadModel().


|
private |
Parse a normal vertice line from the OBJ file.
| line | Line to parse |
References _normals.
Referenced by ObjLoader().

|
private |
Parse a texture coordinate vertice line from the OBJ file.
| line | Line to parse |
References _textureCoords.
Referenced by ObjLoader().

|
private |
Parse a vertice line from the OBJ file.
| line | Line to parse |
References _vertices.
Referenced by ObjLoader().

|
private |
Reset the OBJ loader state.
References _material, and resetObj().
Referenced by loadModel().


|
private |
Reset the OBJ model state.
References _faces, _normals, _textureCoords, and _vertices.
Referenced by reset().

|
private |
Retrieve material from a material library line and call material's parsing method.
| line | Line to parse |
References _material, _modelPath, and model_viewer::string_helpers::trim_copy().
Referenced by ObjLoader().


|
private |
Set the model data to the geometry.
References _faces, _geometry, _normals, _textureCoords, and _vertices.
Referenced by loadModel().

|
private |
Faces of the model.
Referenced by getFaces(), parseFace(), resetObj(), and setModelData().
|
private |
Geometry of the model.
Referenced by geometry(), and setModelData().
|
private |
Material of the model.
Referenced by material(), reset(), and retrieveMaterial().
|
private |
Path to the model file.
Referenced by getModelPath(), loadModel(), and retrieveMaterial().
|
private |
Normals of the model.
Referenced by getNormals(), parseNormal(), resetObj(), and setModelData().
|
private |
Map of parsing functions for different OBJ line prefixes.
Referenced by ObjLoader(), and parseModel().
|
private |
Texture coordinates of the model.
Referenced by getTextureCoords(), parseTextureCoordinate(), resetObj(), and setModelData().
|
private |
Vertices of the model.
Referenced by getVertices(), parseVertice(), resetObj(), and setModelData().