Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HYDRA-806 - Create a unit test for translate, rotate, scale #51

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(TEST_SCRIPT_FILES
testRendererSwitching.py
testSceneBrowser.py
testStageAddPrim.py
testTransforms.py
testNewSceneWithStage.py
testDirectionalLights.py
testFlowViewportAPI.py
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testTransforms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2020 Luma Pictures
lanierd-adsk marked this conversation as resolved.
Show resolved Hide resolved
lanierd-adsk marked this conversation as resolved.
Show resolved Hide resolved
# Copyright 2023 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
lanierd-adsk marked this conversation as resolved.
Show resolved Hide resolved

def setUp(self):
self.imageVersion = None
if maya.mel.eval("defaultShaderName") != "standardSurface1":
self.imageVersion = 'lambertDefaultMaterial'
lanierd-adsk marked this conversation as resolved.
Show resolved Hide resolved

def verifySnapshot(self, imageName):
cmds.refresh()
self.assertSnapshotClose(imageName,
self.IMAGEDIFF_FAIL_THRESHOLD,
self.IMAGEDIFF_FAIL_PERCENT,
imageVersion=self.imageVersion)

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")
lanierd-adsk marked this conversation as resolved.
Show resolved Hide resolved

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())
Loading