I had accidentally posted a followup with a new version to the osg-users list. It will probably get lost there, so here's that patch again to the right list, along with a corrected description: ------------------------------------------------------------------
ac3d.cpp does currently strip everything but the file name in
"texture" paths. This is to drop absolute paths that some
3d editors export (even AC3D itself!). But this also strips
directories of relative paths, which is wrong and contradicts
the ac3d reference implementation. (The reference implementation
doesn't strip anything, though, and so takes the absolute paths
as they are. Definitely not what we want.)
The attached solution checks absolute paths and only strips
those:
(1) A:\\foo\\bar.png -> bar.png (as before)
(2) /foo/bar.png -> bar.png (as before)
(3) foo/bar.png -> foo/bar.png (new)
(4) ../foo/bar.png -> ../foo/bar.png (new)
Here's the patch for easier review (full version attached):
--- src/osgPlugins/ac/ac3d.cpp (revision 7919)
+++ src/osgPlugins/ac/ac3d.cpp (working copy)
@@ -1118,16 +1118,17 @@
group->setName(readString(stream));
}
else if (token == "texture") {
- // read the texture name
std::string texname = readString(stream);
-
- // strip the path to the texture, just look in the directory we
read the ac file
- std::string::size_type p = texname.rfind('\\');
- if (p != std::string::npos)
- texname = texname.substr(p+1, std::string::npos);
- p = texname.rfind('/');
- if (p != std::string::npos)
- texname = texname.substr(p+1, std::string::npos);
+
+ // strip absolute paths
+ if (texname[0] == '/' || isalpha(texname[0]) && texname[1] == ':')
{
+ std::string::size_type p = texname.rfind('\\');
+ if (p != std::string::npos)
+ texname = texname.substr(p+1, std::string::npos);
+ p = texname.rfind('/');
+ if (p != std::string::npos)
+ texname = texname.substr(p+1, std::string::npos);
+ }
textureData = fileData.toTextureData(texname);
}
ac3d.cpp.gz
Description: GNU Zip compressed data
_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
