// ------------------------------------------------------------------- // Get values for a new material description void ObjFileParser::getMaterialDesc() { // Get next data for material data m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd); if (m_DataIt == m_DataItEnd) { return; } char *pStart = &(*m_DataIt); while( m_DataIt != m_DataItEnd && !IsLineEnd( *m_DataIt ) ) { ++m_DataIt; } // In some cases we should ignore this 'usemtl' command, this variable helps us to do so bool skip = false; // Get name std::string strName(pStart, &(*m_DataIt)); strName = trim_whitespaces(strName); if (strName.empty()) skip = true; // 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)) skip = true; 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()) { // 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 { // Found, using detected material m_pModel->m_pCurrentMaterial = (*it).second; } if (needsNewMesh(strName)) createMesh(strName); m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex(strName); } // Skip rest of line m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); }
//------------------------------------------------------------------------------ bool Player::notify(Connection* connection) { bool result = false; if (connection == m_connection) { result = true; int done = 0; while (true) { ssize_t count = m_connection->read(m_buf, sizeof(m_buf)); if (count == -1) { /* If errno == EAGAIN, that means we have read all data, otherwise it's an error so close connection. */ if (errno != EAGAIN) { TextLogger::getInstance()->write(LogLevel::LOG_ERROR, strerror(errno)); done = 1; } break; } else if (count == 0) { /* End of file. The remote has closed the connection. */ done = 1; break; } } if (!done) { m_command = m_buf; trim_whitespaces(m_command); m_commands.push(m_command); } else { /* Closing the connection will make epoll remove it from the set of descriptors which are monitored. */ delete m_connection; m_conn_state = ConnectionState::CON_STATE_LOST_LINK; } } return result; }