|
@@ -1,3 +1,4 @@
|
|
|
+from .exporter_settings_panel import *
|
|
|
from .logger import *
|
|
|
from .package_level import *
|
|
|
|
|
@@ -77,16 +78,16 @@ class Texture:
|
|
|
# always write the file out, since base64 encoding is easiest from a file
|
|
|
try:
|
|
|
imageFilepath = path.normpath(bpy.path.abspath(image.filepath))
|
|
|
- basename = path.basename(imageFilepath)
|
|
|
+ self.fileNoPath = path.basename(imageFilepath)
|
|
|
|
|
|
internalImage = image.packed_file or wasBaked
|
|
|
|
|
|
# when coming from either a packed image or a baked image, then save_render
|
|
|
if internalImage:
|
|
|
- if exporter.scene.inlineTextures:
|
|
|
- textureFile = path.join(exporter.textureDir, basename + "temp")
|
|
|
+ if exporter.scene.textureMethod == INLINE:
|
|
|
+ textureFile = path.join(exporter.textureDir, self.fileNoPath + 'temp')
|
|
|
else:
|
|
|
- textureFile = path.join(exporter.textureDir, basename)
|
|
|
+ textureFile = path.join(exporter.textureDir, self.fileNoPath)
|
|
|
|
|
|
image.save_render(textureFile)
|
|
|
|
|
@@ -99,7 +100,7 @@ class Texture:
|
|
|
ex = exc_info()
|
|
|
Logger.warn('Error encountered processing image file: ' + ', Error: '+ str(ex[1]))
|
|
|
|
|
|
- if exporter.scene.inlineTextures:
|
|
|
+ if exporter.scene.textureMethod == INLINE:
|
|
|
# base64 is easiest from a file, so sometimes a temp file was made above; need to delete those
|
|
|
with open(textureFile, "rb") as image_file:
|
|
|
asString = b64encode(image_file.read()).decode()
|
|
@@ -108,9 +109,18 @@ class Texture:
|
|
|
if internalImage:
|
|
|
remove(textureFile)
|
|
|
|
|
|
+ # build priority Order
|
|
|
+ if exporter.scene.textureMethod == PRIORITIZED:
|
|
|
+ nameNoExtension = self.fileNoPath.rpartition('.')[0]
|
|
|
+ self.priorityNames = []
|
|
|
+ for ext in exporter.scene.texturePriority.split():
|
|
|
+ self.priorityNames.append(nameNoExtension + ext)
|
|
|
+
|
|
|
+ # add blend image last
|
|
|
+ self.priorityNames.append(self.fileNoPath)
|
|
|
+
|
|
|
# capture texture attributes
|
|
|
self.slot = slot
|
|
|
- self.name = basename
|
|
|
self.level = level
|
|
|
|
|
|
if (texture and texture.mapping == 'CUBE'):
|
|
@@ -144,7 +154,22 @@ class Texture:
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
def to_scene_file(self, file_handler):
|
|
|
file_handler.write(', \n"' + self.slot + '":{')
|
|
|
- write_string(file_handler, 'name', self.name, True)
|
|
|
+ if hasattr(self,'encoded_URI'):
|
|
|
+ write_string(file_handler, 'base64String', self.encoded_URI)
|
|
|
+
|
|
|
+ elif hasattr(self,'priorityNames'):
|
|
|
+ file_handler.write('"name":[')
|
|
|
+ first = True
|
|
|
+ for name in self.priorityNames:
|
|
|
+ if first == False:
|
|
|
+ file_handler.write(',')
|
|
|
+ file_handler.write('"' + name + '"')
|
|
|
+ first = False
|
|
|
+ file_handler.write(']')
|
|
|
+
|
|
|
+ else:
|
|
|
+ write_string(file_handler, 'name', self.fileNoPath, True)
|
|
|
+
|
|
|
write_float(file_handler, 'level', self.level)
|
|
|
write_float(file_handler, 'hasAlpha', self.hasAlpha)
|
|
|
write_int(file_handler, 'coordinatesMode', self.coordinatesMode)
|
|
@@ -158,8 +183,6 @@ class Texture:
|
|
|
write_int(file_handler, 'wrapU', self.wrapU)
|
|
|
write_int(file_handler, 'wrapV', self.wrapV)
|
|
|
write_int(file_handler, 'coordinatesIndex', self.coordinatesIndex)
|
|
|
- if hasattr(self,'encoded_URI'):
|
|
|
- write_string(file_handler, 'base64String', self.encoded_URI)
|
|
|
file_handler.write('}')
|
|
|
#===============================================================================
|
|
|
# need to evaluate the need to bake a mesh before even starting; class also stores specific types of bakes
|