-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2383 from Autodesk/vlasovi/MAYA-122246
Implementing testVP2RenderDelegateCameras autotest
- Loading branch information
Showing
9 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+5.41 KB
...vp2RenderDelegate/VP2RenderDelegateCamerasTest/baseline/RenderCameras_moved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.14 KB
...RenderDelegate/VP2RenderDelegateCamerasTest/baseline/RenderCameras_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.3 KB
...derDelegate/VP2RenderDelegateCamerasTest/baseline/RenderCameras_stage_moved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.4 KB
...Delegate/VP2RenderDelegateCamerasTest/baseline/RenderCameras_stage_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.13 KB
...nderDelegate/VP2RenderDelegateCamerasTest/baseline/RenderCameras_unselected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.51 KB
...elegate/VP2RenderDelegateCamerasTest/baseline/RenderCameras_with_new_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions
135
test/lib/mayaUsd/render/vp2RenderDelegate/testVP2RenderDelegateCameras.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#!/usr/bin/env mayapy | ||
# | ||
# Copyright 2022 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 fixturesUtils | ||
import imageUtils | ||
import mayaUtils | ||
import usdUtils | ||
import testUtils | ||
import ufeUtils | ||
|
||
from mayaUsd import ufe as mayaUsdUfe | ||
|
||
from maya import cmds | ||
|
||
import ufe | ||
import os | ||
|
||
class testVP2RenderDelegateCameras(imageUtils.ImageDiffingTestCase): | ||
""" | ||
Tests imaging using the Viewport 2.0 render delegate when using cameras | ||
""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
inputPath = fixturesUtils.setUpClass(__file__, | ||
initializeStandalone=False, loadPlugin=False) | ||
|
||
cls._baselineDir = os.path.join(inputPath, | ||
'VP2RenderDelegateCamerasTest', 'baseline') | ||
|
||
cls._testDir = os.path.abspath('.') | ||
|
||
def assertSnapshotClose(self, imageName): | ||
baselineImage = os.path.join(self._baselineDir, imageName) | ||
snapshotImage = os.path.join(self._testDir, imageName) | ||
imageUtils.snapshot(snapshotImage, width=960, height=540) | ||
return self.assertImagesClose(baselineImage, snapshotImage) | ||
|
||
def _StartTest(self, testName): | ||
cmds.file(force=True, new=True) | ||
mayaUtils.loadPlugin("mayaUsdPlugin") | ||
mayaUtils.loadPlugin("drawUfe") | ||
self._testName = testName | ||
testFile = testUtils.getTestScene("camera", self._testName + ".usda") | ||
mayaUtils.createProxyFromFile(testFile) | ||
|
||
def _RunTest(self): | ||
cmds.setAttr('stageShape.cplx', 1) | ||
|
||
# reparent one of the cameras to verify that the proxy camera handles this properly | ||
# !this check is temporarily disabled because of a bug in PathSubject::addRemoveAllCallbackHelper | ||
#cmds.parent('|stage|stageShape,/cameras/cam1', '|stage|stageShape,/cameras2') | ||
|
||
# unselect all and compare images | ||
globalSelection = ufe.GlobalSelection.get() | ||
globalSelection.clear() | ||
self.assertSnapshotClose('%s_unselected.png' % (self._testName)) | ||
|
||
# select all 2 cameras and compare images | ||
selection = ufe.Selection() | ||
selection.append(self._GetSceneItem('|stage|stageShape', '/cameras/cam1')) | ||
selection.append(self._GetSceneItem('|stage|stageShape', '/cameras/cam2')) | ||
globalSelection.replaceWith(selection) | ||
self.assertSnapshotClose('%s_selected.png' % (self._testName)) | ||
|
||
# change attributes that affect the camera image | ||
ufeItem = ufeUtils.createItem('|stage|stageShape,/cameras/cam2') | ||
cameraPrim = usdUtils.getPrimFromSceneItem(ufeItem) | ||
cameraPrim.GetAttribute('horizontalAperture').Set(100000) | ||
cameraPrim.GetAttribute('verticalAperture').Set(100000) | ||
cameraPrim.GetAttribute('focalLength').Set(100000) | ||
|
||
# move all 2 cameras and compare images | ||
cmds.move(-2, -2, -2, relative=True) | ||
self.assertSnapshotClose('%s_moved.png' % (self._testName)) | ||
|
||
# rename the stage to verify that the proxy camera handles this properly | ||
cmds.rename('|stage', 'stage2') | ||
|
||
# switch color management view transfrom to verify that the proxy camera handles this properly | ||
cmds.modelEditor('modelPanel4', edit=True, viewTransformName='Log') | ||
|
||
# select the stage and compare images | ||
globalSelection.clear() | ||
cmds.select('|stage2') | ||
self.assertSnapshotClose('%s_stage_selected.png' % (self._testName)) | ||
|
||
# delete one of the cameras to verify that the proxy camera handles this properly | ||
cmds.delete('|stage2|stage2Shape,/cameras/cam2') | ||
|
||
# move the stage and compare images | ||
cmds.move(4, 4, 4, absolute=True) | ||
self.assertSnapshotClose('%s_stage_moved.png' % (self._testName)) | ||
|
||
# add a new USD camera and compare images | ||
stage = mayaUsdUfe.getStage("|stage2|stage2Shape") | ||
stage.DefinePrim('/cameras2/cam3', "Camera") | ||
cmds.select( clear=True ) | ||
self.assertSnapshotClose('%s_with_new_camera.png' % (self._testName)) | ||
|
||
def _GetSceneItem(self, mayaPathString, usdPathString): | ||
mayaPathSegment = mayaUtils.createUfePathSegment(mayaPathString) | ||
usdPathSegment = usdUtils.createUfePathSegment(usdPathString) | ||
ufePath = ufe.Path([mayaPathSegment, usdPathSegment]) | ||
ufeItem = ufe.Hierarchy.createItem(ufePath) | ||
return ufeItem | ||
|
||
def testCameras(self): | ||
self._StartTest('RenderCameras') | ||
|
||
cmds.move(-10, 15, 20, 'persp') | ||
cmds.rotate(-30, -30, 0, 'persp') | ||
cmds.modelEditor('modelPanel4', edit=True, grid=False) | ||
cmds.displayColor('camera', 21, active=True) | ||
|
||
self._RunTest() | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#usda 1.0 | ||
( | ||
) | ||
|
||
def Xform "cameras" | ||
{ | ||
def Camera "cam1" | ||
{ | ||
float2 clippingRange = (0.1, 10000) | ||
float focalLength = 35 | ||
float focusDistance = 5 | ||
float fStop = 5.6 | ||
float horizontalAperture = 35.999928 | ||
float verticalAperture = 23.999952 | ||
|
||
double3 xformOp:translate = (3, 3, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
|
||
def Camera "cam2" | ||
{ | ||
float2 clippingRange = (0.1, 10000) | ||
float focalLength = 35 | ||
float focusDistance = 5 | ||
float fStop = 5.6 | ||
float horizontalAperture = 35.999928 | ||
float verticalAperture = 23.999952 | ||
} | ||
} | ||
|
||
def Xform "cameras2" | ||
{ | ||
} |