From 9d96ea82d9cf7dc9af8b8cdb48a97500ef51482a Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sat, 15 Jan 2011 20:37:20 +0000 Subject: [PATCH] bugfix [#25642] Export to X3D TextureImage url field is empty export multiple image paths. --- io_scene_x3d/export_x3d.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py index c420b0cdd..03b5ec262 100644 --- a/io_scene_x3d/export_x3d.py +++ b/io_scene_x3d/export_x3d.py @@ -578,14 +578,26 @@ class x3d_class: def writeImageTexture(self, image): name = image.name - filepath = os.path.basename(image.filepath) + if image.tag: self.write_indented("<ImageTexture USE=\"%s\" />\n" % self.cleanStr(name)) else: image.tag = True self.write_indented("<ImageTexture DEF=\"%s\" " % self.cleanStr(name), 1) - self.file.write("url=\"%s\" />" % filepath) + filepath = image.filepath + filepath_full = bpy.path.abspath(filepath) + # collect image paths, can load multiple + # [relative, absolute, name-only] + images = [] + + if bpy.path.is_subdir(filepath_full, self.filepath): + images.append(os.path.relpath(filepath_full, self.filepath)) + + images.append(filepath_full) + images.append(os.path.basename(filepath_full)) + + self.file.write("url='%s' />" % " ".join(["\"%s\"" % f for f in images])) self.write_indented("\n", -1) def writeBackground(self, world, alltextures): -- GitLab