Skip to content

Commit

Permalink
Update operators.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinokage107 authored Jul 27, 2023
1 parent 2879ebe commit 4932805
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def execute(self, context):
arm = context.scene.anamnesis_armature.pose

# support for proper bone orientations: get diff from original
arm.bones['n_hara'].matrix_basis = Matrix()
arm.bones['n_throw'].matrix_basis = Matrix()
# axis-angle form of the diff quaternion we want to pass to each individual bone operation. shorthand to pack into a float vector property; this seems silly?
aa = Quaternion([1,0,0,0]).rotation_difference(arm.bones['n_hara'].matrix.to_quaternion()).to_axis_angle()
aa = Quaternion([1,0,0,0]).rotation_difference(arm.bones['n_throw'].matrix.to_quaternion()).to_axis_angle()
diff = [aa[0][0], aa[0][1], aa[0][2], aa[1]]

for bone in arm.bones:
bpy.ops.pose.load_ana_bone('EXEC_DEFAULT', bone=bone.name, path=self.filepath, diff=diff)
# rotate the whole thing to be upright, otherwise it can turn based on the transform of the armature object
arm.bones['n_hara'].rotation_quaternion = Quaternion([1,0,0,0])
arm.bones['n_throw'].rotation_quaternion = Quaternion([1,0,0,0])
return {'FINISHED'}

# don't forget this so we can get the file select popup
Expand Down Expand Up @@ -108,9 +108,9 @@ def execute(self, context):
arm = context.scene.anamnesis_armature.pose

hara = arm.bones['n_hara'].matrix_basis
arm.bones['n_hara'].matrix_basis = Matrix()
arm.bones['n_throw'].matrix_basis = Matrix()
diff = Quaternion([1,0,0,0]).rotation_difference(arm.bones['n_hara'].matrix.to_quaternion())
arm.bones['n_hara'].matrix_basis = hara
arm.bones['n_throw'].matrix_basis = hara

with open(self.filepath, 'w') as f:
json_dict = {
Expand Down

0 comments on commit 4932805

Please sign in to comment.