Plasma Engine  2.0
Loading...
Searching...
No Matches
plOBJLoader Class Reference

A loader class for OBJ/MTL files. More...

#include <OBJLoader.h>

Classes

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

Public Member Functions

void 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.
 
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.
 
plResult 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.
 
plResult LoadMTL (const char *szFile, const char *szMaterialBasePath="")
 Loads and MTL file for material information.
 

Public Attributes

plMap< plString, Materialm_Materials
 
plDeque< plVec3m_Positions
 
plDeque< plVec3m_Normals
 
plDeque< plVec3m_TexCoords
 
plDeque< Facem_Faces
 

Detailed Description

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 plOBJLoader object. For upload into a GPU the vertex information must be duplicated manually.

Member Function Documentation

◆ LoadMTL()

plResult plOBJLoader::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 PL_FAILURE when the given file could not be found.

◆ LoadOBJ()

plResult plOBJLoader::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 PL_FAILURE if the given file could not be found.


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