]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/__init__.py
Export the entire scene by default
[libs/gl.git] / blender / io_mspgl / __init__.py
index 133b844c2a7d6152f833c58f320f2b54b3c94779..43a3fac8f691270bae32a61bd9447bd2059ad5ef 100644 (file)
@@ -7,7 +7,7 @@ bl_info = {
 
 if "bpy" in locals():
        import imp
-       for sub in "armature", "datafile", "export_armature", "export_material", "export_mesh", "export_object", "export_scene", "export_texture", "mesh", "properties", "util":
+       for sub in "animation", "armature", "datafile", "export_animation", "export_armature", "export_camera", "export_material", "export_mesh", "export_object", "export_scene", "export_texture", "material", "mesh", "properties", "util":
                if sub in locals():
                        imp.reload(locals()[sub])
 
@@ -90,12 +90,49 @@ class ExportMspGLArmature(bpy.types.Operator, ExportMspGLBase):
                from .export_armature import ArmatureExporter
                return ArmatureExporter()
 
+class ExportMspGLAnimation(bpy.types.Operator, ExportMspGLBase):
+       bl_idname = "export.mspgl_animation"
+       bl_label = "Export Msp GL animation"
+
+       filename_ext = ".anim"
+
+       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)
+
+       def check(self, context):
+               result = False
+
+               ext = ".mdc" if self.export_all and self.collection else ".anim"
+               ext_changed = (ext!=self.filename_ext)
+               if ext_changed:
+                       if self.filepath.endswith(self.filename_ext):
+                               self.filepath = self.filepath[:-len(self.filename_ext)]
+                       self.filename_ext = ext
+
+               super_result = super().check(context)
+
+               return ext_changed or super_result
+
+       def create_exporter(self):
+               from .export_animation import AnimationExporter
+               return AnimationExporter()
+
+       def draw(self, context):
+               col = self.layout.column()
+               col.prop(self, "export_all")
+               if self.export_all:
+                       col.prop(self, "collection")
+               col.prop(self, "looping_threshold")
+
 class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase):
        bl_idname = "export_scene.mspgl_scene"
        bl_label = "Export Msp GL scene"
 
        filename_ext = ".scene"
 
+       selected_only = bpy.props.BoolProperty(name="Selected objects only", description="Only export the selected objects")
+       active_layers = bpy.props.BoolProperty(name="Active layers only", description="Only export objects on the active layers", default=True)
        resource_collection = bpy.props.BoolProperty(name="Resource collection", description="Put resources to a single collection file", default=True)
 
        def create_exporter(self):
@@ -104,13 +141,27 @@ class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase):
 
        def draw(self, context):
                col = self.layout.column()
+               col.prop(self, "selected_only")
+               col.prop(self, "active_layers")
                col.prop(self, "resource_collection")
 
+class ExportMspGLCamera(bpy.types.Operator, ExportMspGLBase):
+       bl_idname = "export.mspgl_camera"
+       bl_label = "Export Msp GL camera"
+
+       filename_ext = ".camera"
+
+       def create_exporter(self):
+               from .export_camera import CameraExporter
+               return CameraExporter()
+
 def menu_func_export(self, context):
        self.layout.operator(ExportMspGLMesh.bl_idname, text="Msp GL mesh")
        self.layout.operator(ExportMspGLObject.bl_idname, text="Msp GL object")
        self.layout.operator(ExportMspGLArmature.bl_idname, text="Msp GL armature")
+       self.layout.operator(ExportMspGLAnimation.bl_idname, text="Msp GL animation")
        self.layout.operator(ExportMspGLScene.bl_idname, text="Msp GL scene")
+       self.layout.operator(ExportMspGLCamera.bl_idname, text="Msp GL camera")
 
 from .properties import MspGLMeshProperties, MspGLObjectProperties