bnp.objects.armature¶
-
posebone_basis(dtype=np.float32) → np.ndarray¶ Return Blender’s posebone basis (equal to bone.matrix_basis) to adjust a bone’s rotation
Parameters: dtype – dtype Returns: np.ndarray basis
-
armature2np(armature, dtype=np.float32, mode="dynamic", frame=bpy.context.scene.frame_current) → np.ndarray¶ Convert a bpy.types.Object which has bpy.types.Armature to np.ndarray at current frame.
Parameters: - armature (bpy.types.Object) – armature which has bpy.types.Armature at armature.data
- dtype – dtype
- mode (str) – “head” or “tail”: local head/tail positions (joint_num, 3), “length”: bone lengths (joint_num,), “offset”: bone offset translation matices (joint_num, 4, 4),”rest” / “dynamic”: absolute translation matrices at rest pose / the frame, “rotation”: pose vectors
- frame (int) – frame when you want to read (default: current frame)
Returns: np.ndarray
-
posebone2np(posebone, dtype=np.float32, mode="dynamic", frame=bpy.context.scene.frame_current) → np.ndarray¶ Get posebone as np.ndarray.
Parameters: - posebone (bpy.types.PoseBone) – posebone
- dtype – dtype
- mode (str) – “head” or “tail”: local head/tail positions (joint_num, 3), “length”: bone lengths (joint_num,), “offset”: offset matrix from the parent (4, 4), “dynamic”: absolute translation matrices at the frame
- frame (int) – frame when you want to read (default: current frame)
Returns: np.ndarray
-
bone2np(bone, dtype=np.float32, mode="rest", frame=bpy.context.scene.frame_current) → np.ndarray¶ Get bone as np.ndarray.
Parameters: - bone (bpy.types.Bone) – bone
- dtype – dtype
- mode (str) – “head” or “tail”: local head/tail positions (joint_num, 3), “length”: bone lengths (joint_num,), “offset”: offset matrix from the parent (4, 4), “rest”: absolute translation matrices at rest pose
- frame (int) – frame when you want to read (default: current frame)
Returns: np.ndarray
-
get_kinematic_tree(armature: bpy.types.Object) → list¶ Get a kinematic tree as a list (index: bone index, value: parent index)
Parameters: armature – bpy.types.Object or bpy.types.Armature
-
insert_keyframe_to_posebone(posebone, pose, translation=None, frame=bpy.context.scene.frame_current, rotation_mode="rotation_axis_angle")¶ Insert a keyframe to a posebone
Parameters: - posebone (bpy.types.PoseBone) – posebone
- pose (np.ndarray) – pose (3) or (4)
- translation (np.ndarray) – translation (3), (4) or None
- frame (int) – keyframe
- rotation_mode (str) – “rotation_axis_angle” (equal to “AXIS_ANGLE”), “rotation_quaternion” (equal to “QUATERNION”) or “rotation_euler” (equal to “XYZ”)
-
insert_keyframe_to_armature(armature, poses, translations=None, frame=bpy.context.scene.frame_current, rotation_mode="rotation_axis_angle", exception_bone_indices=None, only_root_translation=True)¶ Insert a keyframe to an harmature
Parameters: - armature (bpy.types.Object) – armature which has bpy.types.Armature
- poses (np.ndarray) – poses (num_of_joints, 3) or (num_of_joints, 4)
- translations (np.ndarray) – translations (num_of_joints, 3), (1, 3) or None
- frame (int) – keyframe
- rotation_mode (str) – “rotation_axis_angle” (equal to “AXIS_ANGLE”), “rotation_quaternion” (equal to “QUATERNION”) or “rotation_euler” (equal to “XYZ”)
- exception_bone_indices (list) – bone indices not to insert keyframes
- only_root_translation (bool) – whether to insert only root translation or not
-
remove_keyframe_from_posebone(posebone, frame, exception_bone_indices=None)¶ Remove a keyframe from an input posebone
Parameters: - posebone (bpy.types.PoseBone) – posebone
- frame (int) – frame
-
remove_keyframe_from_armature(armature, frame, exception_bone_indices=None)¶ Remove a keyframe from an input armature
Parameters: - armature (bpy.types.Object) – armature which has bpy.types.Armature
- frame (int) – frame
- exception_bone_indices (list) – bone index list not to remove keyframes (optional)
-
remove_keyframes_from_armature(armature, frames, exception_bone_indices=None)¶ Remove a keyframe from an input armature
Parameters: - armature (bpy.types.Object) – armature which has bpy.types.Armature
- frames (list) – frame list
- exception_bone_indices (list) – bone index list not to remove keyframes (optional)
-
change_rotation_modes_of_armature(armature, rotation_mode, normalized=True)¶ Change rotation modes of an input armature and posebones in the armature
Parameters: - armature (bpy.types.Object) – armature which has bpy.types.Armature
- rotation_mode (str) – “rotation_axis_angle” (equal to “AXIS_ANGLE”), “rotation_quaternion” (equal to “QUATERNION”) or “rotation_euler” (equal to “XYZ”)
- normalized (bool) – whether to normalize axis_angle or quaternion
-
normalize_roll(armature: bpy.types.Object)¶ Normalize bones’ rolls
Parameters: obj (bpy.types.Object) – object which has bpy.types.Armature