filename_ext = ".object"
- single_file = bpy.props.BoolProperty(name="Single file", description="Write all data into a single file", default=True)
+ collection = bpy.props.BoolProperty(name="As a collection", description="Write all data into a single collection file", default=False)
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 check(self, context):
+ ext_changed = self.set_extension(".mdc" if self.collection else ".object")
+ super_result = super().check(context)
+ return ext_changed or super_result
+
def create_exporter(self):
from .export_object import ObjectExporter
return ObjectExporter()
col = self.layout.column()
col.label(text="Files")
- col.prop(self, "single_file")
- if not self.single_file:
- col.prop(self, "shared_resources")
+ col.prop(self, "collection")
+ col.prop(self, "shared_resources")
class ExportMspGLArmature(bpy.types.Operator, ExportMspGLBase):
bl_idname = "export.mspgl_armature"
import os
-def create_technique_resource(material, resources, single_file):
+def create_technique_resource(material, resources):
from .datafile import Resource, Statement
tech_res = Resource(material.name+".tech", "technique")
mat_res = resources[material.name+".mat"]
st = Statement("pass", "")
- if 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))
+ st.sub.append(tech_res.create_embed_statement("material", mat_res))
if material.render_mode=='CUSTOM':
st.sub.append(Statement("shader", material.shader))
class MaterialExporter:
def __init__(self):
- self.single_file = True
self.use_textures = True
+ self.inline_texture_data = False
def create_texture_exporter(self):
from .export_texture import TextureExporter
texture_export = TextureExporter()
- texture_export.inline_data = self.single_file
+ texture_export.inline_data = self.inline_texture_data
return texture_export
def export_technique_resources(self, material, resources):
resources[mat_name] = self.export_material(material, resources=resources)
def export_technique(self, material, *, resources):
- return create_technique_resource(material, resources, self.single_file)
+ return create_technique_resource(material, resources)
def export_material(self, material, *, resources):
from .datafile import Resource, Statement
if self.use_textures and prop.texture:
tex_res = resources[prop.texture.image.name+".tex2d"]
fn = os.path.basename(prop.texture.image.filepath)
- if self.single_file:
- raise Exception("Can't export textures to a single file")
- elif prop.texture.default_filter and fn:
+ if prop.texture.default_filter and fn:
return Statement(keyword+"_map", fn)
else:
return mat_res.create_reference_statement(keyword+"_map", tex_res)
class MaterialMapExporter:
def __init__(self):
- self.single_file = True
+ pass
def export_technique_resources(self, material_map, resources):
from .datafile import Resource, Statement, Token
resources[mat_name] = mat_res
def export_technique(self, material_map, *, resources):
- return create_technique_resource(material_map, resources, self.single_file)
+ return create_technique_resource(material_map, resources)
self.use_strips = True
self.use_degen_tris = False
self.use_textures = True
- self.single_file = True
+ self.collection = False
self.shared_resources = True
self.export_lods = True
def create_material_exporter(self):
from .export_material import MaterialExporter
material_export = MaterialExporter()
- material_export.single_file = self.single_file
material_export.use_textures = self.use_textures
return material_export
def create_material_map_exporter(self):
from .export_material import MaterialMapExporter
material_map_export = MaterialMapExporter()
- material_map_export.single_file = self.single_file
return material_map_export
def export_to_file(self, context, out_fn):
r.name = base+ext
numbers[ext] = n+1
- for r in refs:
- r.write_to_file(os.path.join(path, r.name))
- obj_res.write_to_file(out_fn)
+ if self.collection:
+ obj_res.write_collection(out_fn)
+ else:
+ for r in refs:
+ r.write_to_file(os.path.join(path, r.name))
+ obj_res.write_to_file(out_fn)
def export_object_resources(self, context, obj, resources, progress, material_maps=None):
if material_maps is None:
if l.data.name!=prev_mesh:
mesh_res = resources[l.data.name+".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))
+ lod_st.append(obj_res.create_reference_statement("mesh", mesh_res))
prev_mesh = l.data.name
if tech_res.name!=prev_tech:
if material and material.render_mode=='EXTERNAL':
lod_st.append(Statement("technique", material.technique))
- 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))
+ lod_st.append(obj_res.create_reference_statement("technique", tech_res))
prev_tech = tech_res.name
if i>0: