Skip to content

Commit

Permalink
Add unit tests for camera manipulators
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelliu-adsk committed May 30, 2024
1 parent 7a2bc9b commit cd026fd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/lib/ufe/testCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
11 changes: 11 additions & 0 deletions test/testSamples/camera/cameraManipulator.usda
Original file line number Diff line number Diff line change
@@ -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"]
}

0 comments on commit cd026fd

Please sign in to comment.