[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1366] contrib/py/scripts/addons/ io_import_fbx.py: == FBX Importer ==

Mitchell Stokes mogurijin at gmail.com
Sat Jan 8 11:32:09 CET 2011


Revision: 1366
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1366
Author:   moguri
Date:     2011-01-08 10:32:09 +0000 (Sat, 08 Jan 2011)
Log Message:
-----------
== FBX Importer ==
  * Objects/Meshes now have the proper rotation (rad conversion + 90deg X rotation)

Modified Paths:
--------------
    contrib/py/scripts/addons/io_import_fbx.py

Modified: contrib/py/scripts/addons/io_import_fbx.py
===================================================================
--- contrib/py/scripts/addons/io_import_fbx.py	2011-01-08 08:09:59 UTC (rev 1365)
+++ contrib/py/scripts/addons/io_import_fbx.py	2011-01-08 10:32:09 UTC (rev 1366)
@@ -177,7 +177,10 @@
 
 def import_fbx(path):
     import math
+    import mathutils
     
+    mtx_x90 = mathutils.Matrix.Rotation( math.pi/2.0, 3, 'X')
+    
     fbx_data = []
     objects = {}
     parse_fbx(path, fbx_data)
@@ -271,14 +274,17 @@
                     
                         # apply transformation
                         props = tag_get_single(value2, "Properties60")[1]
-                        
-                        # Note, rotations is not correct!
+
                         loc = tag_get_prop(props, "Lcl Translation")
                         rot = tag_get_prop(props, "Lcl Rotation")
                         sca = tag_get_prop(props, "Lcl Scaling")
+                        
+                        # Convert rotation
+                        rot_mat = mathutils.Euler([math.radians(i) for i in rot]).to_matrix()
+                        rot_mat *= mtx_x90
 
                         obj.location = loc
-                        obj.rotation_euler = [math.radians(i) for i in rot]
+                        obj.rotation_euler = rot_mat.to_euler()[:]
                         obj.scale = sca
                         
                         # Take care of parenting (we assume the parent has already been processed)



More information about the Bf-extensions-cvs mailing list