本文整理汇总了Python中maya.cmds.usdExport函数的典型用法代码示例。如果您正苦于以下问题:Python usdExport函数的具体用法?Python usdExport怎么用?Python usdExport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usdExport函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testReexport
def testReexport(self):
cmds.usdImport(file=self.USD_FILE, primPath='/')
cmds.usdExport(file=self.USD_FILE_OUT)
stage = Usd.Stage.Open(self.USD_FILE_OUT)
self.assertTrue(stage)
self.assertTrue(stage.GetPrimAtPath('/A'))
self.assertEqual(stage.GetPrimAtPath('/A').GetTypeName(), 'Xform')
self.assertTrue(stage.GetPrimAtPath('/A/A_1'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1').GetTypeName(), '')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_I'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_I').GetTypeName(),
'')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_II'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_II').GetTypeName(),
'') # Originally Cube, but not on re-export!
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_III'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_III').GetTypeName(),
'Scope')
self.assertTrue(stage.GetPrimAtPath('/A/A_2'))
self.assertEqual(stage.GetPrimAtPath('/A/A_2').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/B'))
self.assertEqual(stage.GetPrimAtPath('/B').GetTypeName(), '')
self.assertTrue(stage.GetPrimAtPath('/B/B_1'))
self.assertEqual(stage.GetPrimAtPath('/B/B_1').GetTypeName(), 'Xform')
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:26,代码来源:testUsdTranslateTypelessDefs.py
示例2: setUpClass
def setUpClass(cls):
standalone.initialize('usd')
# Stage with simple (non-nested) instancing.
mayaFile = os.path.abspath('InstancedShading.ma')
cmds.file(mayaFile, open=True, force=True)
usdFilePath = os.path.abspath('InstancedShading.usda')
cmds.loadPlugin('pxrUsd')
cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath,
shadingMode='displayColor', exportInstances=True,
materialsScopeName='Materials',
exportCollectionBasedBindings=True,
exportMaterialCollections=True,
materialCollectionsPath="/World")
cls._simpleStage = Usd.Stage.Open(usdFilePath)
# Stage with nested instancing.
mayaFile = os.path.abspath('NestedInstancedShading.ma')
cmds.file(mayaFile, open=True, force=True)
usdFilePath = os.path.abspath('NestedInstancedShading.usda')
cmds.loadPlugin('pxrUsd')
cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath,
shadingMode='displayColor', exportInstances=True,
materialsScopeName='Materials',
exportCollectionBasedBindings=True,
exportMaterialCollections=True,
materialCollectionsPath="/World")
cls._nestedStage = Usd.Stage.Open(usdFilePath)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:32,代码来源:testUsdExportShadingInstanced.py
示例3: setUpClass
def setUpClass(cls):
standalone.initialize('usd')
cmds.loadPlugin('pxrUsd')
if not UsdMaya.WriteUtil.WriteUVAsFloat2():
cmds.file(os.path.abspath('UsdExportUVSetsTest.ma'), open=True,
force=True)
else:
cmds.file(os.path.abspath('UsdExportUVSetsTest_Float.ma'), open=True,
force=True)
# Make some live edits to the box with weird UVs for the
# testExportUvVersusUvIndexFromIterator test.
cmds.select("box.map[0:299]", r=True)
cmds.polyEditUV(u=1.0, v=1.0)
usdFilePath = os.path.abspath('UsdExportUVSetsTest.usda')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
shadingMode='none',
exportColorSets=False,
exportDisplayColor=False,
exportUVs=True)
cls._stage = Usd.Stage.Open(usdFilePath)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:25,代码来源:testUsdExportUVSets.py
示例4: testReexportScope
def testReexportScope(self):
cmds.usdImport(file=self.USD_FILE, primPath='/')
cmds.usdExport(file=self.USD_FILE_OUT)
stage = Usd.Stage.Open(self.USD_FILE_OUT)
self.assertTrue(stage)
self.assertTrue(stage.GetPrimAtPath('/A'))
self.assertEqual(stage.GetPrimAtPath('/A').GetTypeName(), 'Xform')
self.assertTrue(stage.GetPrimAtPath('/A/A_1'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_I'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_I').GetTypeName(),
'Mesh')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_II'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_II').GetTypeName(),
'Camera')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_III'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_III').GetTypeName(),
'Scope')
self.assertTrue(stage.GetPrimAtPath('/A/A_2'))
self.assertEqual(stage.GetPrimAtPath('/A/A_2').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/B'))
self.assertEqual(stage.GetPrimAtPath('/B').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/B/B_1'))
self.assertEqual(stage.GetPrimAtPath('/B/B_1').GetTypeName(), 'Xform')
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:26,代码来源:testPxrUsdTranslatorsScope.py
示例5: testArKitCompatibility
def testArKitCompatibility(self):
'''Tests usdz package export with ARKit compatibility profile.'''
usdFile = os.path.abspath('MyAwesomeArKitCompatibleFile.usdz')
usdFileNoExt = os.path.abspath('MyAwesomeArKitCompatibleFile')
# The usdExport command should automatically add "usdz" extension since
# we're requestion appleArKit compatibility.
cmds.usdExport(
file=usdFileNoExt,
mergeTransformAndShape=True,
shadingMode='none',
compatibility='appleArKit')
# Lets make sure that the root layer is the first file and that all
# the references were localized ok.
# Note that the path of "card.png" in the usdz archive may have changed
# because of the flattening step.
zipFile = Usd.ZipFile.Open(usdFile)
fileNames = zipFile.GetFileNames()
self.assertEqual(len(fileNames), 2)
self.assertEqual(fileNames[0], "MyAwesomeArKitCompatibleFile.usdc")
self.assertTrue(fileNames[1].endswith("card.png"))
# Open the usdz file up to verify that everything exported properly.
stage = Usd.Stage.Open(usdFile)
self._AssertExpectedStage(stage, fileNames[-1])
# Make sure there's no weird temp files sitting around.
self._AssertNoTempFiles(usdFile)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:29,代码来源:testUsdExportPackage.py
示例6: testExportInstances
def testExportInstances(self):
usdFile = os.path.abspath('UsdExportPref_nopref.usda')
cmds.usdExport(mergeTransformAndShape=True, exportReferenceObjects=False,
shadingMode='none', file=usdFile)
stage = Usd.Stage.Open(usdFile)
plane1Path = '/pPlane1'
plane2Path = '/pPlane2'
plane1 = UsdGeom.Mesh.Get(stage, plane1Path)
self.assertTrue(plane1.GetPrim().IsValid())
plane2 = UsdGeom.Mesh.Get(stage, plane2Path)
self.assertTrue(plane2.GetPrim().IsValid())
self.assertFalse(plane1.GetPrimvar(UsdUtils.GetPrefName()).IsDefined())
usdFile = os.path.abspath('UsdExportPref_pref.usda')
cmds.usdExport(mergeTransformAndShape=True, exportReferenceObjects=True,
shadingMode='none', file=usdFile)
stage = Usd.Stage.Open(usdFile)
plane1 = UsdGeom.Mesh.Get(stage, plane1Path)
self.assertTrue(plane1.GetPrim().IsValid())
plane2 = UsdGeom.Mesh.Get(stage, plane2Path)
self.assertTrue(plane2.GetPrim().IsValid())
self.assertTrue(plane1.GetPrimvar(UsdUtils.GetPrefName()).IsDefined())
self.assertEqual(plane1.GetPrimvar(UsdUtils.GetPrefName()).Get(), plane2.GetPointsAttr().Get())
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:30,代码来源:testUsdExportPref.py
示例7: testExportAsPoly
def testExportAsPoly(self):
usdFile = os.path.abspath('UsdExportMesh_none.usda')
cmds.usdExport(mergeTransformAndShape=True, file=usdFile,
shadingMode='none', defaultMeshScheme='none')
stage = Usd.Stage.Open(usdFile)
m = UsdGeom.Mesh.Get(stage, '/UsdExportMeshTest/unspecified')
self.assertEqual(m.GetSubdivisionSchemeAttr().Get(), UsdGeom.Tokens.none)
self.assertTrue(len(m.GetNormalsAttr().Get()) > 0)
# XXX: For some reason, when the mesh export used the getNormal()
# method on MItMeshFaceVertex, we would sometimes get incorrect normal
# values. Instead, we had to get all of the normals off of the MFnMesh
# and then use the iterator's normalId() method to do a lookup into the
# normals.
# This test ensures that we're getting correct normals. The mesh should
# only have normals in the x or z direction.
m = UsdGeom.Mesh.Get(stage, '/UsdExportMeshTest/TestNormalsMesh')
normals = m.GetNormalsAttr().Get()
self.assertTrue(normals)
for n in normals:
# we don't expect the normals to be pointed in the y-axis at all.
self.assertAlmostEqual(n[1], 0.0, delta=1e-4)
# make sure the other 2 values aren't both 0.
self.assertNotAlmostEqual(abs(n[0]) + abs(n[2]), 0.0, delta=1e-4)
开发者ID:JT-a,项目名称:USD,代码行数:28,代码来源:testUsdExportMesh.py
示例8: testExportWithStripAndMerge
def testExportWithStripAndMerge(self):
mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
cmds.file(mayaFilePath, new=True, force=True)
cmds.namespace(add=":foo")
cmds.namespace(add=":bar")
node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(set=":foo");
node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube2" )
cmds.namespace(set=":bar");
node3 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube3" )
cmds.namespace(set=":");
usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')
cmds.usdExport(mergeTransformAndShape=True,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
expectedPrims = ("/cube1", "/cube2", "/cube3")
for primPath in expectedPrims:
prim = stage.GetPrimAtPath(primPath)
self.assertTrue(prim.IsValid(), "Expect " + primPath)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:30,代码来源:testUsdExportStripNamespaces.py
示例9: testExportWithKindFlag
def testExportWithKindFlag(self):
"""
Tests exporting a Maya file with no USD_kind custom attributes
and using the usdExport -kind flag.
"""
cmds.file(os.path.abspath('KindTest.ma'), open=True, force=True)
cmds.loadPlugin('pxrUsd')
usdFilePath = os.path.abspath('KindTest.usda')
# Check the error mark; this ensures that we actually got a Tf error
# (that was eventually converted into a Maya error, which Maya raises
# in Python as a RuntimeError).
mark = Tf.Error.Mark()
mark.SetMark()
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
errors = mark.GetErrors()
self.assertEqual(len(errors), 1)
self.assertIn(
"</KindTest> has kind 'assembly', which is derived from 'assembly'",
str(errors[0]))
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='fakeKind')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'fakeKind'))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:34,代码来源:testUsdMayaModelKindProcessor.py
示例10: testExportWithAssemblyAndMesh
def testExportWithAssemblyAndMesh(self):
"""
Tests exporting a Maya file with a root prim containing an assembly
and a mesh.
"""
cmds.file(os.path.abspath('KindTestAssemblyAndMesh.ma'), open=True,
force=True)
cmds.loadPlugin('pxrUsd')
# Should fail due to the mesh.
usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
# Should be 'component' because of the mesh
usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath)
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'component'))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:26,代码来源:testUsdMayaModelKindProcessor.py
示例11: testExportWithClashStripping
def testExportWithClashStripping(self):
mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
cmds.file(mayaFilePath, new=True, force=True)
node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(add="foo")
cmds.namespace(set="foo");
node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(set=":");
usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')
errorRegexp = "Multiple dag nodes map to the same prim path" \
".+|cube1 - |foo:cube1.*"
with self.assertRaisesRegexp(RuntimeError, errorRegexp) as cm:
cmds.usdExport(mergeTransformAndShape=True,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
with self.assertRaisesRegexp(RuntimeError,errorRegexp) as cm:
cmds.usdExport(mergeTransformAndShape=False,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:27,代码来源:testUsdExportStripNamespaces.py
示例12: testExportWithKindAttrAndKindFlag
def testExportWithKindAttrAndKindFlag(self):
"""
Tests exporting a Maya file with both USD_kind custom attributes and
using the usdExport -kind flag; there should be an error if the USD_kind
is not derived from the kind specified in the -kind flag.
"""
cmds.file(os.path.abspath('KindTestUsdKindAttr.ma'), open=True, force=True)
cmds.loadPlugin('pxrUsd')
usdFilePath = os.path.abspath('KindTestUsdKindAttr.usda')
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='model')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'component'))
rootPrim2 = stage.GetPrimAtPath('/KindTest2')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim2).GetKind(),
'assembly'))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:27,代码来源:testUsdMayaModelKindProcessor.py
示例13: testExport
def testExport(self):
'''Tests standard usdz package export.'''
usdFile = os.path.abspath('MyAwesomePackage.usdz')
cmds.usdExport(
file=usdFile,
mergeTransformAndShape=True,
shadingMode='none')
# Lets make sure that the root layer is the first file and that all
# the references were localized ok.
zipFile = Usd.ZipFile.Open(usdFile)
fileNames = zipFile.GetFileNames()
self.assertEqual(fileNames, [
"MyAwesomePackage.usd",
"ReferenceModel.usda",
"BaseModel.usda",
"card.png"
])
# Open the usdz file up to verify that everything exported properly.
stage = Usd.Stage.Open(usdFile)
self._AssertExpectedStage(stage, "./card.png")
# Make sure there's no weird temp files sitting around.
self._AssertNoTempFiles(usdFile)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:25,代码来源:testUsdExportPackage.py
示例14: testExport
def testExport(self):
"""
Tests that the adaptor mechanism can export
USD_hidden, USD_instanceable, and USD_kind attributes by setting
the correct metadata in the output USD file.
"""
cmds.file(new=True, force=True)
usdFile = os.path.abspath('UsdAttrs.usda')
cmds.usdImport(file=usdFile, shadingMode='none')
newUsdFilePath = os.path.abspath('UsdAttrsNew.usda')
cmds.usdExport(file=newUsdFilePath, shadingMode='none')
newUsdStage = Usd.Stage.Open(newUsdFilePath)
# pCube1 and pCube2 have USD_kind.
prim1 = newUsdStage.GetPrimAtPath('/World/pCube1')
self.assertEqual(Usd.ModelAPI(prim1).GetKind(), 'potato')
prim2 = newUsdStage.GetPrimAtPath('/World/pCube2')
self.assertEqual(Usd.ModelAPI(prim2).GetKind(), 'bakedpotato')
# pCube2, pCube4, and pCube5 have USD_hidden. pCube1 and pCube3 do not.
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube2').HasAuthoredHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube4').HasAuthoredHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube5').HasAuthoredHidden())
self.assertFalse(newUsdStage.GetPrimAtPath('/World/pCube1').HasAuthoredHidden())
self.assertFalse(newUsdStage.GetPrimAtPath('/World/pCube3').HasAuthoredHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube2').IsHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube4').IsHidden())
self.assertFalse(newUsdStage.GetPrimAtPath('/World/pCube5').IsHidden())
# pCube3 and pCube4 have USD_instanceable.
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube3').IsInstanceable())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube4').IsInstanceable())
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:34,代码来源:testUsdMayaAdaptorMetadata.py
示例15: testExportToAnonymousLayer
def testExportToAnonymousLayer(self):
"""
Tests exporting to an existing anonymous layer. In normal (non-append)
mode, this should completely overwrite the contents of the anonymous
layer.
"""
cmds.file(new=True, force=True)
cmds.polyCube(name='TestCube')
stage = Usd.Stage.CreateInMemory()
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.usdExport(
file=stage.GetRootLayer().identifier,
mergeTransformAndShape=True,
shadingMode='none')
self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.rename('TestCube', 'TestThing')
cmds.usdExport(
file=stage.GetRootLayer().identifier,
mergeTransformAndShape=True,
shadingMode='none')
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:25,代码来源:testUsdExportOpenLayer.py
示例16: testExportToDiskLayer
def testExportToDiskLayer(self):
"""
Tests that exporting to an on-disk layer that is open elsewhere in the
process still works.
"""
cmds.file(new=True, force=True)
cmds.polyCube(name='TestCube')
filePath = os.path.abspath("testStage.usda")
stage = Usd.Stage.CreateNew(filePath)
stage.Save()
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.usdExport(
file=filePath,
mergeTransformAndShape=True,
shadingMode='none')
self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.rename('TestCube', 'TestThing')
cmds.usdExport(
file=filePath,
mergeTransformAndShape=True,
shadingMode='none')
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:26,代码来源:testUsdExportOpenLayer.py
示例17: testExportAsClip
def testExportAsClip(self):
"""
Test that a maya scene exports to usd the same way if it is exported
all at once, or in 5 frame clips and then stitched back together.
"""
# generate clip files and validate num samples on points attribute
clipFiles = []
# first 5 frames have no animation
usdFile = os.path.abspath('UsdExportAsClip_cube.001.usda')
clipFiles.append(usdFile)
cmds.usdExport(mergeTransformAndShape=True, file=usdFile, frameRange=(1, 5))
stage = Usd.Stage.Open(usdFile)
self._ValidateNumSamples(stage,'/world/pCube1', 'points', 1)
# next 5 frames have no animation
usdFile = os.path.abspath('UsdExportAsClip_cube.005.usda')
clipFiles.append(usdFile)
cmds.usdExport(mergeTransformAndShape=True, file=usdFile, frameRange=(5, 10))
stage = Usd.Stage.Open(usdFile)
self._ValidateNumSamples(stage, '/world/pCube1', 'points', 1)
# next 5 frames have deformation animation
usdFile = os.path.abspath('UsdExportAsClip_cube.010.usda')
clipFiles.append(usdFile)
frames = (10, 15)
cmds.usdExport(mergeTransformAndShape=True, file=usdFile, frameRange=frames)
stage = Usd.Stage.Open(usdFile)
self._ValidateNumSamples(stage, '/world/pCube1', 'points', frames[1] + 1 - frames[0])
# next 5 frames have no animation
usdFile = os.path.abspath('UsdExportAsClip_cube.015.usda')
clipFiles.append(usdFile)
cmds.usdExport(mergeTransformAndShape=True, file=usdFile, frameRange=(15, 20))
stage = Usd.Stage.Open(usdFile)
self._ValidateNumSamples(stage, '/world/pCube1', 'points', 1)
stitchedPath = os.path.abspath('result.usda')
stitchedLayer = Sdf.Layer.CreateNew(stitchedPath)
UsdUtils.StitchClips(stitchedLayer, clipFiles, '/world', 1, 20, 'default')
# export a non clip version for comparison
canonicalUsdFile = os.path.abspath('canonical.usda')
cmds.usdExport(mergeTransformAndShape=True, file=canonicalUsdFile, frameRange=(1, 20))
print 'comparing: \nnormal: {}\nstitched: {}'.format(canonicalUsdFile, stitchedPath)
canonicalStage = Usd.Stage.Open(canonicalUsdFile)
clipsStage = Usd.Stage.Open(stitchedPath)
# visible
self._ValidateSamples(canonicalStage, clipsStage, '/world/pCube1', 'visibility', (0, 21))
# animated visibility
self._ValidateSamples(canonicalStage, clipsStage, '/world/pCube2', 'visibility', (0, 21))
# hidden, non animated:
self._ValidateSamples(canonicalStage, clipsStage, '/world/pCube4', 'visibility', (0, 21))
# constant points:
self._ValidateSamples(canonicalStage, clipsStage, '/world/pCube2', 'points', (0, 21))
# blend shape driven animated points:
self._ValidateSamples(canonicalStage, clipsStage, '/world/pCube3', 'points', (0, 21))
# animated points:
self._ValidateSamples(canonicalStage, clipsStage, '/world/pCube1', 'points', (0, 21))
开发者ID:rodeofx,项目名称:USD,代码行数:59,代码来源:testUsdExportAsClip.py
示例18: testSkelTransforms
def testSkelTransforms(self):
"""
Tests that the computed joint transforms in USD, when tarnsformed into
world space, match the world space transforms of the Maya joints.
"""
cmds.file(os.path.abspath('UsdExportSkeleton.ma'),
open=True, force=True)
# frameRange = [1, 30]
frameRange = [1, 3]
# TODO: The joint hierarchy intentionally includes non-joint nodes,
# which are expected to be ignored. However, when we try to extract
# restTransforms from the dagPose, the intermediate transforms cause
# problems, since they are not members of the dagPose. As a result,
# no dag pose is exported. Need to come up with a way to handle this
# correctly in export.
print "Expect warnings about invalid restTransforms"
usdFile = os.path.abspath('UsdExportSkeleton.usda')
cmds.usdExport(mergeTransformAndShape=True, file=usdFile,
shadingMode='none', frameRange=frameRange,
exportSkels='auto')
stage = Usd.Stage.Open(usdFile)
root = UsdSkel.Root.Get(stage, '/SkelChar')
self.assertTrue(root)
skelCache = UsdSkel.Cache()
skelCache.Populate(root)
skel = UsdSkel.Skeleton.Get(stage, '/SkelChar/Hips')
self.assertTrue(skel)
skelQuery = skelCache.GetSkelQuery(skel)
self.assertTrue(skelQuery)
xfCache = UsdGeom.XformCache()
for frame in xrange(*frameRange):
cmds.currentTime(frame, edit=True)
xfCache.SetTime(frame)
skelLocalToWorld = xfCache.GetLocalToWorldTransform(skelQuery.GetPrim())
usdJointXforms = skelQuery.ComputeJointSkelTransforms(frame)
for joint,usdJointXf in zip(skelQuery.GetJointOrder(),
usdJointXforms):
usdJointWorldXf = usdJointXf * skelLocalToWorld
selList = OM.MSelectionList()
selList.add(Sdf.Path(joint).name)
dagPath = selList.getDagPath(0)
mayaJointWorldXf = Gf.Matrix4d(*dagPath.inclusiveMatrix())
self.assertTrue(Gf.IsClose(mayaJointWorldXf,
usdJointWorldXf, 1e-5))
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:59,代码来源:testUsdExportSkeleton.py
示例19: testExportNoParentScope
def testExportNoParentScope(self):
usdFile = os.path.abspath('UsdExportParentScope_testNoParentScope.usda')
cmds.usdExport(mergeTransformAndShape=False, exportInstances=False,
shadingMode='none', file=usdFile, frameRange=(1, 1))
stage = Usd.Stage.Open(usdFile)
p = UsdGeom.Mesh.Get(stage, '/pSphere1/pSphereShape1')
self.assertTrue(p.GetPrim().IsValid())
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:9,代码来源:testUsdExportParentScope.py
示例20: _GetUsdStage
def _GetUsdStage(self, testName):
usdFilePath = os.path.abspath('%s.usda' % testName)
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
shadingMode='none',
exportDisplayColor=True,
exportUVs=False)
self._stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(self._stage)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:10,代码来源:testUsdExportColorSets.py
注:本文中的maya.cmds.usdExport函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论