OBJParser
OBJ File Parser Powered by Boost Spirit
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OBJState Class Reference

#include <OBJState.hpp>

Public Member Functions

void clearState ()
 
void reserve (uint32_t spatial, uint32_t texture=0, uint32_t normal=0, uint32_t groupFaces=0, uint32_t groupFreeForms=0)
 
OBJFreeFormStategetFreeFormState ()
 
OBJRenderState getRenderState (uint32_t index) const
 
void getGroups (std::vector< OBJGroup const * > &groups) const
 
std::vector< OBJVector4 > const * getSpatialData () const
 
std::vector< OBJVector2 > const * getTextureData () const
 
std::vector< OBJVector3 > const * getNormalData () const
 
std::vector< std::string > const * getMaterialLibraries () const
 
void getMaterials (std::vector< OBJMaterial const * > &materials) const
 
void clearActiveGroups ()
 
void addActiveGroup (std::string const &name)
 
void addVertexSpatial (OBJVector4 const &vector)
 
void addVertexTexture (OBJVector2 const &vector)
 
void addVertexNormal (OBJVector3 const &vector)
 
void addVertexParameter (OBJVector3 const &vector)
 
void addFace (OBJFace face)
 
void addLine (std::vector< OBJVertexGroup > &line)
 
void addPointCollection (std::vector< OBJVertexGroup > &points)
 
void addFreeFormCurve (OBJCurve const &curve)
 
void addFreeFormCurve2D (std::vector< int32_t > const &points)
 
void addFreeFormSurface (OBJSurface const &surface)
 
void addFreeFormConnection (OBJSurfaceConnection connection)
 
void addFreeFormParameterU (std::vector< float > const &parameters)
 
void addFreeFormParameterV (std::vector< float > const &parameters)
 
void addFreeFormTrim (OBJSimpleCurve const &trim)
 
void addFreeFormHole (OBJSimpleCurve const &hole)
 
void addFreeFormSpecialCurve (OBJSimpleCurve const &scurve)
 
void addFreeFormSpecialPoints (std::vector< int32_t > const &points)
 
void setSmoothingGroup (uint32_t group)
 
void setLevelOfDetail (uint32_t lod)
 
void setBevelInterp (bool on)
 
void setColorInterp (bool on)
 
void setDissolveInterp (bool on)
 
void setMaterial (std::string const &name)
 
void setMaterial (std::string const &name, OBJMaterial const &material)
 
void addMaterialLibrary (std::string const &path)
 
void setTextureMap (std::string const &name)
 
void addTextureMapLibrary (std::string const &path)
 
void setShadowObject (std::string const &name)
 
void setTracingObject (std::string const &name)
 
void setTechniqueParametric (float res)
 
void setTechniqueParametricA (OBJVector2 const &vec)
 
void setTechniqueParametricB (float res)
 
void setTechniqueSpatialCurve (float length)
 
void setTechniqueSpatialSurface (float length)
 
void setTechniqueCurvatureCurve (OBJVector2 const &vec)
 
void setTechniqueCurvatureSurface (OBJVector2 const &vec)
 
void setFreeFormType (OBJFreeFormType type)
 
void setFreeFormRational (bool rational)
 
void setFreeFormDegreeU (int32_t degree)
 
void setFreeFormDegreeV (int32_t degree)
 
void setFreeFormStepU (int32_t step)
 
void setFreeFormStepV (int32_t step)
 
void setFreeFormBasisMatrixU (std::vector< float > const &matrix)
 
void setFreeFormBasisMatrixV (std::vector< float > const &matrix)
 
void setFreeFormMergeGroupNumber (int32_t id)
 
void setFreeFormMergeGroupResolution (float res)
 

Protected Member Functions

void resetAuxiliaryStates ()
 
void transformVertexGroup (OBJVertexGroup &source) const
 

Protected Attributes

uint32_t m_GroupFacesReservedSize
 
uint32_t m_GroupFreeFormReservedSize
 
OBJFreeFormState m_FreeFormState
 
bool m_FreeFormRational
 
std::unordered_map
< std::string, OBJGroup
m_GroupMap
 
std::unordered_map
< std::string, OBJMaterial
m_MaterialMap
 
std::vector< OBJGroup * > m_ActiveGroups
 
std::vector< OBJVector4 > m_VertexSpatialData
 
std::vector< OBJVector2m_VertexTextureData
 
std::vector< OBJVector3m_VertexNormalData
 
std::vector< std::string > m_MaterialLibraries
 
std::vector< std::string > m_TextureMapLibraries
 
std::vector< OBJRenderStatem_RenderStates
 

Detailed Description

OBJ is a state-based file format, and this class represents that state. It keeps track of all groups and their associated data.

After parsing, this data can then be retrieved from the state object.

Member Function Documentation

void OBJState::addActiveGroup ( std::string const &  name)

Adds an additional active group. If the group has not been added before, then a new group is created.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]nameGroup name.
void OBJState::addFace ( OBJFace  face)

Adds a new face element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]faceFace to add.
void OBJState::addFreeFormConnection ( OBJSurfaceConnection  connection)

Adds a new OBJSurfaceConnection to the internal OBJFreeFormState.

Parameters
[in]connection
void OBJState::addFreeFormCurve ( OBJCurve const &  curve)

Adds a new OBJCurve to the internal OBJFreeFormState.

Parameters
[in]curve
void OBJState::addFreeFormCurve2D ( std::vector< int32_t > const &  points)

Adds a new OBJCurve2D to the internal OBJFreeFormState.

Parameters
[in]points
void OBJState::addFreeFormHole ( OBJSimpleCurve const &  hole)

Adds hole values to the newest OBJFreeForm in the internal OBJFreeFormState.

Parameters
[in]hole
void OBJState::addFreeFormParameterU ( std::vector< float > const &  parameters)

Adds parameter u values to the newest OBJFreeForm in the internal OBJFreeFormState.

Parameters
[in]parameters
void OBJState::addFreeFormParameterV ( std::vector< float > const &  parameters)

Adds parameter v values to the newest OBJFreeForm in the internal OBJFreeFormState.

Parameters
[in]parameters
void OBJState::addFreeFormSpecialCurve ( OBJSimpleCurve const &  scurve)

Adds scurve values to the newest OBJFreeForm in the internal OBJFreeFormState.

Parameters
[in]scurve
void OBJState::addFreeFormSpecialPoints ( std::vector< int32_t > const &  points)

Adds points values to the newest OBJFreeForm in the internal OBJFreeFormState.

Parameters
[in]points
void OBJState::addFreeFormSurface ( OBJSurface const &  surface)

Adds a new OBJSurface to the internal OBJFreeFormState.

Parameters
[in]surface
void OBJState::addFreeFormTrim ( OBJSimpleCurve const &  trim)

Adds trim values to the newest OBJFreeForm in the internal OBJFreeFormState.

Parameters
[in]trim
void OBJState::addLine ( std::vector< OBJVertexGroup > &  line)

Adds a new line element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]lineLine to add.
void OBJState::addMaterialLibrary ( std::string const &  path)

Adds a new material library to create materials from.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]pathRelative path, including extension, from the current OBJ file.
void OBJState::addPointCollection ( std::vector< OBJVertexGroup > &  points)

Adds a new point element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]pointsPoints to add.
void OBJState::addTextureMapLibrary ( std::string const &  path)

Adds a new texture library to create textures from.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]pathRelative path, including extension, from the current OBJ file.
void OBJState::addVertexNormal ( OBJVector3 const &  vector)

Adds a new normal (x, y, z) vertex element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vectorNormal vertex to add.
void OBJState::addVertexParameter ( OBJVector3 const &  vector)

Adds a new free-form parameter (u, v, w) vertex element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vectorFree-Form parameter vertex to add.
void OBJState::addVertexSpatial ( OBJVector4 const &  vector)

Adds a new spatial (x, y, z, w) vertex element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vectorSpatial vertex to add.
void OBJState::addVertexTexture ( OBJVector2 const &  vector)

Adds a new texture (u, v) vertex element.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vectorTexture vertex to add.
void OBJState::clearActiveGroups ( )

Clears all active groups.

Note
Typically should only be used by the OBJGrammar class.
void OBJState::clearState ( )

Resets the state back to a default setting. Typically called automatically prior to starting a new parse.

OBJFreeFormState * OBJState::getFreeFormState ( )

Returns a pointer to the internal OBJFreeForm state. This state defines all free-form geometries, connections, and most of their attributes.

Note
This pointer will never be invalid, but the state will be cleared when clearState is called.
void OBJState::getGroups ( std::vector< OBJGroup const * > &  groups) const

Fills a vector with pointers to all OBJGroups stored in the state.

If the state is cleared (whether explicitly or upon a new parse action), then all group pointers will become invalidated.

Note
The provided vector is cleared prior to filling with groups.
Parameters
[out]groups
std::vector< std::string > const * OBJState::getMaterialLibraries ( ) const

Returns a pointer to the container of all material libraries (accompanying .mtl files).

std::vector< OBJVector3 > const * OBJState::getNormalData ( ) const

Returns a pointer to the container of all parsed normal vertex data.

Note
Keep in mind that OBJ indices are 1-based while the data container indices are 0-based.
OBJRenderState OBJState::getRenderState ( uint32_t  index) const

Retrieves the specified state of the render attributes.

Each face and free-form has an associated render attributes state detailing extra state settings that were active upon it's creation (such as material, lod, smoothing, etc.).

Parameters
[in]indexRender attribute state index. If invalid, will return the default state.
Returns
The specified render attribute state.
std::vector< OBJVector4 > const * OBJState::getSpatialData ( ) const

Returns a pointer to the container of all parsed spatial vertex data.

Note
Keep in mind that OBJ indices are 1-based while the data container indices are 0-based.
std::vector< OBJVector2 > const * OBJState::getTextureData ( ) const

Returns a pointer to the container of all parsed texture coordinate vertex data.

Note
Keep in mind that OBJ indices are 1-based while the data container indices are 0-based.
void OBJState::reserve ( uint32_t  spatial,
uint32_t  texture = 0,
uint32_t  normal = 0,
uint32_t  groupFaces = 0,
uint32_t  groupFreeForms = 0 
)

Allows the ability to specify the amount of space to reserve for the various containers used by the state. If one knows in advance the general size of the parsed objects, then reserving an adequate amount of space in advance may produce performance improvements.

Reserved size can only ever be increased and may not be decreased.

By default, the state will not reserve any space in advance.

Parameters
[in]spatialNumber of spatial vertex elements to reserve for.
[in]textureNumber of texture vertex elements to reserve for.
[in]normalNumber of normals vertex elements to reserve for.
[in]groupFacesNumber of faces to reserve in each new group.
[in]groupFreeFormsNumber of free-forms to reserve in each new group.
void OBJState::setBevelInterp ( bool  on)

Enables/disables bevel interpolation for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]on
void OBJState::setColorInterp ( bool  on)

Enables/disables color interpolation for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]on
void OBJState::setDissolveInterp ( bool  on)

Enables/disables dissolve interpolation for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]on
void OBJState::setFreeFormBasisMatrixU ( std::vector< float > const &  matrix)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]matrix
void OBJState::setFreeFormBasisMatrixV ( std::vector< float > const &  matrix)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]matrix
void OBJState::setFreeFormDegreeU ( int32_t  degree)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]degree
void OBJState::setFreeFormDegreeV ( int32_t  degree)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]degree
void OBJState::setFreeFormMergeGroupNumber ( int32_t  id)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]id
void OBJState::setFreeFormMergeGroupResolution ( float  res)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]res
void OBJState::setFreeFormRational ( bool  rational)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]rational
void OBJState::setFreeFormStepU ( int32_t  step)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]step
void OBJState::setFreeFormStepV ( int32_t  step)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]step
void OBJState::setFreeFormType ( OBJFreeFormType  type)

Sets an attribute on the current OBJFreeFormAttributeState

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]type
void OBJState::setLevelOfDetail ( uint32_t  lod)

Sets the level-of-detail for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]lod
void OBJState::setMaterial ( std::string const &  name)

Sets the bound material for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]name
void OBJState::setMaterial ( std::string const &  name,
OBJMaterial const &  material 
)

Sets the material data for the specified material name.

Note
Typically should only be used by the MTLGrammar class.
Parameters
[in]name
[in]material
void OBJState::setShadowObject ( std::string const &  name)

Sets the bound shadow object for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]name
void OBJState::setSmoothingGroup ( uint32_t  group)

Sets the smoothing group for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]group
void OBJState::setTechniqueCurvatureCurve ( OBJVector2 const &  vec)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vec
void OBJState::setTechniqueCurvatureSurface ( OBJVector2 const &  vec)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vec
void OBJState::setTechniqueParametric ( float  res)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]res
void OBJState::setTechniqueParametricA ( OBJVector2 const &  vec)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]vec
void OBJState::setTechniqueParametricB ( float  res)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]res
void OBJState::setTechniqueSpatialCurve ( float  length)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]length
void OBJState::setTechniqueSpatialSurface ( float  length)

Sets a technique attribute on the current RenderState.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]length
void OBJState::setTextureMap ( std::string const &  name)

Sets the bound texture for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]name
void OBJState::setTracingObject ( std::string const &  name)

Sets the bound tracing object for the current auxiliary state.

Note
Typically should only be used by the OBJGrammar class.
Parameters
[in]name

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