Skip to content

Commit

Permalink
add rotation data as being part of the json_element
Browse files Browse the repository at this point in the history
  • Loading branch information
moonyuet committed Aug 2, 2024
1 parent de7db5d commit e8d9c99
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions client/ayon_maya/plugins/publish/extract_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,9 @@ def convert_transformation_matrix(transform_mm: om.MMatrix, rotation: list) -> o
convert_translation = om.MVector(convert_translation.x, convert_translation.z, -convert_translation.y)
convert_scale = convert_transform.scale(om.MSpace.kObject)
convert_transform.setTranslation(convert_translation, om.MSpace.kWorld)
# If rotation x are less than 0, the z rotation would be flipped
# If rotation x are at 0 and rotation x are at 0, the z rotation would be flipped.
# If rotation x, y, z equals to zero, the rotations remains same value.
# if rotation y has values, the z rotation would be same.
# If the rotation x ,y ,z have values, the rotations remains same value.
if rotation[0] <= 0 or rotation[1] == 0 or (rotation[0] == 0 and rotation[1] == 0) or not (
rotation[0] == 0 and rotation[1] == 0 and rotation[2] == 0) or not (rotation[1] == 0):
converted_rotation = om.MEulerRotation(
math.radians(rotation[0]), math.radians(rotation[2]),
math.radians(-180) + math.radians(rotation[1])
)
else:
converted_rotation = om.MEulerRotation(
math.radians(rotation[0]), math.radians(rotation[2]), math.radians(rotation[1])
)
converted_rotation = om.MEulerRotation(
math.radians(rotation[0]), math.radians(rotation[2]), math.radians(rotation[1])
)
convert_transform.setRotation(converted_rotation)
convert_transform.setScale([convert_scale[0], convert_scale[2], convert_scale[1]], om.MSpace.kObject)

Expand Down Expand Up @@ -167,6 +155,11 @@ def process(self, instance):
for row in b_matrix:
json_element["basis"].append(list(row))

json_element["rotation"] = {
"x": local_rotation[0],
"y": local_rotation[1],
"z": local_rotation[2]
}
json_data.append(json_element)

json_filename = "{}.json".format(instance.name)
Expand Down

0 comments on commit e8d9c99

Please sign in to comment.