Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def set_location(self):
- armature = bpy.data.objects[self.armature_name]
- armature.select = True
- bpy.context.scene.objects.active = armature
- bpy.ops.object.mode_set(mode='POSE')
- bpy.ops.pose.select_all(action='DESELECT')
- # the transformation I'd like to apply
- x = float(self.poses[step]["location"][0])
- y = float(self.poses[step]["location"][1])
- z = float(self.poses[step]["location"][2])
- pose_bone = armature.pose.bones["location"]
- bone = pose_bone.bone
- bone.select = True
- obj = pose_bone.id_data
- # facing south
- vec = Vector((x, y, z))
- if self.rotation == 0.000:
- vec = Vector((x, y, z))
- # facing south-east
- elif self.rotation == 45.0:
- vec = Vector((-y, x, z))
- # facing east
- elif self.rotation == 90.0:
- vec = Vector((x, -y, z))
- # facing noth-east
- elif self.rotation == 135.0:
- vec = Vector((y, x, z))
- # facing noth
- elif self.rotation == 180.0:
- vec = Vector((x, y, z))
- # facing noth-west
- elif self.rotation == 225.0:
- vec = Vector((-y, x, z))
- # facing west
- elif self.rotation == 270.0:
- vec = Vector((x, -y, z))
- # facing south-west
- elif self.rotation == 315.0:
- vec = Vector((y, x, z))
- matrix_final = obj.matrix_world * pose_bone.matrix
- inv = matrix_final.copy()
- inv.invert()
- vec_rot = vec * inv
- pose_bone.location += vec_rot
Add Comment
Please, Sign In to add comment