[3118522] OBJ material/texture filename with spaces support.

I also added a test case for this issue.

(see https://sourceforge.net/tracker/?func=detail&aid=3118522&group_id=226462&atid=1067632)

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1157 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/5/head
aramis_acg 2012-02-03 18:16:15 +00:00
parent 06bfcbf22d
commit c84a14a7a8
3 changed files with 138 additions and 2 deletions

View File

@ -146,7 +146,8 @@ inline char_t skipLine( char_t it, char_t end, unsigned int &uiLine )
return it;
}
/** @brief Get a name, must be separated with a blank.
/** @brief Get a name from the current line. Preserve space in the middle,
* but trim it at the end.
* @param it set to current position
* @param end set to end of scratch buffer for readout
* @param name Separated name
@ -161,8 +162,14 @@ inline char_t getName( char_t it, char_t end, std::string &name )
return end;
char *pStart = &( *it );
while ( !isEndOfBuffer( it, end ) && !isSeparator( *it ) )
while ( !isEndOfBuffer( it, end ) && !isNewLine( *it ) ) {
++it;
}
while(isEndOfBuffer( it, end ) || isNewLine( *it ) || isSeparator(*it)) {
--it;
}
++it;
// Get name
std::string strName( pStart, &(*it) );

View File

@ -0,0 +1,30 @@
# Vertices: 8
# Points: 0
# Lines: 0
# Faces: 6
# Materials: 1
mtllib ./box_spaces.mtl
o 1
# Vertex list
v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v 0.5 -0.5 0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v 0.5 0.5 0.5
# Point/Line/Face list
usemtl Material name with many, many spaces
f 4 3 2 1
f 2 6 5 1
f 3 7 6 2
f 8 7 3 4
f 5 8 4 1
f 6 7 8 5
# End of file

View File

@ -0,0 +1,99 @@
# Max2Mtl Version 4.0 Mar 10th, 2001
#
newmtl Material name with many, many spaces
Ka 0.2 0.2 0.2
Kd 0.2 0.2 0.2
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Door
Ka 0.8 0.6 0.4
Kd 0.8 0.6 0.4
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Floor
Ka 0.9 0.9 0.7
Kd 0.9 0.9 0.7
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Rafter
Ka 0.8 0.5 0.2
Kd 0.8 0.5 0.2
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Ridging
Ka 0.4 0.3 0.3
Kd 0.4 0.3 0.3
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Sill
Ka 0.2 0.2 0.2
Kd 0.2 0.2 0.2
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Site
Ka 0.5 0.7 0.4
Kd 0.5 0.7 0.4
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Roof
Ka 0.9 0.9 0.6
Kd 0.9 0.9 0.6
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Terraindæk
Ka 0.4 0.3 0.3
Kd 0.4 0.3 0.3
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Wall-inner
Ka 0.8 0.7 0.5
Kd 0.8 0.7 0.5
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Wall-out
Ka 0.5 0.0 0.0
Kd 0.5 0.0 0.0
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl Windows
Ka 0.6 0.7 0.8
Kd 0.6 0.7 0.8
Ks 0.9 0.9 0.9
d 0.5
Ns 0.0
illum 2
#
# EOF