XII Release 0.1.0
Loading...
Searching...
No Matches
xiiOBJLoader Class Reference

Copyright (c) Theophilus Eriata. All Rights Reserved. More...

#include <OBJLoader.h>

Classes

struct  FaceVertex
 Stores the information for a vertex in a face. More...
struct  Material
struct  Face
 Holds all data about one face (ie. polygon, not only triangles). More...

Public Member Functions

void Clear ()
bool HasTextureCoordinates () const
 Returns whether texture-coordinates are available for this mesh.
bool HasVertexNormals () const
 Returns whether vertex-normals are available for this mesh. Otherwise only face-normals are available.
void ComputeTangentSpaceVectors ()
 Updates the tangent and bi-tangent vectors of the faces.
void SortFacesByMaterial ()
 Sorts all faces by their material.
xiiResult LoadOBJ (const char *szFile, bool bIgnoreMaterials=false)
xiiResult LoadMTL (const char *szFile, const char *szMaterialBasePath="")

Public Attributes

xiiMap< xiiString, Material > m_Materials
xiiDeque< xiiVec3 > m_Positions
xiiDeque< xiiVec3 > m_Normals
xiiDeque< xiiVec3 > m_TexCoords
xiiDeque< Face > m_Faces

Detailed Description

Copyright (c) Theophilus Eriata. All Rights Reserved.

A loader class for OBJ/MTL files.

The LoadOBJ() and LoadMTL() functions will parse the given files and add all information to the existing mesh data. You can load multiple OBJ and MTL files into this object, all information will be merged. Afterwards faces can be sorted by material and tangents and bi-tangents can be computed.

All shared information (positions, normals, texcoords) is stored using indices, so the information what is shared is preserved in the xiiOBJLoader object. For upload into a GPU the vertex information must be duplicated manually.

Member Function Documentation

◆ Clear()

void xiiOBJLoader::Clear ( )

Clears all data. Call this before LoadOBJ() / LoadMTL(), if you want to reuse the loader object to load another OBJ file, without merging them.

◆ LoadMTL()

xiiResult xiiOBJLoader::LoadMTL ( const char * szFile,
const char * szMaterialBasePath = "" )

Loads and MTL file for material information.

You can load multiple MTL files to merge them into one object. You can load an MTL file before or after loading OBJ files the missing information will be filled out whenever it is available.

Returns XII_FAILURE when the given file could not be found.

◆ LoadOBJ()

xiiResult xiiOBJLoader::LoadOBJ ( const char * szFile,
bool bIgnoreMaterials = false )

Loads an OBJ file into this object. Adds all information to the existing data, so multiple OBJ files can be merged.

Returns XII_FAILURE if the file cannot be opened or a face references an invalid vertex, normal, or texture coordinate.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Utilities/FileFormats/OBJLoader.h
  • /home/runner/work/XII/XII/Source/Engine/Utilities/FileFormats/Implementation/OBJLoader.cpp