[Bf-extensions-cvs] [ec2d0c1a] master: io_scene_x: moved to contrib: T63750

meta-androcto noreply at git.blender.org
Fri May 24 03:18:45 CEST 2019


Commit: ec2d0c1a6dac5aaa1568d8677268b74691423b5b
Author: meta-androcto
Date:   Fri May 24 11:18:19 2019 +1000
Branches: master
https://developer.blender.org/rBACec2d0c1a6dac5aaa1568d8677268b74691423b5b

io_scene_x: moved to contrib: T63750

===================================================================

A	io_scene_x/__init__.py
A	io_scene_x/export_x.py

===================================================================

diff --git a/io_scene_x/__init__.py b/io_scene_x/__init__.py
new file mode 100644
index 00000000..c8e2bc73
--- /dev/null
+++ b/io_scene_x/__init__.py
@@ -0,0 +1,189 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation, either version 3
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#  All rights reserved.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+bl_info = {
+    "name": "DirectX X Format",
+    "author": "Chris Foster",
+    "version": (3, 1, 0),
+    "blender": (2, 69, 0),
+    "location": "File > Export > DirectX (.x)",
+    "description": "Export mesh vertices, UV's, materials, textures, "
+                   "vertex colors, armatures, empties, and actions.",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+                "Scripts/Import-Export/DirectX_Exporter",
+    "category": "Import-Export"}
+
+
+import bpy
+from bpy.props import BoolProperty
+from bpy.props import EnumProperty
+from bpy.props import StringProperty
+
+
+class ExportDirectX(bpy.types.Operator):
+    """Export selection to DirectX"""
+
+    bl_idname = "export_scene.x"
+    bl_label = "Export DirectX"
+
+    filepath: StringProperty(subtype='FILE_PATH')
+
+    # Export options
+
+    SelectedOnly: BoolProperty(
+        name="Export Selected Objects Only",
+        description="Export only selected objects",
+        default=True)
+
+    CoordinateSystem: EnumProperty(
+        name="Coordinate System",
+        description="Use the selected coordinate system for export",
+        items=(('LEFT_HANDED', "Left-Handed", "Use a Y up, Z forward system or a Z up, -Y forward system"),
+               ('RIGHT_HANDED', "Right-Handed", "Use a Y up, -Z forward system or a Z up, Y forward system")),
+        default='LEFT_HANDED')
+
+    UpAxis: EnumProperty(
+        name="Up Axis",
+        description="The selected axis points upward",
+        items=(('Y', "Y", "The Y axis points up"),
+               ('Z', "Z", "The Z axis points up")),
+        default='Y')
+
+    ExportMeshes: BoolProperty(
+        name="Export Meshes",
+        description="Export mesh objects",
+        default=True)
+
+    ExportNormals: BoolProperty(
+        name="    Export Normals",
+        description="Export mesh normals",
+        default=True)
+
+    FlipNormals: BoolProperty(
+        name="        Flip Normals",
+        description="Flip mesh normals before export",
+        default=False)
+
+    ExportUVCoordinates: BoolProperty(
+        name="    Export UV Coordinates",
+        description="Export mesh UV coordinates, if any",
+        default=True)
+
+    ExportMaterials: BoolProperty(
+        name="    Export Materials",
+        description="Export material properties and reference image textures",
+        default=True)
+
+    ExportActiveImageMaterials: BoolProperty(
+        name="        Reference Active Images as Textures",
+        description="Reference the active image of each face as a texture, "\
+            "as opposed to the image assigned to the material",
+        default=False)
+
+    ExportVertexColors: BoolProperty(
+        name="    Export Vertex Colors",
+        description="Export mesh vertex colors, if any",
+        default=False)
+
+    ExportSkinWeights: BoolProperty(
+        name="    Export Skin Weights",
+        description="Bind mesh vertices to armature bones",
+        default=False)
+
+    ApplyModifiers: BoolProperty(
+        name="    Apply Modifiers",
+        description="Apply the effects of object modifiers before export",
+        default=False)
+
+    ExportArmatureBones: BoolProperty(
+        name="Export Armature Bones",
+        description="Export armatures bones",
+        default=False)
+
+    ExportRestBone: BoolProperty(
+        name="    Export Rest Position",
+        description="Export bones in their rest position (recommended for "\
+            "animation)",
+        default=False)
+
+    ExportAnimation: BoolProperty(
+        name="Export Animations",
+        description="Export object and bone animations.  Data is exported for "\
+            "every frame",
+        default=False)
+
+    IncludeFrameRate: BoolProperty(
+        name="    Include Frame Rate",
+        description="Include the AnimTicksPerSecond template which is "\
+            "used by some engines to control animation speed",
+        default=False)
+
+    ExportActionsAsSets: BoolProperty(
+        name="    Export Actions as AnimationSets",
+        description="Export each action of each object as a separate "\
+            "AnimationSet. Otherwise all current actions are lumped "\
+            "together into a single set",
+        default=False)
+
+    AttachToFirstArmature: BoolProperty(
+        name="        Attach Unused Actions to First Armature",
+        description="Export each unused action as if used by the first "\
+            "armature object",
+        default=False)
+
+    Verbose: BoolProperty(
+        name="Verbose",
+        description="Run the exporter in debug mode. Check the console for "\
+            "output",
+        default=False)
+
+    def execute(self, context):
+        self.filepath = bpy.path.ensure_ext(self.filepath, ".x")
+
+        from . import export_x
+        Exporter = export_x.DirectXExporter(self, context)
+        Exporter.Export()
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        if not self.filepath:
+            self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".x")
+        context.window_manager.fileselect_add(self)
+        return {'RUNNING_MODAL'}
+
+
+def menu_func(self, context):
+    self.layout.operator(ExportDirectX.bl_idname, text="DirectX (.x)")
+
+
+def register():
+    bpy.utils.register_module(__name__)
+
+    bpy.types.TOPBAR_MT_file_export.append(menu_func)
+
+
+def unregister():
+    bpy.utils.unregister_module(__name__)
+
+    bpy.types.TOPBAR_MT_file_export.remove(menu_func)
+
+
+if __name__ == "__main__":
+    register()
diff --git a/io_scene_x/export_x.py b/io_scene_x/export_x.py
new file mode 100644
index 00000000..e0fc817b
--- /dev/null
+++ b/io_scene_x/export_x.py
@@ -0,0 +1,1395 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation, either version 3
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#  All rights reserved.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+from math import radians, pi
+
+import bpy
+from mathutils import *
+
+
+class DirectXExporter:
+    def __init__(self, Config, context):
+        self.Config = Config
+        self.context = context
+
+        self.Log("Begin verbose logging ----------\n")
+
+        self.File = File(self.Config.filepath)
+
+        self.Log("Setting up coordinate system...")
+
+        # SystemMatrix converts from right-handed, z-up to the target coordinate system
+        self.SystemMatrix = Matrix()
+
+        if self.Config.CoordinateSystem == 'LEFT_HANDED':
+            self.SystemMatrix *= Matrix.Scale(-1, 4, Vector((0, 0, 1)))
+
+        if self.Config.UpAxis == 'Y':
+            self.SystemMatrix *= Matrix.Rotation(radians(-90), 4, 'X')
+
+        self.Log("Done")
+
+        self.Log("Generating object lists for export...")
+        if self.Config.SelectedOnly:
+            ExportList = list(self.context.selected_objects)
+        else:
+            ExportList = list(self.context.scene.objects)
+
+        # ExportMap maps Blender objects to ExportObjects
+        ExportMap = {}
+        for Object in ExportList:
+            if Object.type == 'EMPTY':
+                ExportMap[Object] = EmptyExportObject(self.Config, self, Object)
+            elif Object.type == 'MESH':
+                ExportMap[Object] = MeshExportObject(self.Config, self,
+                    Object)
+            elif Object.type == 'ARMATURE':
+                ExportMap[Object] = ArmatureExportObject(self.Config, self,
+                    Object)
+
+        # Find the objects who do not have a parent or whose parent we are
+        # not exporting
+        self.RootExportList = [Object for Object in ExportMap.values()
+            if Object.BlenderObject.parent not in ExportList]
+        self.RootExportList = Util.SortByNameField(self.RootExportList)
+
+        self.ExportList = Util.SortByNameField(ExportMap.values())
+
+        # Determine each object's children from the pool of ExportObjects
+        for Object in ExportMap.values():
+            Children = Object.BlenderObject.children
+            Object.Children = []
+            for Child in Children:
+                if Child in ExportMap:
+                    Object.Children.append(ExportMap[Child])
+        self.Log("Done")
+
+        self.AnimationWriter = None
+        if self.Config.ExportAnimation:
+            self.Log("Gathering animation data...")
+
+            # Collect all animated object data
+            AnimationGenerators = self.__GatherAnimationGenerators()
+
+            # Split the data up into animation sets based on user options
+            if self.Config.ExportActionsAsSets:
+                self.AnimationWriter = SplitSetAni

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list