Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _GenerateBoneKeys(self):
- from itertools import zip_longest as zipl
- Scene = bpy.context.scene # Convenience alias
- BlenderCurrentFrame = Scene.frame_current
- ArmatureObject = self.ExportObject.BlenderObject
- ArmatureSafeName = self.ExportObject.SafeName
- # Create Animation objects for each bone
- BoneAnimations = [Animation(ArmatureSafeName + "_" + \
- Util.SafeName(Bone.name)) for Bone in ArmatureObject.pose.bones]
- for Frame in range(Scene.frame_start, Scene.frame_end + 1):
- Scene.frame_set(Frame)
- for Bone, BoneAnimation in \
- zipl(ArmatureObject.pose.bones, BoneAnimations):
- Rotation = Bone.rotation_quaternion
- PoseMatrix = Matrix()
- if Bone.parent:
- PoseMatrix = Bone.parent.matrix.inverted()
- PoseMatrix *= Bone.matrix
- Scale = PoseMatrix.to_scale()
- Position = PoseMatrix.to_translation()
- BoneAnimation.RotationKeys.append(Rotation)
- BoneAnimation.ScaleKeys.append(Scale)
- BoneAnimation.PositionKeys.append(Position)
- #Выводит нормальные повороты
- self.Exporter.Log("Rotation for frame {} for bone {} is {}".format(Frame, Bone, BoneAnimation.RotationKeys[-1]))
- #ВЫВОДИТ КАКУЮ-ТО ХУЙНЮ НЕПРАВИЛЬНУЮ, БЛЯДЬ
- for Bone, Anim in enumerate(BoneAnimations):
- for Frame, BAnim in enumerate(Anim.RotationKeys):
- self.Exporter.Log("Rotation for frame {} for bone {} is {}".format(Frame, Bone, BAnim))
- self.Animations += BoneAnimations
- Scene.frame_set(BlenderCurrentFrame)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement