From 1328d1c884565e20f72ea51033902412eeea3a91 Mon Sep 17 00:00:00 2001 From: "Daniel M. Basso" Date: Wed, 11 Jul 2012 13:59:22 +0000 Subject: added option to convert from Y-up coordinates --- io_anim_c3d/__init__.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'io_anim_c3d') diff --git a/io_anim_c3d/__init__.py b/io_anim_c3d/__init__.py index 605ebf63..ffd3658c 100644 --- a/io_anim_c3d/__init__.py +++ b/io_anim_c3d/__init__.py @@ -25,7 +25,7 @@ bl_info = { 'name': "C3D Graphics Lab Motion Capture file (.c3d)", 'author': "Daniel Monteiro Basso ", - '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 @@ class C3DAnimateCloud(bpy.types.Operator): fskip = 0 scale = 0 timer = None + Y_up = False def modal(self, context, event): if event.type == 'ESC': @@ -78,7 +79,8 @@ class C3DAnimateCloud(bpy.types.Operator): 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 @@ class C3DImporter(bpy.types.Operator): 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 @@ class C3DImporter(bpy.types.Operator): (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 @@ class C3DImporter(bpy.types.Operator): 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 @@ class C3DImporter(bpy.types.Operator): 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 -- cgit v1.2.3