Advertisement
Guest User

Untitled

a guest
Mar 14th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1.     def _GenerateBoneKeys(self):
  2.         from itertools import zip_longest as zipl
  3.        
  4.         Scene = bpy.context.scene # Convenience alias
  5.         BlenderCurrentFrame = Scene.frame_current
  6.        
  7.         ArmatureObject = self.ExportObject.BlenderObject
  8.         ArmatureSafeName = self.ExportObject.SafeName
  9.        
  10.         # Create Animation objects for each bone
  11.         BoneAnimations = [Animation(ArmatureSafeName + "_" + \
  12.             Util.SafeName(Bone.name)) for Bone in ArmatureObject.pose.bones]
  13.        
  14.         for Frame in range(Scene.frame_start, Scene.frame_end + 1):
  15.             Scene.frame_set(Frame)
  16.            
  17.             for Bone, BoneAnimation in \
  18.                 zipl(ArmatureObject.pose.bones, BoneAnimations):
  19.                
  20.                 Rotation = Bone.rotation_quaternion
  21.                
  22.                 PoseMatrix = Matrix()
  23.                 if Bone.parent:
  24.                     PoseMatrix = Bone.parent.matrix.inverted()
  25.                 PoseMatrix *= Bone.matrix
  26.                
  27.                 Scale = PoseMatrix.to_scale()
  28.                 Position = PoseMatrix.to_translation()
  29.                
  30.                 BoneAnimation.RotationKeys.append(Rotation)
  31.                 BoneAnimation.ScaleKeys.append(Scale)
  32.                 BoneAnimation.PositionKeys.append(Position)
  33.  
  34.                 #Выводит нормальные повороты
  35.                 self.Exporter.Log("Rotation for frame {} for bone {} is {}".format(Frame, Bone, BoneAnimation.RotationKeys[-1]))
  36.  
  37.         #ВЫВОДИТ КАКУЮ-ТО ХУЙНЮ НЕПРАВИЛЬНУЮ, БЛЯДЬ
  38.         for Bone, Anim in enumerate(BoneAnimations):
  39.             for Frame, BAnim in enumerate(Anim.RotationKeys):
  40.                 self.Exporter.Log("Rotation for frame {} for bone {} is {}".format(Frame, Bone, BAnim))
  41.        
  42.         self.Animations += BoneAnimations
  43.         Scene.frame_set(BlenderCurrentFrame)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement