I’m having trouble getting the exact rotation of a prim. I followed the video totorial given in the solution here:
I tried the following:
def decompose_matrix(self, mat: Gf.Matrix4d):
reversed_ident_mtx = reversed(Gf.Matrix3d())
translate: Gf.Vec3d = mat.ExtractTranslation()
scale: Gf.Vec3d = Gf.Vec3d(*(v.GetLength() for v in mat.ExtractRotationMatrix()))
mat.Orthonormalize()
rotate = Gf.Vec3d(*reversed(mat.ExtractRotation().Decompose(*reversed_ident_mtx)))
return translate, rotate, scale
def get_world_transform_xform(self, prim: Usd.Prim) -> typing.Tuple[Gf.Vec3d, Gf.Rotation, Gf.Vec3d]:
world_transform: Gf.Matrix4d = omni.usd.get_world_transform_matrix(prim)
decompose_matrix = self.decompose_matrix(world_transform)
return decompose_matrix
def get_local_transform_xform(self, prim: Usd.Prim):
xform = UsdGeom.Xformable(prim)
local_transform: Gf.Matrix4d = xform.GetLocalTransformation()
decompose_matrix = self.decompose_matrix(local_transform)
return decompose_matrix
def get_global_transform_omni(self, prim):
xform = UsdGeom.Xformable(prim)
mtrx = xform.ComputeLocalToWorldTransform(0)
decompose_matrix = self.decompose_matrix(mtrx)
return decompose_matrix
the good news is that they all give me the same solution. The bad news is that its not the rotation displayed in the editor:
any input on this would be super helpful. I saw it working perfectly in the office hours video not sure whats wrong on my end. I did notice that in Mati’s editor he had ‘Rotate’ while I have ‘Orient’:
But still its just Euler angles so it shouldnt be different. On my end if I add ‘Rotate’ Only the Orient changes with the rotation of the prim. ‘Rotate’ is always zeros.