Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Object::OBJLoader Class Reference

#include <OBJLoader.hpp>

Public Member Functions

 OBJLoader (const std::string &filepath, const std::string &mtlSearchPath="")
 Constructs an OBJLoader for the specified file.
 ~OBJLoader ()=default
Component::Mesh GetMesh ()
 Retrieves the loaded mesh data.
std::vector< Resource::ShapeGetShapes ()
 Retrieves the loaded shapes data.
std::vector< Component::MaterialGetMaterials ()
 Retrieves the loaded materials data.

Private Member Functions

void ProcessMeshFace (Component::Mesh &mesh, const std::vector< tinyobj::shape_t > &shapes, size_t shape, size_t face_vertices, size_t &index_offset) noexcept
 Processes a single face of the mesh and populates the Mesh object.
void SetMaterialProperties (Component::Material &material, const tinyobj::material_t &mat) noexcept
 Sets the properties of a material according to the tinyobj::material_t structure.

Private Attributes

tinyobj::ObjReaderConfig _reader_config
tinyobj::ObjReader _reader
Component::Mesh _mesh {}
std::vector< Resource::Shape_shapes {}
std::vector< Component::Material_materials {}

Detailed Description

Constructor & Destructor Documentation

◆ OBJLoader()

Object::OBJLoader::OBJLoader ( const std::string & filepath,
const std::string & mtlSearchPath = "" )
explicit

Constructs an OBJLoader for the specified file.

Parameters
filepathThe path to the OBJ file.
mtlSearchPathThe path to the directory containing material files.
Exceptions
OBJLoaderErrorif the file cannot be loaded or parsed.
See also
OBJLoaderError

◆ ~OBJLoader()

Object::OBJLoader::~OBJLoader ( )
default

Member Function Documentation

◆ GetMaterials()

std::vector< Component::Material > Object::OBJLoader::GetMaterials ( )
nodiscard

Retrieves the loaded materials data.

Returns
std::vector<Component::Material> The materials data extracted from the OBJ file.
See also
Component::Material

◆ GetMesh()

Component::Mesh Object::OBJLoader::GetMesh ( )
nodiscard

Retrieves the loaded mesh data.

Returns
Component::Mesh The mesh data extracted from the OBJ file.
See also
Component::Mesh
Examples
Loading an OBJ file.

◆ GetShapes()

std::vector< Resource::Shape > Object::OBJLoader::GetShapes ( )
nodiscard

Retrieves the loaded shapes data.

Returns
std::vector<Resource::Shape> The shapes data extracted from the OBJ file.
See also
Resource::Shape

◆ ProcessMeshFace()

void Object::OBJLoader::ProcessMeshFace ( Component::Mesh & mesh,
const std::vector< tinyobj::shape_t > & shapes,
size_t shape,
size_t face_vertices,
size_t & index_offset )
privatenoexcept

Processes a single face of the mesh and populates the Mesh object.

Parameters
meshThe Mesh object to populate.
shapesThe vector of shapes loaded from the OBJ file.
shapeThe index of the current shape being processed.
face_verticesThe number of vertices in the current face.
index_offsetThe offset in the index array for the current face.
See also
Component::Mesh

◆ SetMaterialProperties()

void Object::OBJLoader::SetMaterialProperties ( Component::Material & material,
const tinyobj::material_t & mat )
privatenoexcept

Sets the properties of a material according to the tinyobj::material_t structure.

Parameters
materialThe Material object to populate.
matThe tinyobj::material_t object containing the material properties.

Member Data Documentation

◆ _materials

std::vector<Component::Material> Object::OBJLoader::_materials {}
private

◆ _mesh

Component::Mesh Object::OBJLoader::_mesh {}
private

◆ _reader

tinyobj::ObjReader Object::OBJLoader::_reader
private

◆ _reader_config

tinyobj::ObjReaderConfig Object::OBJLoader::_reader_config
private

◆ _shapes

std::vector<Resource::Shape> Object::OBJLoader::_shapes {}
private

The documentation for this class was generated from the following files: