diff --git a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt index 1e47a21e3e..a5726831dc 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt @@ -11,6 +11,7 @@ set(TEST_SCRIPT_FILES testRendererSwitching.py testSceneBrowser.py testStageAddPrim.py + testTransforms.py testNewSceneWithStage.py testDirectionalLights.py testFlowViewportAPI.py diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved.png new file mode 100644 index 0000000000..33e6da91ce Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved_rotated.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved_rotated.png new file mode 100644 index 0000000000..3edea31877 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved_rotated.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved_rotated_scaled.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved_rotated_scaled.png new file mode 100644 index 0000000000..8e9c3e7e55 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_parent_moved_rotated_scaled.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled.png new file mode 100644 index 0000000000..880f4776ae Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled_moved.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled_moved.png new file mode 100644 index 0000000000..1f242b553b Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled_moved.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled_moved_rotated.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled_moved_rotated.png new file mode 100644 index 0000000000..10563d0912 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_scaled_moved_rotated.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_untransformed.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_untransformed.png new file mode 100644 index 0000000000..2191ccf418 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/cube_untransformed.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved.png new file mode 100644 index 0000000000..cc2175172e Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved_rotated.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved_rotated.png new file mode 100644 index 0000000000..bbb2fc7701 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved_rotated.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved_rotated_scaled.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved_rotated_scaled.png new file mode 100644 index 0000000000..729f6d7e6e Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_parent_moved_rotated_scaled.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled.png new file mode 100644 index 0000000000..db02475a70 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled_moved.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled_moved.png new file mode 100644 index 0000000000..d2af9eef04 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled_moved.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled_moved_rotated.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled_moved_rotated.png new file mode 100644 index 0000000000..b0305c2c83 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_scaled_moved_rotated.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_untransformed.png b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_untransformed.png new file mode 100644 index 0000000000..abc657bf53 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/TransformsTest/usd_cube_untransformed.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py b/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py new file mode 100644 index 0000000000..e862dd92f7 --- /dev/null +++ b/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py @@ -0,0 +1,101 @@ +# Copyright 2024 Autodesk +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import maya.cmds as cmds +import maya.mel + +import fixturesUtils +import mtohUtils +import unittest + +class TestTransforms(mtohUtils.MtohTestCase): + _file = __file__ + + IMAGEDIFF_FAIL_THRESHOLD = 0.01 + IMAGEDIFF_FAIL_PERCENT = 0.1 + + def verifySnapshot(self, imageName): + cmds.refresh() + self.assertSnapshotClose(imageName, + self.IMAGEDIFF_FAIL_THRESHOLD, + self.IMAGEDIFF_FAIL_PERCENT) + + def test_nativePrim(self): + self.makeCubeScene(camDist=6) + cubeParent = cmds.group(self.cubeTrans, name='cubeParent') + cmds.select(clear=1) + + self.verifySnapshot("cube_untransformed.png") + + cmds.scale(3, 1, 3, self.cubeTrans, absolute=True) + self.verifySnapshot("cube_scaled.png") + + cmds.move(0, 2, 0, self.cubeTrans, absolute=True) + self.verifySnapshot("cube_scaled_moved.png") + + cmds.rotate(0, 45, 0, self.cubeTrans, absolute=True) + self.verifySnapshot("cube_scaled_moved_rotated.png") + + cmds.move(0, -3, 0, cubeParent, absolute=True) + self.verifySnapshot("cube_parent_moved.png") + + cmds.rotate(0, 0, 45, cubeParent, absolute=True) + self.verifySnapshot("cube_parent_moved_rotated.png") + + cmds.scale(2, 2, 2, cubeParent, absolute=True) + self.verifySnapshot("cube_parent_moved_rotated_scaled.png") + + @unittest.skipUnless(mtohUtils.checkForMayaUsdPlugin(), "Requires Maya USD Plugin.") + def test_usdPrim(self): + import mayaUsd + import mayaUsd_createStageWithNewLayer + from pxr import UsdGeom, Gf + + cmds.file(new=True, force=True) + self.setBasicCam(10) + self.setHdStormRenderer() + + # Create a USD stage + usdProxyShapeUfePathString = mayaUsd_createStageWithNewLayer.createStageWithNewLayer() + stage = mayaUsd.lib.GetPrim(usdProxyShapeUfePathString).GetStage() + + # Define a cube prim in the stage + parentA = "/ParentA" + childCube = "/ParentA/Cube" + parentPrimA = stage.DefinePrim(parentA, 'Xform') + childPrimCube = stage.DefinePrim(childCube, 'Cube') + + self.verifySnapshot("usd_cube_untransformed.png") + + UsdGeom.XformCommonAPI(childPrimCube).SetScale((2, 1, 2)) + self.verifySnapshot("usd_cube_scaled.png") + + UsdGeom.XformCommonAPI(childPrimCube).SetTranslate((0, 2, 0)) + self.verifySnapshot("usd_cube_scaled_moved.png") + + UsdGeom.XformCommonAPI(childPrimCube).SetRotate(Gf.Vec3f(0, 45, 0)) + self.verifySnapshot("usd_cube_scaled_moved_rotated.png") + + UsdGeom.XformCommonAPI(parentPrimA).SetTranslate((0, -4, 0)) + self.verifySnapshot("usd_cube_parent_moved.png") + + UsdGeom.XformCommonAPI(parentPrimA).SetRotate(Gf.Vec3f(0, 0, 45)) + self.verifySnapshot("usd_cube_parent_moved_rotated.png") + + UsdGeom.XformCommonAPI(parentPrimA).SetScale((2, 3, 2)) + self.verifySnapshot("usd_cube_parent_moved_rotated_scaled.png") + + +if __name__ == '__main__': + fixturesUtils.runTests(globals())