Skip to content

Commit

Permalink
add convert_transformation_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
moonyuet committed Sep 11, 2024
1 parent 1f0628b commit 2e54535
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions client/ayon_maya/plugins/publish/extract_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,28 @@ def convert_abc_transformation_matrix(self, transform_mm: om.MMatrix, rotation:
convert_transform.setScale([convert_scale[0], convert_scale[2], convert_scale[1]], om.MSpace.kObject)

return convert_transform.asMatrix()


def convert_transformation_matrix(self, transform_mm: om.MMatrix, rotation: list) -> om.MMatrix:
"""Convert matrix to list of transformation matrix for Unreal Engine fbx asset import.
Args:
transform_mm (om.MMatrix): Local Matrix for the asset
rotation (list): Rotations of the asset
Returns:
List[om.MMatrix]: List of transformation matrix of the asset
"""
convert_transform = om.MTransformationMatrix(transform_mm)

convert_translation = convert_transform.translation(om.MSpace.kWorld)
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)
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)

return convert_transform.asMatrix()

0 comments on commit 2e54535

Please sign in to comment.