self.show_progress = True
def export_to_file(self, context, out_fn):
- from .scene import create_scene_from_current
- scene = create_scene_from_current(context, selected_only=self.selected_only, visible_only=self.visible_only)
-
- path, base = os.path.split(out_fn)
- base, ext = os.path.splitext(base)
-
from .util import Progress
progress = Progress(self.show_progress and context)
- from .export import DataExporter
- data_exporter = DataExporter()
+ from .scene import create_scene_from_current
+ scene = create_scene_from_current(context, selected_only=self.selected_only, visible_only=self.visible_only)
resources = {}
- data_exporter.export_resources(context, scene.prototypes, resources, None, progress)
+ self.export_scene_resources(context, scene, resources, progress)
scene_res = self.export_scene(scene, resources)
- refs = scene_res.collect_references()
progress.set_progress(1.0)
+ path, base = os.path.split(out_fn)
+ base, ext = os.path.splitext(base)
+
if self.collection:
existing = None
if self.skip_existing:
scene_res.write_collection(out_fn, filter=existing)
else:
scene_res.write_to_file(out_fn)
- for r in refs:
+ for r in scene_res.collect_references():
r.write_to_file(os.path.join(path, r.name))
+ def export_scene_resources(self, context, scene, resources, progress):
+ from .export import DataExporter
+ data_exporter = DataExporter()
+
+ data_exporter.export_resources(context, scene.prototypes, resources, None, progress)
+
def export_scene(self, scene, resources):
from .datafile import Resource, Statement, Token
scene_res = Resource(scene.name+".scene", "scene")
yield int((pixels[i]+pixels[i+1]+pixels[i+2])*255/3)
class TextureExporter:
- def __init__(self):
- self.inline_data = True
-
def export_texture(self, tex_node, usage='RGB', *, invert_green=False):
image = tex_node.image
from .datafile import Resource, Statement, Token
from .util import basename
fn = basename(image.filepath)
- if not self.inline_data and not invert_green and fn:
+ if not invert_green and fn:
srgb = "_srgb" if colorspace=='sRGB' else ""
tex_res.statements.append(Statement("external_image"+srgb, fn))
else: