[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1217] trunk/py/scripts/addons/ io_export_directx_x.py: Fixed some formatting errors that could possibly be screwing with XNA importers .

Chris Foster cdbfoster at gmail.com
Thu Dec 2 23:07:35 CET 2010


Revision: 1217
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1217
Author:   kiravakaan
Date:     2010-12-02 23:07:35 +0100 (Thu, 02 Dec 2010)

Log Message:
-----------
Fixed some formatting errors that could possibly be screwing with XNA importers.  Also fixed keyframe animation to only export frames within the timeline's start and end frames.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_export_directx_x.py

Modified: trunk/py/scripts/addons/io_export_directx_x.py
===================================================================
--- trunk/py/scripts/addons/io_export_directx_x.py	2010-12-02 07:20:07 UTC (rev 1216)
+++ trunk/py/scripts/addons/io_export_directx_x.py	2010-12-02 22:07:35 UTC (rev 1217)
@@ -18,9 +18,9 @@
 bl_addon_info = {
     "name": "Export DirectX Model Format (.x)",
     "author": "Chris Foster (Kira Vakaan)",
-    "version": (1,9),
+    "version": (2,0),
     "blender": (2, 5, 3),
-    "api": 32681,
+    "api": 33427,
     "location": "File > Export",
     "description": "Export to the DirectX Model Format (.x)",
     "warning": "",
@@ -668,8 +668,13 @@
                     if FCurve:
                         Keyframes = []
                         for Keyframe in FCurve.keyframe_points:
-                            Keyframes.append(Keyframe.co)
-                            AllKeyframes.add(int(Keyframe.co[0]))
+                            if Keyframe.co[0] < bpy.context.scene.frame_start:
+                                AllKeyframes.add(bpy.context.scene.frame_start)
+                            elif Keyframe.co[0] > bpy.context.scene.frame_end:
+                                AllKeyframes.add(bpy.context.scene.frame_end)
+                            else:
+                                Keyframes.append(Keyframe.co)
+                                AllKeyframes.add(int(Keyframe.co[0]))
                         PositionFCurves[Index] = {int(Keyframe): Value for Keyframe, Value in Keyframes}
                 Config.File.write("{}AnimationKey {{ //Position\n".format("  " * Config.Whitespace))
                 Config.Whitespace += 1
@@ -683,12 +688,17 @@
                         Position[0] = ((PositionFCurves[0][Keyframe] if Keyframe in PositionFCurves[0] else Object.location[0]) if PositionFCurves[0] else Object.location[0])
                         Position[1] = ((PositionFCurves[1][Keyframe] if Keyframe in PositionFCurves[1] else Object.location[1]) if PositionFCurves[1] else Object.location[1])
                         Position[2] = ((PositionFCurves[2][Keyframe] if Keyframe in PositionFCurves[2] else Object.location[2]) if PositionFCurves[2] else Object.location[2])
-                        Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format("  " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Position[0], Position[1], Position[2]))
+                        Config.File.write("{}{}{:9f},{:9f},{:9f};;".format("  " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Position[0], Position[1], Position[2]))
+                        if Keyframe == AllKeyframes[-1]:
+                            Config.File.write(";\n")
+                        else:
+                            Config.File.write(",\n")
+                        
                 else:
                     Config.File.write("{}2;\n{}1;\n".format("  " * Config.Whitespace, "  " * Config.Whitespace))
                     bpy.context.scene.frame_set(bpy.context.scene.frame_start)
                     Position = Object.matrix_local.translation_part()
-                    Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format("  " * Config.Whitespace, ("0;3;").ljust(8), Position[0], Position[1], Position[2]))
+                    Config.File.write("{}{}{:9f},{:9f},{:9f};;;\n".format("  " * Config.Whitespace, ("0;3;").ljust(8), Position[0], Position[1], Position[2]))
                 Config.Whitespace -= 1
                 Config.File.write("{}}}\n".format("  " * Config.Whitespace))
                 if Config.Verbose:
@@ -702,8 +712,13 @@
                     if FCurve:
                         Keyframes = []
                         for Keyframe in FCurve.keyframe_points:
-                            Keyframes.append(Keyframe.co)
-                            AllKeyframes.add(int(Keyframe.co[0]))
+                            if Keyframe.co[0] < bpy.context.scene.frame_start:
+                                AllKeyframes.add(bpy.context.scene.frame_start)
+                            elif Keyframe.co[0] > bpy.context.scene.frame_end:
+                                AllKeyframes.add(bpy.context.scene.frame_end)
+                            else:
+                                Keyframes.append(Keyframe.co)
+                                AllKeyframes.add(int(Keyframe.co[0]))
                         RotationFCurves[Index] = {int(Keyframe): Value for Keyframe, Value in Keyframes}
                 Config.File.write("{}AnimationKey {{ //Rotation\n".format("  " * Config.Whitespace))
                 Config.Whitespace += 1
@@ -718,12 +733,16 @@
                         Rotation[1] = ((RotationFCurves[1][Keyframe] if Keyframe in RotationFCurves[1] else Object.rotation_euler[1]) if RotationFCurves[1] else Object.rotation_euler[1])
                         Rotation[2] = ((RotationFCurves[2][Keyframe] if Keyframe in RotationFCurves[2] else Object.rotation_euler[2]) if RotationFCurves[2] else Object.rotation_euler[2])
                         Rotation = Rotation.to_quat()
-                        Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;\n".format("  " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";4;").ljust(8), - Rotation[0], Rotation[1], Rotation[2], Rotation[3]))
+                        Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;".format("  " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";4;").ljust(8), - Rotation[0], Rotation[1], Rotation[2], Rotation[3]))
+                        if Keyframe == AllKeyframes[-1]:
+                            Config.File.write(";\n")
+                        else:
+                            Config.File.write(",\n")
                 else:
                     Config.File.write("{}0;\n{}1;\n".format("  " * Config.Whitespace, "  " * Config.Whitespace))
                     bpy.context.scene.frame_set(bpy.context.scene.frame_start)
                     Rotation = Object.rotation_euler.to_quat()
-                    Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;\n".format("  " * Config.Whitespace, ("0;4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3]))
+                    Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;;\n".format("  " * Config.Whitespace, ("0;4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3]))
                 Config.Whitespace -= 1
                 Config.File.write("{}}}\n".format("  " * Config.Whitespace))
                 if Config.Verbose:
@@ -737,8 +756,13 @@
                     if FCurve:
                         Keyframes = []
                         for Keyframe in FCurve.keyframe_points:
-                            Keyframes.append(Keyframe.co)
-                            AllKeyframes.add(int(Keyframe.co[0]))
+                            if Keyframe.co[0] < bpy.context.scene.frame_start:
+                                AllKeyframes.add(bpy.context.scene.frame_start)
+                            elif Keyframe.co[0] > bpy.context.scene.frame_end:
+                                AllKeyframes.add(bpy.context.scene.frame_end)
+                            else:
+                                Keyframes.append(Keyframe.co)
+                                AllKeyframes.add(int(Keyframe.co[0]))
                         ScaleFCurves[Index] = {int(Keyframe): Value for Keyframe, Value in Keyframes}
                 Config.File.write("{}AnimationKey {{ //Scale\n".format("  " * Config.Whitespace))
                 Config.Whitespace += 1
@@ -752,12 +776,16 @@
                         Scale[0] = ((ScaleFCurves[0][Keyframe] if Keyframe in ScaleFCurves[0] else Object.scale[0]) if ScaleFCurves[0] else Object.scale[0])
                         Scale[1] = ((ScaleFCurves[1][Keyframe] if Keyframe in ScaleFCurves[1] else Object.scale[1]) if ScaleFCurves[1] else Object.scale[1])
                         Scale[2] = ((ScaleFCurves[2][Keyframe] if Keyframe in ScaleFCurves[2] else Object.scale[2]) if ScaleFCurves[2] else Object.scale[2])
-                        Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format("  " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2]))
+                        Config.File.write("{}{}{:9f},{:9f},{:9f};;".format("  " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2]))
+                        if Keyframe == AllKeyframes[-1]:
+                            Config.File.write(";\n")
+                        else:
+                            Config.File.write(",\n")
                 else:
                     Config.File.write("{}1;\n{}1;\n".format("  " * Config.Whitespace, "  " * Config.Whitespace))
                     bpy.context.scene.frame_set(bpy.context.scene.frame_start)
                     Scale = Object.matrix_local.scale_part()
-                    Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format("  " * Config.Whitespace, ("0;3;").ljust(8), Scale[0], Scale[1], Scale[2]))
+                    Config.File.write("{}{}{:9f},{:9f},{:9f};;;\n".format("  " * Config.Whitespace, ("0;3;").ljust(8), Scale[0], Scale[1], Scale[2]))
                 Config.Whitespace -= 1
                 Config.File.write("{}}}\n".format("  " * Config.Whitespace))
                 if Config.Verbose:
@@ -803,8 +831,13 @@
                         if FCurve:
                             Keyframes = []
                             for Keyframe in FCurve.keyframe_points:
-                                Keyframes.append(Keyframe.co)
-                                AllKeyframes.add(int(Keyframe.co[0]))
+                                if Keyframe.co[0] < bpy.context.scene.frame_start:
+                                    AllKeyframes.add(bpy.context.scene.frame_start)
+                                elif Keyframe.co[0] > bpy.context.scene.frame_end:
+                                    AllKeyframes.add(bpy.context.scene.frame_end)
+                                else:
+                                    Keyframes.append(Keyframe.co)
+                                    AllKeyframes.add(int(Keyframe.co[0]))
                             PositionFCurves[Index] = {int(Keyframe): Value for Keyframe, Value in Keyframes}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list