def testImportInverseXformOpsOnly(self): """ Tests that importing a USD cube mesh that has XformOps on it all tagged as inverse ops results in the correct transform when imported into Maya. """ usdFile = os.path.join(self.inputPath, "UsdImportXformsTest", "UsdImportXformsTest.usda") cmds.usdImport(file=usdFile, shadingMode='none') mayaTransform = self._GetMayaTransform('InverseOpsOnlyCube') transformationMatrix = mayaTransform.transformation() expectedTranslation = [-1.0, -2.0, -3.0] actualTranslation = list( transformationMatrix.translation(OM.MSpace.kTransform)) self.assertTrue( Gf.IsClose(expectedTranslation, actualTranslation, self.EPSILON)) expectedRotation = [0.0, 0.0, Gf.DegreesToRadians(-45.0)] actualRotation = list(transformationMatrix.rotation()) self.assertTrue( Gf.IsClose(expectedRotation, actualRotation, self.EPSILON)) expectedScale = [2.0, 2.0, 2.0] actualScale = list(transformationMatrix.scale(OM.MSpace.kTransform)) self.assertTrue( Gf.IsClose(expectedScale, actualScale, self.EPSILON))
def testImportXformsRotateAxis(self): """ Tests that importing xforms that have a rotateAxis with rotate order other than just XYZ still imports correctly """ usdFile = os.path.join(self.inputPath, "UsdImportXformsTest", "UsdImportXformsTestRotateAxis.usda") cmds.usdImport(file=usdFile, shadingMode=[ ["none", "default"], ]) expectedRotates = { 'X': (60, 0, 0), 'Y': (0, 60, 0), 'Z': (0, 0, 60), 'XYZ': (-120, 60, 0), 'YZX': (-106.1021138, 25.6589063, 56.3099325), 'ZXY': (120, -60, 0), 'XZY': (-120, -60, 0), 'YXZ': (106.1021138, 25.6589063, -56.3099325), 'ZYX': (-106.1021138, -25.6589063, -56.3099325), } expectedScale = (.5, .5, .5) expectedTranslation = (1.0, 2.0, 3.0) for rotOrderName in expectedRotates.keys(): expectedRotation = expectedRotates[rotOrderName] mayaTransform = self._GetMayaTransform(rotOrderName) transformationMatrix = mayaTransform.transformation() actualTranslation = list( transformationMatrix.translation(OM.MSpace.kTransform)) self.assertTrue( Gf.IsClose(expectedTranslation, actualTranslation, self.EPSILON)) expectedRotation = [ Gf.DegreesToRadians(x) for x in expectedRotation ] actualRotation = transformationMatrix.rotationOrientation( ).asEulerRotation() actualRotation = list(actualRotation) #print rotOrderName, actualRotation self.assertTrue( Gf.IsClose(expectedRotation, actualRotation, self.EPSILON)) actualScale = list(transformationMatrix.scale( OM.MSpace.kTransform)) self.assertTrue( Gf.IsClose(expectedScale, actualScale, self.EPSILON))