Hello everyone,
I have encountered a challenge while automating the manipulation of a Primitive object. The Primitive has a noticeable difference in pivot position compared to its parent object’s xform. To ensure correct scaling, I utilized a pivot tool to adjust the pivot position of the parent object accordingly. With the help of Omniverse’s rotation tool, I have successfully achieved accurate rotation, translation, and scaling of the Primitive using the new pivot point.
However, as I attempted to replicate these transformations programmatically using a Python script and a 4x4 transformation matrix for a -90 degree rotation around the Y-axis, I encountered unexpected stretching effects. Despite the Primitive rotating correctly, the resulting appearance is not as intended.
I would greatly appreciate any guidance or insights on how to address this issue and achieve the desired transformation accurately without the presence of stretching effects. Thank you in advance for your assistance.
import omni.usd
import math
from pxr import Gf, UsdGeomdef get_rotation_matrix(angle):
rotation = Gf.Rotation(Gf.Vec3d(0, 1, 0), angle)
matrix = Gf.Matrix4d(1.0)
matrix.SetRotate(rotation)
return matrixrotation_matrix = get_rotation_matrix(-90)
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath(“/scene/Meshes/Sketchfab_model/root/GLTF_SceneRootNode/Box_28”)
transform_matrix = prim.GetAttribute(“xformOp:transform”).Get()prim.GetAttribute(“xformOp:transform”).Set(rotation_matrix * transform_matrix)