namespace Assimp {
-const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
+static const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
// -------------------------------------------------------------------
// Constructor with loaded data and directories.
// -------------------------------------------------------------------
// Destructor
-ObjFileParser::~ObjFileParser()
-{
+ObjFileParser::~ObjFileParser() {
delete m_pModel;
m_pModel = NULL;
}
// -------------------------------------------------------------------
// Returns a pointer to the model instance.
-ObjFile::Model *ObjFileParser::GetModel() const
-{
+ObjFile::Model *ObjFileParser::GetModel() const {
return m_pModel;
}
}
ObjFile::Face *face = new ObjFile::Face( type );
- /*std::vector<unsigned int> *pIndices = new std::vector<unsigned int>;
- std::vector<unsigned int> *pTexID = new std::vector<unsigned int>;
- std::vector<unsigned int> *pNormalID = new std::vector<unsigned int>;*/
bool hasNormal = false;
const int vSize = m_pModel->m_Vertices.size();
++iStep;
}
- if ( iVal > 0 )
- {
+ if ( iVal > 0 ) {
// Store parsed index
- if ( 0 == iPos )
- {
+ if ( 0 == iPos ) {
face->m_vertices.push_back( iVal - 1 );
- //pIndices->push_back( iVal-1 );
- }
- else if ( 1 == iPos )
- {
+ } else if ( 1 == iPos ) {
face->m_texturCoords.push_back( iVal - 1 );
- //pTexID->push_back( iVal-1 );
- }
- else if ( 2 == iPos )
- {
+ } else if ( 2 == iPos ) {
face->m_normals.push_back( iVal - 1 );
- //pNormalID->push_back( iVal-1 );
hasNormal = true;
- }
- else
- {
+ } else {
reportErrorTokenInFace();
}
- }
- else if ( iVal < 0 )
- {
+ } else if ( iVal < 0 ) {
// Store relatively index
- if ( 0 == iPos )
- {
+ if ( 0 == iPos ) {
face->m_vertices.push_back( vSize + iVal );
- //pIndices->push_back( vSize + iVal );
- }
- else if ( 1 == iPos )
- {
+ } else if ( 1 == iPos ) {
face->m_texturCoords.push_back( vtSize + iVal );
- //pTexID->push_back( vtSize + iVal );
- }
- else if ( 2 == iPos )
- {
+ } else if ( 2 == iPos ) {
face->m_normals.push_back( vnSize + iVal );
- //pNormalID->push_back( vnSize + iVal );
hasNormal = true;
- }
- else
- {
+ } else {
reportErrorTokenInFace();
}
}
DefaultLogger::get()->error("Obj: Ignoring empty face");
// skip line and clean up
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
- /*delete pNormalID;
- delete pTexID;
- delete pIndices;*/
-
return;
}
// -------------------------------------------------------------------
// Get values for a new material description
-void ObjFileParser::getMaterialDesc()
-{
+void ObjFileParser::getMaterialDesc() {
// Get next data for material data
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
if (m_DataIt == m_DataItEnd) {
// If the current mesh has the same material, we simply ignore that 'usemtl' command
// There is no need to create another object or even mesh here
- if (m_pModel->m_pCurrentMaterial && m_pModel->m_pCurrentMaterial->MaterialName == aiString(strName))
+ if ( m_pModel->m_pCurrentMaterial && m_pModel->m_pCurrentMaterial->MaterialName == aiString( strName ) ) {
skip = true;
+ }
- if (!skip)
- {
+ if (!skip) {
// Search for material
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find(strName);
- if (it == m_pModel->m_MaterialMap.end())
- {
+ if (it == m_pModel->m_MaterialMap.end()) {
// Not found, use default material
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping");
strName = m_pModel->m_pDefaultMaterial->MaterialName.C_Str();
- }
- else
- {
+ } else {
// Found, using detected material
m_pModel->m_pCurrentMaterial = (*it).second;
}
- if (needsNewMesh(strName))
- createMesh(strName);
+ if ( needsNewMesh( strName ) ) {
+ createMesh( strName );
+ }
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex(strName);
}
// -------------------------------------------------------------------
// Get a comment, values will be skipped
-void ObjFileParser::getComment()
-{
- while (m_DataIt != m_DataItEnd)
- {
- if ( '\n' == (*m_DataIt))
- {
+void ObjFileParser::getComment() {
+ while (m_DataIt != m_DataItEnd) {
+ if ( '\n' == (*m_DataIt)) {
++m_DataIt;
break;
- }
- else
- {
+ } else {
++m_DataIt;
}
}
// -------------------------------------------------------------------
// Get material library from file.
-void ObjFileParser::getMaterialLib()
-{
+void ObjFileParser::getMaterialLib() {
// Translate tuple
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
if( m_DataIt == m_DataItEnd ) {