Move scene resources export to a separate function and remove some
unused bits.
return tech_res
class MaterialExporter:
return tech_res
class MaterialExporter:
- def __init__(self):
- self.inline_texture_data = False
-
def create_texture_exporter(self):
from .export_texture import TextureExporter
texture_export = TextureExporter()
def create_texture_exporter(self):
from .export_texture import TextureExporter
texture_export = TextureExporter()
- texture_export.inline_data = self.inline_texture_data
return texture_export
def export_technique_resources(self, material, resources):
return texture_export
def export_technique_resources(self, material, resources):
self.show_progress = True
def export_to_file(self, context, out_fn):
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 .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)
- 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)
scene_res = self.export_scene(scene, resources)
- refs = scene_res.collect_references()
progress.set_progress(1.0)
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:
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)
scene_res.write_collection(out_fn, filter=existing)
else:
scene_res.write_to_file(out_fn)
+ for r in scene_res.collect_references():
r.write_to_file(os.path.join(path, r.name))
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")
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:
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
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)
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:
srgb = "_srgb" if colorspace=='sRGB' else ""
tex_res.statements.append(Statement("external_image"+srgb, fn))
else:
if m.material_atlas and m.shader==shader:
materials.append(m)
if m.material_atlas and m.shader==shader:
materials.append(m)
- mat_map = MaterialAtlas(materials)
-
- return mat_map
+ return MaterialAtlas(materials)