Skip to content
Snippets Groups Projects
io_export_directx_x.py 50.7 KiB
Newer Older
  • Learn to ignore specific revisions
  •     ExportTextures = BoolProperty(name="Export Textures", description="Reference external image files to be used by the model", default=True)
    
        ExportArmatures = BoolProperty(name="Export Armatures", description="Export the bones of any armatures to deform meshes.", default=False)
    
        ExportAnimation = EnumProperty(name="Animations", description="Select the type of animations to export.  Only object and armature bone animations can be exported.", items=AnimationModes, default="0")
    
    
        ExportMode = EnumProperty(name="Export", description="Select which objects to export.  Only Mesh, Empty, and Armature objects will be exported.", items=ExportModes, default="1")
    
        Verbose = BoolProperty(name="Verbose", description="Run the exporter in debug mode.  Check the console for output.", default=False)
    
        def execute(self, context):
    
            #Append .x if needed
    
            FilePath = self.properties.filepath
    
            if not FilePath.lower().endswith(".x"):
    
                FilePath += ".x"
    
            Config = DirectXExporterSettings(context,
                                             FilePath,
                                             CoordinateSystem=self.properties.CoordinateSystem,
                                             RotateX=self.properties.RotateX,
                                             FlipNormals=self.properties.FlipNormals,
                                             ApplyModifiers=self.properties.ApplyModifiers,
                                             IncludeFrameRate=self.properties.IncludeFrameRate,
                                             ExportTextures=self.properties.ExportTextures,
                                             ExportArmatures=self.properties.ExportArmatures,
                                             ExportAnimation=self.properties.ExportAnimation,
                                             ExportMode=self.properties.ExportMode,
                                             Verbose=self.properties.Verbose)
    
            ExportDirectX(Config)
            return {"FINISHED"}
    
    
        def invoke(self, context, event):
            WindowManager = context.manager
    
            WindowManager.add_fileselect(self)
            return {"RUNNING_MODAL"}
    
    
    
    def menu_func(self, context):
    
        DefaultPath = os.path.splitext(bpy.data.filepath)[0] + ".x"
    
        self.layout.operator(DirectXExporter.bl_idname, text="DirectX (.x)").filepath = DefaultPath
    
    
    
    def register():
        bpy.types.register(DirectXExporter)
        bpy.types.INFO_MT_file_export.append(menu_func)
    
    
    def unregister():
        bpy.types.unregister(DirectXExporter)
        bpy.types.INFO_MT_file_export.remove(menu_func)
    
    
    
    if __name__ == "__main__":