diff options
author | Chris Foster <cdbfoster@gmail.com> | 2013-12-09 22:32:06 +0400 |
---|---|---|
committer | Chris Foster <cdbfoster@gmail.com> | 2013-12-09 22:32:06 +0400 |
commit | 74ff9632637c44fddd06863968b38e12f18b1860 (patch) | |
tree | 5e7cd52096278e8b0ae32d1890dbb6308f6cb5eb /io_scene_x | |
parent | 689bb9c2146ae75ccce0dae6914681104e3c5f7a (diff) |
Re-added the Coordinate System and Up Axis options. Apparently XNA uses a right handed system and the option was useful for some users. Oops!
Diffstat (limited to 'io_scene_x')
-rw-r--r-- | io_scene_x/__init__.py | 14 | ||||
-rw-r--r-- | io_scene_x/export_x.py | 18 |
2 files changed, 25 insertions, 7 deletions
diff --git a/io_scene_x/__init__.py b/io_scene_x/__init__.py index 519ca16c..394954e6 100644 --- a/io_scene_x/__init__.py +++ b/io_scene_x/__init__.py @@ -53,6 +53,20 @@ class ExportDirectX(bpy.types.Operator): 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", diff --git a/io_scene_x/export_x.py b/io_scene_x/export_x.py index f8ccdef2..dcaf2206 100644 --- a/io_scene_x/export_x.py +++ b/io_scene_x/export_x.py @@ -34,9 +34,16 @@ class DirectXExporter: self.File = File(self.Config.filepath) self.Log("Setting up coordinate system...") - # SystemMatrix converts from right-handed, z-up to left-handed, y-up - self.SystemMatrix = (Matrix.Scale(-1, 4, Vector((0, 0, 1))) * - Matrix.Rotation(radians(-90), 4, 'X')) + + # 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...") @@ -469,8 +476,6 @@ class MeshExportObject(ExportObject): self.Exporter.File.Write("{};".format(len(PolygonVertexIndexes))) - PolygonVertexIndexes = PolygonVertexIndexes[::-1] - for VertexCountIndex, VertexIndex in \ enumerate(PolygonVertexIndexes): @@ -574,8 +579,7 @@ class MeshExportObject(ExportObject): for Index, Polygon in enumerate(MeshEnumerator.PolygonVertexIndexes): self.Exporter.File.Write("{};".format(len(Polygon))) - # Reverse the winding order - for VertexCountIndex, VertexIndex in enumerate(Polygon[::-1]): + for VertexCountIndex, VertexIndex in enumerate(Polygon): if VertexCountIndex == len(Polygon) - 1: self.Exporter.File.Write("{};".format(VertexIndex), Indent=False) |