mirror of
https://github.com/blender/blender-addons.git
synced 2025-08-16 15:35:05 +00:00
bugfix [#25903] Export to X3D should provide relative path with forward slash for subdirectories in url of ImageTexture
This commit is contained in:
@ -591,18 +591,19 @@ class x3d_class:
|
||||
|
||||
self.write_indented("<ImageTexture DEF=\"%s\" " % self.cleanStr(name), 1)
|
||||
filepath = image.filepath
|
||||
relpath = os.path.dirname(self.filepath) # could cache
|
||||
filepath_full = bpy.path.abspath(filepath)
|
||||
# collect image paths, can load multiple
|
||||
# [relative, absolute, name-only]
|
||||
# [relative, name-only, absolute]
|
||||
images = []
|
||||
|
||||
if bpy.path.is_subdir(filepath_full, self.filepath):
|
||||
images.append(os.path.relpath(filepath_full, self.filepath))
|
||||
if bpy.path.is_subdir(filepath_full, relpath):
|
||||
images.append(os.path.relpath(filepath_full, relpath))
|
||||
|
||||
images.append(filepath_full)
|
||||
images.append(os.path.basename(filepath_full))
|
||||
images.append(filepath_full)
|
||||
|
||||
self.file.write("url='%s' />" % " ".join(["\"%s\"" % f for f in images]))
|
||||
self.file.write("url='%s' />" % " ".join(["\"%s\"" % f.replace("\\", "/") for f in images]))
|
||||
self.write_indented("\n", -1)
|
||||
|
||||
def writeBackground(self, world, alltextures):
|
||||
|
@ -614,15 +614,15 @@ class VIEW3D_MT_master_material(bpy.types.Menu):
|
||||
layout.menu("VIEW3D_MT_assign_material", icon='ZOOMIN')
|
||||
layout.menu("VIEW3D_MT_select_material", icon='HAND')
|
||||
layout.separator()
|
||||
layout.operator("clean_material_slots",
|
||||
layout.operator("view3d.clean_material_slots",
|
||||
text = 'Clean Material Slots', icon='CANCEL')
|
||||
layout.operator("material_to_texface",
|
||||
layout.operator("view3d.material_to_texface",
|
||||
text = 'Material to Texface',icon='FACESEL_HLT')
|
||||
layout.operator("texface_to_material",
|
||||
layout.operator("view3d.texface_to_material",
|
||||
text = 'Texface to Material',icon='FACESEL_HLT')
|
||||
|
||||
layout.separator()
|
||||
layout.operator("replace_material",
|
||||
layout.operator("view3d.replace_material",
|
||||
text = 'Replace Material', icon='ARROW_LEFTRIGHT')
|
||||
|
||||
|
||||
@ -638,11 +638,11 @@ class VIEW3D_MT_assign_material(bpy.types.Menu):
|
||||
layout.label
|
||||
for i in range (len(bpy.data.materials)):
|
||||
|
||||
layout.operator("assign_material",
|
||||
layout.operator("view3d.assign_material",
|
||||
text=bpy.data.materials[i].name,
|
||||
icon='MATERIAL_DATA').matname = bpy.data.materials[i].name
|
||||
|
||||
layout.operator("assign_material",text="Add New",
|
||||
layout.operator("view3d.assign_material",text="Add New",
|
||||
icon='ZOOMIN')
|
||||
|
||||
class VIEW3D_MT_select_material(bpy.types.Menu):
|
||||
@ -658,7 +658,7 @@ class VIEW3D_MT_select_material(bpy.types.Menu):
|
||||
#show all materials in entire blend file
|
||||
for i in range (len(bpy.data.materials)):
|
||||
|
||||
layout.operator("select_material_by_name",
|
||||
layout.operator("view3d.select_material_by_name",
|
||||
text=bpy.data.materials[i].name,
|
||||
icon='MATERIAL_DATA').matname = bpy.data.materials[i].name
|
||||
|
||||
@ -667,7 +667,7 @@ class VIEW3D_MT_select_material(bpy.types.Menu):
|
||||
#show only the materials on this object
|
||||
mats = ob.material_slots.keys()
|
||||
for m in mats:
|
||||
layout.operator("select_material_by_name",
|
||||
layout.operator("view3d.select_material_by_name",
|
||||
text=m,
|
||||
icon='MATERIAL_DATA').matname = m
|
||||
|
||||
|
Reference in New Issue
Block a user