Support Forum       G3D Web Page     
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
G3D::ParseOBJ Class Reference

Parses OBJ files with polygonal data and their associated MTL files. More...

Classes

class  Group
 An OBJ group, created with the "g" command. More...
 
class  Index
 Set of indices into the vertex attribute arrays. More...
 
class  Mesh
 Part of a group that uses a single material. More...
 
class  Options
 

Public Types

typedef SmallArray< Index, 5 > Face
 A polygon, which is expected to be a triangle or quadrilateral but is unlimited in OBJ format. More...
 
typedef Table< String, shared_ptr< Group > > GroupTable
 Maps group names to groups. More...
 
typedef Table< shared_ptr< ParseMTL::Material >, shared_ptr< Mesh > > MeshTable
 

Public Member Functions

void parse (const char *ptr, size_t len, const String &basePath, const ParseOBJ::Options &options)
 
void parse (BinaryInput &bi, const ParseOBJ::Options &options=ParseOBJ::Options(), const String &basePath="<AUTO>")
 

Public Attributes

GroupTable groupTable
 Maps group names to groups. More...
 
Array< StringmtlArray
 stores names of MTL files included by the OBJ More...
 
Array< Vector3normalArray
 
Array< Point2texCoord0Array
 Texture coordinates in OBJ coordinate frame, where (0, 0) is the LOWER-left. More...
 
Array< Point2texCoord1Array
 
Array< Point3vertexArray
 

Static Public Attributes

static const int UNDEFINED = -1
 

Detailed Description

Parses OBJ files with polygonal data and their associated MTL files.

Ignores groups, smoothing groups, surfaces, object names. Assumes that each face is in exactly one group. Note that group information may be useful for object-level culling.

Referenced Code: http://www.martinreddy.net/gfx/3d/OBJ.spec

Uses a special text parser instead of G3D::TextInput for peak performance (about 30x faster than TextInput).

This is intentionally designed to map the file format into memory, not to process it further. That supports a number of modeling uses of the data beyond specific OpenGL-trimesh rendering.

To iterate over the meshes, use:

for (const ParseOBJ::GroupTable::Entry& groupEntry : parser.groupTable) {
const shared_ptr<ParseOBJ::Group>& group = groupEntry.value;
for (const ParseOBJ::MeshTable::Entry& meshEntry : group->meshTable) {
const shared_ptr<ParseOBJ::Mesh>& mesh = meshEntry.value;
...
}
}
See also
G3D::ParseMTL, G3D::ParsePLY, G3D::Parse3DS, G3D::ArticulatedModel

Member Typedef Documentation

◆ Face

A polygon, which is expected to be a triangle or quadrilateral but is unlimited in OBJ format.

◆ GroupTable

typedef Table<String, shared_ptr<Group> > G3D::ParseOBJ::GroupTable

Maps group names to groups.

◆ MeshTable

typedef Table<shared_ptr<ParseMTL::Material>, shared_ptr<Mesh> > G3D::ParseOBJ::MeshTable

Member Function Documentation

◆ parse() [1/2]

void G3D::ParseOBJ::parse ( const char *  ptr,
size_t  len,
const String basePath,
const ParseOBJ::Options options 
)

◆ parse() [2/2]

void G3D::ParseOBJ::parse ( BinaryInput bi,
const ParseOBJ::Options options = ParseOBJ::Options(),
const String basePath = "<AUTO>" 
)

Member Data Documentation

◆ groupTable

GroupTable G3D::ParseOBJ::groupTable

Maps group names to groups.

◆ mtlArray

Array<String> G3D::ParseOBJ::mtlArray

stores names of MTL files included by the OBJ

◆ normalArray

Array<Vector3> G3D::ParseOBJ::normalArray

◆ texCoord0Array

Array<Point2> G3D::ParseOBJ::texCoord0Array

Texture coordinates in OBJ coordinate frame, where (0, 0) is the LOWER-left.

◆ texCoord1Array

Array<Point2> G3D::ParseOBJ::texCoord1Array

◆ UNDEFINED

const int G3D::ParseOBJ::UNDEFINED = -1
static

◆ vertexArray

Array<Point3> G3D::ParseOBJ::vertexArray

documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15