[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3617] trunk/py/scripts/addons/ io_anim_c3d/__init__.py: added option to convert from Y-up coordinates

Daniel M. Basso danielmbasso at gmail.com
Wed Jul 11 15:59:23 CEST 2012


Revision: 3617
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3617
Author:   dmbasso
Date:     2012-07-11 13:59:22 +0000 (Wed, 11 Jul 2012)
Log Message:
-----------
added option to convert from Y-up coordinates

Modified Paths:
--------------
    trunk/py/scripts/addons/io_anim_c3d/__init__.py

Modified: trunk/py/scripts/addons/io_anim_c3d/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_anim_c3d/__init__.py	2012-07-11 00:11:45 UTC (rev 3616)
+++ trunk/py/scripts/addons/io_anim_c3d/__init__.py	2012-07-11 13:59:22 UTC (rev 3617)
@@ -25,7 +25,7 @@
 bl_info = {
     'name': "C3D Graphics Lab Motion Capture file (.c3d)",
     'author': "Daniel Monteiro Basso <daniel at basso.inf.br>",
-    'version': (2012, 7, 10, 1),
+    'version': (2012, 7, 11, 1),
     'blender': (2, 6, 3),
     'location': "File > Import",
     'description': "Imports C3D Graphics Lab Motion Capture files",
@@ -62,6 +62,7 @@
     fskip = 0
     scale = 0
     timer = None
+    Y_up = False
 
     def modal(self, context, event):
         if event.type == 'ESC':
@@ -78,7 +79,8 @@
                 name = self.unames[self.prefix + ml]
                 o = bpy.context.scene.objects[name]
                 m = self.markerset.getMarker(ml, self.curframe)
-                o.location = Vector(m.position) * self.scale
+                p = Vector(m.position) * self.scale
+                o.location = Vector((p[0], -p[2], p[1])) if self.Y_up else p
                 if m.confidence >= self.confidence:
                     o.keyframe_insert('location', frame=fno)
             self.curframe += self.fskip
@@ -106,6 +108,11 @@
     filepath = StringProperty(
             subtype='FILE_PATH',
             )
+    Y_up = BoolProperty(
+            name="Up vector is Y axis",
+            default=False,
+            description="Convert to Blender coordinates",
+            )
     from_inches = BoolProperty(
             name="Convert from inches to metric",
             default=False,
@@ -176,6 +183,7 @@
             (only works for standing poses)
         """
         zmin = None
+        hidx = 1 if self.properties.Y_up else 2
         for ml in ms.markerLabels:
             if 'LTOE' in ml:
                 hd = ml.replace('LTOE', 'LFHD')
@@ -183,10 +191,10 @@
                     break
                 pmin_idx = ms.markerLabels.index(ml)
                 pmax_idx = ms.markerLabels.index(hd)
-                zmin = ms.frames[0][pmin_idx].position[2]
-                zmax = ms.frames[0][pmax_idx].position[2]
+                zmin = ms.frames[0][pmin_idx].position[hidx]
+                zmax = ms.frames[0][pmax_idx].position[hidx]
         if zmin is None:  # could not find named markers, get extremes
-            allz = [m.position[2] for m in ms.frames[0]]
+            allz = [m.position[hidx] for m in ms.frames[0]]
             zmin, zmax = min(allz), max(allz)
         return abs(zmax - zmin)
 
@@ -243,6 +251,7 @@
         C3DAnimateCloud.markerset = ms
         C3DAnimateCloud.unames = unames
         C3DAnimateCloud.scale = scale
+        C3DAnimateCloud.Y_up = self.properties.Y_up
         C3DAnimateCloud.fskip = self.properties.frame_skip
         C3DAnimateCloud.prefix = self.properties.prefix
         C3DAnimateCloud.use_frame_no = self.properties.use_frame_no



More information about the Bf-extensions-cvs mailing list