weimingtom / away3d

Automatically exported from code.google.com/p/away3d
0 stars 1 forks source link

Collada texture filenames - strip absolute paths #58

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Some .DAE (collada) files seem to contain absolute paths to textures, for
example "file:///c:/some/directory/image.jpg". Here's a patch that strips
anything up to the last (back- or forward-)slash character in texture file
names.

Index: Collada.as
===================================================================
--- Collada.as  (revision 1661)
+++ Collada.as  (working copy)
@@ -1247,6 +1247,9 @@
                {
                    filename = filename.substr( 2 );
                }
+               if (ini.getBoolean("texture_file_name_strip_paths", true)) {
+                   filename = String(filename).replace(/^(.*[\\\/])/, ""); // Removes
everything from start of string until last (back|forward)slash, keeping the
end of string
+               }
            }
            return filename;
        }
@@ -1368,4 +1371,4 @@
             return output;
         }
     }
-}
\ No newline at end of file
+}

Original issue reported on code.google.com by postmes...@gmail.com on 25 Aug 2009 at 6:05

Attachments:

GoogleCodeExporter commented 9 years ago
unfortunately, this approach would break apps trying to load collada textures 
from a
local directory as well... maybe we could sense an absolute filename and strip 
it
back to the name of the texture, and leave all others?

Original comment by rob.bate...@gmail.com on 15 Sep 2009 at 11:17

GoogleCodeExporter commented 9 years ago
Okay, maybe change the regexp to something like:

/^(file:.*[\\\/])/

(untested since I'm not at my development machine right now)

This should only strip things if it starts with "file:".

Original comment by postmes...@gmail.com on 16 Sep 2009 at 4:53