ezEngine  Milestone 7
ezOBJLoader 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.
 
ezResult 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. More...
 
ezResult LoadMTL (const char *szFile, const char *szMaterialBasePath="")
 Loads and MTL file for material information. More...
 

Public Attributes

ezMap< ezString, Materialm_Materials
 
ezDeque< ezVec3m_Positions
 
ezDeque< ezVec3m_Normals
 
ezDeque< ezVec3m_TexCoords
 
ezDeque< 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 ezOBJLoader object. For upload into a GPU the vertex information must be duplicated manually.


Class Documentation

struct ezOBJLoader::Material

Holds the information about one Material.

Only the diffuse texture is actually read and stored by this loader, but if needed this can easily be extended. The MaterialID is the ID of the Material itself, this is only needed by the loader.

Class Members
ezString m_sDiffuseTexture The path to the diffuse texture of this material.
ezUInt32 m_uiMaterialID The ID of this material.

Member Function Documentation

ezResult ezOBJLoader::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 EZ_FAILURE when the given file could not be found.

ezResult ezOBJLoader::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 EZ_FAILURE if the given file could not be found.


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