Example #1
0
// -------------------------------------------------------------------
//	Stores values for a new object instance, name will be used to 
//	identify it.
void ObjFileParser::getObjectName()
{
	m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
	if (m_DataIt == m_DataItEnd)
		return;
	char *pStart = &(*m_DataIt);
	while ( m_DataIt != m_DataItEnd && !isSeparator( *m_DataIt ) )
		++m_DataIt;

	std::string strObjectName(pStart, &(*m_DataIt));
	if (!strObjectName.empty()) 
	{
		// Reset current object
		m_pModel->m_pCurrent = NULL;
		
		// Search for actual object
		for (std::vector<ObjFile::Object*>::const_iterator it = m_pModel->m_Objects.begin();
			it != m_pModel->m_Objects.end();
			++it)
		{
			if ((*it)->m_strObjName == strObjectName)
			{
				m_pModel->m_pCurrent = *it;
				break;
			}
		}

		// Allocate a new object, if current one was not found before
		if ( NULL == m_pModel->m_pCurrent )
			createObject(strObjectName);
	}
	m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
}