Having different options for each resource type was getting unmanageable.
I don't see much value in such fine-grained control either.
filename_ext = ".object"
- textures = bpy.props.EnumProperty(name="Textures", description="Export textures", default="REF",
- items=(("NONE", "None", "Ignore textures"),
- ("REF", "Referenced", "Reference external data"),
- ("INLINE", "Inline", "Embed textures in the object")))
-
- separate_mesh = bpy.props.BoolProperty(name="Separate mesh", description="Write mesh data into a separate file", default=False)
- separate_tech = bpy.props.BoolProperty(name="Separate technique", description="Write technique data into a separate file", default=False)
+ single_file = bpy.props.BoolProperty(name="Single file", description="Write all data into a single file", default=True)
shared_resources = bpy.props.BoolProperty(name="Shared resources", description="Use global names for resource files to enable sharing", default=True)
export_lods = bpy.props.BoolProperty(name="Export LoDs", description="Export all levels of detail", default=True)
+ use_textures = bpy.props.BoolProperty(name="Use textures", description="Use textures in the exported object", default=True)
def create_exporter(self):
from .export_object import ObjectExporter
def draw(self, context):
super().draw(context)
- col = self.general_col
- col.prop(self, "export_lods")
- col.prop(self, "textures")
- col.separator()
-
- self.layout.separator()
+ self.general_col.prop(self, "export_lods")
+ self.general_col.prop(self, "use_textures")
col = self.layout.column()
col.label("Files")
- col.prop(self, "separate_mesh")
- col.prop(self, "separate_tech")
- if self.separate_mesh or self.separate_tech:
+ col.prop(self, "single_file")
+ if not self.single_file:
col.prop(self, "shared_resources")
class ExportMspGLArmature(bpy.types.Operator, ExportMspGLBase):
class MaterialExporter:
def __init__(self):
- self.textures = 'REF'
+ self.single_file = True
+ self.use_textures = True
def create_texture_exporter(self):
from .export_texture import TextureExporter
texture_export = TextureExporter()
- if self.textures=='INLINE':
- texture_export.pixels = 'INLINE'
+ texture_export.inline_data = self.single_file
return texture_export
def export_technique_resources(self, material, resources):
if mat_name not in resources:
resources[mat_name] = self.export_material(material)
- if self.textures!='NONE':
+ if self.use_textures:
for s in material.texture_slots:
if s and s.texture.type=='IMAGE' and s.texture.image:
tex_name = s.texture.name+".tex2d"
mat_res = resources[material.name+".mat"]
textures = {}
- if self.textures!='NONE':
+ if self.use_textures:
image_texture_slots = [s for s in material.texture_slots if s and s.texture.type=='IMAGE' and s.texture.image]
for s in image_texture_slots:
if s.use_map_color_diffuse:
if not obj.inherit_tech:
return []
+ if self.single_file:
+ raise Exception("Can't export inherited technique to a single file")
+
st = Statement("inherit", material.technique)
for s, t in textures.items():
if t.default_filter:
tech_res.statements.append(st)
else:
st = Statement("pass", "")
- st.sub.append(tech_res.create_embed_statement("material", mat_res))
+ if self.single_file:
+ st.sub.append(tech_res.create_embed_statement("material", mat_res))
+ else:
+ st.sub.append(tech_res.create_reference_statement("material", mat_res))
if "diffuse_map" in textures:
diffuse_tex = textures["diffuse_map"]
tex_res = resources[diffuse_tex.name+".tex2d"]
ss = Statement("texunit", 0)
- if self.textures=='INLINE':
+ if self.single_file:
ss.sub.append(tech_res.create_embed_statement("texture2d", tex_res))
elif not diffuse_tex.default_filter:
ss.sub.append(tech_res.create_reference_statement("texture2d", tex_res))
self.show_progress = True
self.use_strips = True
self.use_degen_tris = False
- self.textures = "REF"
- self.separate_mesh = False
- self.separate_tech = False
+ self.use_textures = True
+ self.single_file = True
self.shared_resources = True
self.export_lods = True
def create_material_exporter(self):
from .export_material import MaterialExporter
material_export = MaterialExporter()
- material_export.textures = self.textures
+ material_export.single_file = self.single_file
+ material_export.use_textures = self.use_textures
return material_export
def export_to_file(self, context, out_fn):
if l.data.name!=prev_mesh:
mesh_res = resources[l.data.name+".mesh"]
- if self.separate_mesh:
+ if not self.single_file:
lod_st.append(obj_res.create_reference_statement("mesh", mesh_res))
else:
lod_st.append(obj_res.create_embed_statement("mesh", mesh_res))
if tech_res.name!=prev_tech:
if material and material.technique and not material.inherit_tech:
lod_st.append(Statement("technique", material.technique))
- elif self.separate_tech:
+ elif not self.single_file:
lod_st.append(obj_res.create_reference_statement("technique", tech_res))
else:
lod_st.append(obj_res.create_embed_statement("technique", tech_res))
def export_scene_resources(self, context, objs, resources, progress):
from .export_object import ObjectExporter
object_export = ObjectExporter()
- object_export.separate_mesh = True
- object_export.separate_tech = True
+ object_export.single_file = False
for i, o in enumerate(objs):
progress.push_task_slice(o.name, i, len(objs))
class TextureExporter:
def __init__(self):
- self.pixels = 'REF'
+ self.inline_data = True
def export_texture(self, texture):
from .datafile import Resource, Statement, Token
else:
tex_res.statements.append(Statement("min_filter", Token('NEAREST')))
- if self.pixels=='REF':
+ if not self.inline_data:
from .util import image_name
tex_res.statements.append(Statement("image_data", image_name(texture.image)))
else: