Improved reader for textureMaps. Now ignoring empty testure definitions.

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@124 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2009-05-11 12:00:25 +00:00
parent 0865d8174e
commit 2bc737b798

View File

@@ -69,8 +69,8 @@ _OBJReader_& OBJReader() { return __OBJReaderInstance; }
void trimString( std::string& _string) { void trimString( std::string& _string) {
// Trim Both leading and trailing spaces // Trim Both leading and trailing spaces
size_t start = _string.find_first_not_of(" \t"); size_t start = _string.find_first_not_of(" \t\r\n");
size_t end = _string.find_last_not_of(" \t"); size_t end = _string.find_last_not_of(" \t\r\n");
if(( std::string::npos == start ) || ( std::string::npos == end)) if(( std::string::npos == start ) || ( std::string::npos == end))
_string = ""; _string = "";
@@ -215,9 +215,11 @@ read_material(std::fstream& _in)
} }
#endif #endif
else if (keyWrd == "map_Kd" ) { else if (keyWrd == "map_Kd" ) {
// Get the rest of the line, removeing leading or trailing spaces // Get the rest of the line, removing leading or trailing spaces
// This will define the filename of the texture
std::getline(stream,textureName); std::getline(stream,textureName);
trimString(textureName); trimString(textureName);
if ( ! textureName.empty() )
mat.set_map_Kd( textureName, textureId++ ); mat.set_map_Kd( textureName, textureId++ );
} }
else if (keyWrd == "Tr") // transparency value else if (keyWrd == "Tr") // transparency value
@@ -316,7 +318,6 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt)
} }
} }
// mat.has_map_Kd();
} }
// usemtl // usemtl