- Collada Exporter id naming scheme once again revised to exclude any potential invalid chars
- Collada Exporter outputs proper URLs for texture file names now. - Updated Collada Loader to understand and convert texture file name URLs git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1191 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/5/head
parent
3ed356d3c4
commit
6970307b4e
|
@ -156,7 +156,17 @@ void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::strin
|
||||||
{
|
{
|
||||||
mOutput << startstr << "<image id=\"" << pNameAdd << "\">" << endstr;
|
mOutput << startstr << "<image id=\"" << pNameAdd << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<init_from>" << pSurface.texture << "</init_from>" << endstr;
|
mOutput << startstr << "<init_from>";
|
||||||
|
if( pSurface.texture.find( "file://") == std::string::npos )
|
||||||
|
mOutput << "file://";
|
||||||
|
for( std::string::const_iterator it = std::begin( pSurface.texture); it != std::end( pSurface.texture); ++it )
|
||||||
|
{
|
||||||
|
if( isalnum( *it) || *it == '_' || *it == '.' || *it == '/' || *it == '\\' )
|
||||||
|
mOutput << *it;
|
||||||
|
else
|
||||||
|
mOutput << '%' << std::hex << size_t( (unsigned char) *it) << std::dec;
|
||||||
|
}
|
||||||
|
mOutput << "</init_from>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</image>" << endstr;
|
mOutput << startstr << "</image>" << endstr;
|
||||||
}
|
}
|
||||||
|
@ -224,13 +234,9 @@ void ColladaExporter::WriteMaterials()
|
||||||
if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS )
|
if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS )
|
||||||
name = "mat";
|
name = "mat";
|
||||||
materials[a].name = std::string( "m") + boost::lexical_cast<std::string> (a) + name.C_Str();
|
materials[a].name = std::string( "m") + boost::lexical_cast<std::string> (a) + name.C_Str();
|
||||||
size_t pos;
|
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it )
|
||||||
while( (pos = materials[a].name.find( '#')) != std::string::npos )
|
if( !isalnum( *it) )
|
||||||
materials[a].name[pos] = 'x';
|
*it = '_';
|
||||||
while( (pos = materials[a].name.find( ' ')) != std::string::npos )
|
|
||||||
materials[a].name[pos] = '_';
|
|
||||||
while( (pos = materials[a].name.find( '"')) != std::string::npos )
|
|
||||||
materials[a].name[pos] = '_';
|
|
||||||
|
|
||||||
ReadMaterialSurface( materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT);
|
ReadMaterialSurface( materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT);
|
||||||
if( !materials[a].ambient.texture.empty() ) numTextures++;
|
if( !materials[a].ambient.texture.empty() ) numTextures++;
|
||||||
|
|
|
@ -1398,6 +1398,24 @@ void ColladaLoader::ConvertPath (aiString& ss)
|
||||||
memmove(ss.data,ss.data+7,ss.length);
|
memmove(ss.data,ss.data+7,ss.length);
|
||||||
ss.data[ss.length] = '\0';
|
ss.data[ss.length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find and convert all %xyz special chars
|
||||||
|
char* out = ss.data;
|
||||||
|
for( const char* it = ss.data; it != ss.data + ss.length; /**/ )
|
||||||
|
{
|
||||||
|
if( *it == '%' )
|
||||||
|
{
|
||||||
|
size_t nbr = strtoul16( ++it, &it);
|
||||||
|
*out++ = nbr;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
*out++ = *it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// adjust length and terminator of the shortened string
|
||||||
|
*out = 0;
|
||||||
|
ss.length = (ptrdiff_t) (out - ss.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue