Guest User

Untitled

a guest
Apr 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. def set_location(self):
  2. armature = bpy.data.objects[self.armature_name]
  3. armature.select = True
  4. bpy.context.scene.objects.active = armature
  5. bpy.ops.object.mode_set(mode='POSE')
  6. bpy.ops.pose.select_all(action='DESELECT')
  7.  
  8. # the transformation I'd like to apply
  9. x = float(self.poses[step]["location"][0])
  10. y = float(self.poses[step]["location"][1])
  11. z = float(self.poses[step]["location"][2])
  12.  
  13. pose_bone = armature.pose.bones["location"]
  14. bone = pose_bone.bone
  15. bone.select = True
  16. obj = pose_bone.id_data
  17.  
  18. # facing south
  19. vec = Vector((x, y, z))
  20. if self.rotation == 0.000:
  21. vec = Vector((x, y, z))
  22. # facing south-east
  23. elif self.rotation == 45.0:
  24. vec = Vector((-y, x, z))
  25. # facing east
  26. elif self.rotation == 90.0:
  27. vec = Vector((x, -y, z))
  28. # facing noth-east
  29. elif self.rotation == 135.0:
  30. vec = Vector((y, x, z))
  31. # facing noth
  32. elif self.rotation == 180.0:
  33. vec = Vector((x, y, z))
  34. # facing noth-west
  35. elif self.rotation == 225.0:
  36. vec = Vector((-y, x, z))
  37. # facing west
  38. elif self.rotation == 270.0:
  39. vec = Vector((x, -y, z))
  40. # facing south-west
  41. elif self.rotation == 315.0:
  42. vec = Vector((y, x, z))
  43.  
  44.  
  45. matrix_final = obj.matrix_world * pose_bone.matrix
  46. inv = matrix_final.copy()
  47. inv.invert()
  48. vec_rot = vec * inv
  49. pose_bone.location += vec_rot
Add Comment
Please, Sign In to add comment