[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34200] trunk/blender/release/scripts/op/ io_anim_bvh/export_bvh.py: patch from Andrea Rugliancich, dont export locations for bones which are connected to their parents.

Campbell Barton ideasman42 at gmail.com
Sun Jan 9 17:46:02 CET 2011


Revision: 34200
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34200
Author:   campbellbarton
Date:     2011-01-09 16:46:01 +0000 (Sun, 09 Jan 2011)
Log Message:
-----------
patch from Andrea Rugliancich, dont export locations for bones which are connected to their parents.
note, we could be smarter about not exporting animation channels which are not needed.

Modified Paths:
--------------
    trunk/blender/release/scripts/op/io_anim_bvh/export_bvh.py

Modified: trunk/blender/release/scripts/op/io_anim_bvh/export_bvh.py
===================================================================
--- trunk/blender/release/scripts/op/io_anim_bvh/export_bvh.py	2011-01-09 15:28:43 UTC (rev 34199)
+++ trunk/blender/release/scripts/op/io_anim_bvh/export_bvh.py	2011-01-09 16:46:01 UTC (rev 34200)
@@ -76,7 +76,10 @@
 
         file.write("%s{\n" % indent_str)
         file.write("%s\tOFFSET %.6f %.6f %.6f\n" % (indent_str, loc.x * global_scale, loc.y * global_scale, loc.z * global_scale))
-        file.write("%s\tCHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation\n" % indent_str)
+        if bone.use_connect and bone.parent:
+            file.write("%s\tCHANNELS 3 Xrotation Yrotation Zrotation\n" % indent_str)
+        else:
+            file.write("%s\tCHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation\n" % indent_str)
 
         if my_children:
             # store the location for the children
@@ -133,6 +136,7 @@
         "rest_arm_imat",  # rest_arm_mat inverted
         "rest_local_imat",  # rest_local_mat inverted
         "prev_euler",  # last used euler to preserve euler compability in between keyframes
+        "connected",  # is the bone connected to the parent bone?
         )
 
         def __init__(self, bone_name):
@@ -153,6 +157,7 @@
 
             self.parent = None
             self.prev_euler = Euler((0.0, 0.0, 0.0))
+            self.connected = (self.rest_bone.use_connect and self.rest_bone.parent)
 
         def update_posedata(self):
             self.pose_mat = self.pose_bone.matrix
@@ -206,7 +211,9 @@
             # keep eulers compatible, no jumping on interpolation.
             rot = mat_final.rotation_part().invert().to_euler('XYZ', dbone.prev_euler)
 
-            file.write("%.6f %.6f %.6f " % (loc * global_scale)[:])
+            if not dbone.connected:
+                file.write("%.6f %.6f %.6f " % (loc * global_scale)[:])
+
             file.write("%.6f %.6f %.6f " % (-degrees(rot[0]), -degrees(rot[1]), -degrees(rot[2])))
 
             dbone.prev_euler = rot




More information about the Bf-blender-cvs mailing list