filepath: bpy.props.StringProperty(name="File path", description="File path for exporting the data", subtype='FILE_PATH')
collection: bpy.props.BoolProperty(name="As a collection", description="Export all data as 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)
+ debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
@classmethod
def poll(cls, context):
return {'RUNNING_MODAL'}
def execute(self, context):
+ from .context import ExportContext
from .export import DataExporter
+
+ ex_ctx = ExportContext(context, verbose=self.debug_mode)
exporter = DataExporter()
- exporter.collection = self.collection
- exporter.shared_resources = self.shared_resources
- exporter.export_to_file(context, self.filepath)
+ ex_ctx.export(exporter.export_to_file, self.filepath,
+ collection=self.collection,
+ shared_resources=self.shared_resources)
return {'FINISHED'}
def draw(self, context):
col.prop(self, "collection")
col.prop(self, "shared_resources")
+ self.layout.separator()
+
+ col = self.layout.column()
+ col.prop(self, "debug_mode")
+
class ExportMspGLAnimation(bpy.types.Operator, ExportHelper):
bl_idname = "export.mspgl_animation"
bl_label = "Export Msp GL animation"
export_all: bpy.props.BoolProperty(name="Export all animations", description="Export all animations present on the selected objects' NLA tracks")
collection: bpy.props.BoolProperty(name="As a collection", description="Export the animations as a single collection file", default=True)
looping_threshold: bpy.props.FloatProperty(name="Looping threshold", description="Tolerance for curve beginning and end values for looping", min=0.0, soft_max=1.0, precision=4, default=0.001)
+ debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
def check(self, context):
ext_changed = self.set_extension(".mdc" if self.export_all and self.collection else ".anim")
return ext_changed or super_result
def execute(self, context):
+ from .context import ExportContext
from .export_animation import AnimationExporter
+
+ ex_ctx = ExportContext(context, verbose=self.debug_mode)
exporter = AnimationExporter()
- exporter.export_all = self.export_all
- exporter.collection = self.collection
- exporter.looping_threshold = self.looping_threshold
- exporter.export_to_file(context, self.filepath)
+ ex_ctx.export(exporter.export_to_file, self.filepath,
+ export_all=self.export_all,
+ collection=self.collection,
+ looping_threshold=looping_threshold)
return {'FINISHED'}
def draw(self, context):
col.prop(self, "collection")
col.prop(self, "looping_threshold")
+ self.layout.separator()
+
+ col = self.layout.column()
+ col.prop(self, "debug_mode")
+
class ExportMspGLScene(bpy.types.Operator, ExportHelper):
bl_idname = "export_scene.mspgl_scene"
bl_label = "Export Msp GL scene"
visible_only: bpy.props.BoolProperty(name="Visible only", description="Only export objects in visible collections", default=True)
collection: bpy.props.BoolProperty(name="As a collection", description="Export the scene and all resources as a single collection file", default=False)
skip_existing: bpy.props.BoolProperty(name="Skip existing files", description="Skip resources that already exist as files", default=True)
+ debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
def invoke(self, context, event):
self.filepath = context.scene.name+".scene"
return ext_changed or super_result
def execute(self, context):
+ from .context import ExportContext
from .export_scene import SceneExporter
+
+ ex_ctx = ExportContext(context, verbose=self.debug_mode)
exporter = SceneExporter()
- exporter.selected_only = self.selected_only
- exporter.visible_only = self.visible_only
- exporter.collection = self.collection
- exporter.skip_existing = self.skip_existing
- exporter.export_to_file(context, self.filepath)
+ ex_ctx.export(exporter.export_to_file, self.filepath,
+ selected_only=self.selected_only,
+ visible_only=self.visible_only,
+ collection=self.collection,
+ skip_existing=self.skip_existing)
return {'FINISHED'}
def draw(self, context):
if self.collection:
col.prop(self, "skip_existing")
+ self.layout.separator()
+
+ col = self.layout.column()
+ col.prop(self, "debug_mode")
+
class ExportMspGLProject(bpy.types.Operator):
bl_idname = "export.mspgl_project"
bl_label = "Export Msp GL project"
bl_description = "Export the entire project in Msp GL format"
directory: bpy.props.StringProperty(name="Directory", description="Directory for exporting the data", subtype='FILE_PATH')
+ debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
def invoke(self, context, event):
blend_filepath = context.blend_data.filepath
return {'RUNNING_MODAL'}
def execute(self, context):
+ from .context import ExportContext
from .export import ProjectExporter
+
+ ex_ctx = ExportContext(context, verbose=self.debug_mode)
exporter = ProjectExporter()
- exporter.export_to_directory(context, self.directory)
+ ex_ctx.export(exporter.export_to_directory, self.directory)
return {'FINISHED'}
+ def draw(self, context):
+ col = self.layout.column()
+ col.prop(self, "debug_mode")
+
+class AddRenderMethod(bpy.types.Operator):
+ bl_idname = "material.add_render_method"
+ bl_label = "Add Render Method"
+ bl_description = "Add a new render method to the material"
+
+ def execute(self, context):
+ mat = context.active_object.active_material
+ mat.render_methods.add()
+ mat.active_render_method_index = len(mat.uniforms)-1
+
+ return {"FINISHED"}
+
+class RemoveRenderMethod(bpy.types.Operator):
+ bl_idname = "material.remove_render_method"
+ bl_label = "Remove Render Method"
+ bl_description = "Remove the selected render method from the material"
+
+ def execute(self, context):
+ mat = context.active_object.active_material
+ mat.render_methods.remove(mat.active_render_method_index)
+ mat.active_render_method_index = min(mat.active_render_method_index, len(mat.render_methods)-1)
+
+ return {"FINISHED"}
+
class AddUniform(bpy.types.Operator):
bl_idname = "material.add_uniform"
bl_label = "Add Uniform"
return {"FINISHED"}
-classes = [ExportMspGLData, ExportMspGLAnimation, ExportMspGLScene, ExportMspGLProject, AddUniform, RemoveUniform]
+classes = [ExportMspGLData, ExportMspGLAnimation, ExportMspGLScene, ExportMspGLProject, AddRenderMethod,
+ RemoveRenderMethod, AddUniform, RemoveUniform]
def register_operators():
for c in classes: