From cd026fd98139f51497ee25c9f40f96c3e11db5fe Mon Sep 17 00:00:00 2001 From: Samuel Liu Date: Thu, 30 May 2024 18:20:16 -0400 Subject: [PATCH] Add unit tests for camera manipulators --- test/lib/ufe/testCamera.py | 32 +++++++++++++++++++ .../testSamples/camera/cameraManipulator.usda | 11 +++++++ 2 files changed, 43 insertions(+) create mode 100644 test/testSamples/camera/cameraManipulator.usda diff --git a/test/lib/ufe/testCamera.py b/test/lib/ufe/testCamera.py index d6227f7ec5..1928e8f5fe 100644 --- a/test/lib/ufe/testCamera.py +++ b/test/lib/ufe/testCamera.py @@ -331,5 +331,37 @@ def testUsdCameraHandler(self): result = ufe.CameraHandler.findAll(geoPath) self.assertTrue(result.empty()) + @unittest.skipUnless(mayaUtils.mayaMajorMinorVersions() >= (2025, 2), 'Maya USD camera manipulator is only supported in 2025.2 or greater.') + def testUsdCameraManipulators(self): + cmds.file(force=True, new=True) + mayaUtils.loadPlugin("mayaUsdPlugin") + testFile = testUtils.getTestScene("camera", 'cameraManipulator.usda') + mayaUtils.createProxyFromFile(testFile) + globalSelection = ufe.GlobalSelection.get() + globalSelection.clear() + + # create some strings + cameraManPathString = '|stage|stageShape,/Camera1' + + camItem = ufeUtils.createItem(cameraManPathString) + cameraPrim = usdUtils.getPrimFromSceneItem(camItem) + + translateAttr = cameraPrim.GetAttribute("xformOp:translate") + self.assertIsNotNone(translateAttr) + tranlateBeforeEdit = translateAttr.Get() + print(tranlateBeforeEdit) + + # dolly + cmds.dolly( cameraManPathString, d = -3 ) + translateAttr = cameraPrim.GetAttribute("xformOp:translate") + self.assertIsNotNone(translateAttr) + self.assertEqual(translateAttr.Get(), Gf.Vec3d(0.0, 0.0, -3.0)) + + #track + cmds.track( cameraManPathString, d = 10 ) + translateAttr = cameraPrim.GetAttribute("xformOp:translate") + self.assertIsNotNone(translateAttr) + self.assertEqual(translateAttr.Get(), Gf.Vec3d(0.0, -10.0, 0.0)) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/test/testSamples/camera/cameraManipulator.usda b/test/testSamples/camera/cameraManipulator.usda new file mode 100644 index 0000000000..b194297f01 --- /dev/null +++ b/test/testSamples/camera/cameraManipulator.usda @@ -0,0 +1,11 @@ +#usda 1.0 + +def Camera "Camera1" +{ + float3 xformOp:rotateXYZ = (0, 0, 0) + double3 xformOp:translate = (0, 0, 0) + float3 xformOp:translate:rotatePivot = (0, 0, 0) + float3 xformOp:translate:rotatePivotTranslate = (0, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:rotatePivotTranslate", "xformOp:translate:rotatePivot", "xformOp:rotateXYZ", "!invert!xformOp:translate:rotatePivot"] +} +