Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
cinder::ObjLoader Class Reference

Loads Alias|Wavefront .OBJ file format. More...

#include <ObjLoader.h>

Classes

struct  Face
 
struct  Group
 
struct  Material
 

Public Member Functions

 ObjLoader (std::shared_ptr< IStreamCinder > aStream, bool includeUVs=true)
 
 ObjLoader (DataSourceRef dataSource, bool includeUVs=true)
 
 ObjLoader (DataSourceRef dataSource, DataSourceRef materialSource, bool includeUVs=true)
 
 ~ObjLoader ()
 
void load (TriMesh *destTriMesh, boost::tribool loadNormals=boost::logic::indeterminate, boost::tribool loadTexCoords=boost::logic::indeterminate, bool optimizeVertices=true)
 
void load (size_t groupIndex, TriMesh *destTriMesh, boost::tribool loadNormals=boost::logic::indeterminate, boost::tribool loadTexCoords=boost::logic::indeterminate, bool optimizeVertices=true)
 
size_t getNumGroups () const
 Returns the total number of groups. More...
 
const std::vector< Group > & getGroups () const
 Returns a vector<> of the Groups in the OBJ. More...
 

Static Public Member Functions

static void write (DataTargetRef dataTarget, const TriMesh &mesh, bool writeNormals=true, bool writeUVs=true)
 Writes a new OBJ file to dataTarget. More...
 

Detailed Description

Loads Alias|Wavefront .OBJ file format.

Currently does not support anything but polygonal data
Example usage:

ObjLoader loader( loadFile( "myPath/cube.obj" ) );
loader.load( &myCube );
gl::draw( myCube );

Constructor & Destructor Documentation

cinder::ObjLoader::ObjLoader ( std::shared_ptr< IStreamCinder aStream,
bool  includeUVs = true 
)

Constructs and does the parsing of the file

Parameters
includeUVsif false UV coordinates will be skipped, which can provide a faster load time
cinder::ObjLoader::ObjLoader ( DataSourceRef  dataSource,
bool  includeUVs = true 
)

Constructs and does the parsing of the file

Parameters
includeUVsif false UV coordinates will be skipped, which can provide a faster load time
cinder::ObjLoader::ObjLoader ( DataSourceRef  dataSource,
DataSourceRef  materialSource,
bool  includeUVs = true 
)

Constructs and does the parsing of the file

Parameters
includeUVsif false UV coordinates will be skipped, which can provide a faster load time
cinder::ObjLoader::~ObjLoader ( )

Member Function Documentation

void cinder::ObjLoader::load ( TriMesh destTriMesh,
boost::tribool  loadNormals = boost::logic::indeterminate,
boost::tribool  loadTexCoords = boost::logic::indeterminate,
bool  optimizeVertices = true 
)

Loads all the groups present in the file into a single TriMesh

Parameters
destTriMeshthe destination TriMesh, whose contents are cleared first
loadNormalsshould normals be loaded or generated if not present. Default determines from the contents of the file
loadTexCoordsshould 2D texture coordinates be loaded or set to zero if not present. Default determines from the contents of the file
optimizeVerticesshould the loader minimze the vertices by identifying shared vertices between faces.
void cinder::ObjLoader::load ( size_t  groupIndex,
TriMesh destTriMesh,
boost::tribool  loadNormals = boost::logic::indeterminate,
boost::tribool  loadTexCoords = boost::logic::indeterminate,
bool  optimizeVertices = true 
)

Loads a particular group into a TriMesh

Parameters
loadNormalsshould normals be loaded or generated if not present. Default determines from the contents of the file
loadTexCoordsshould 2D texture coordinates be loaded or set to zero if not present. Default determines from the contents of the file
optimizeVerticesshould the loader minimize the vertices by identifying shared vertices between faces.
void cinder::ObjLoader::write ( DataTargetRef  dataTarget,
const TriMesh mesh,
bool  writeNormals = true,
bool  writeUVs = true 
)
static

Writes a new OBJ file to dataTarget.

Warning
- this method will be moved in the future
size_t cinder::ObjLoader::getNumGroups ( ) const

Returns the total number of groups.

const std::vector<Group>& cinder::ObjLoader::getGroups ( ) const

Returns a vector<> of the Groups in the OBJ.


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