def testExportSkin_Posed(self): """ Checks that the skeletal skinning works when the skeleton is exported in a non-rest pose. """ cmds.currentTime(1, edit=True) usdFile = os.path.abspath('UsdExportMesh_skelPosed.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFile, shadingMode='none', exportSkin='explicit') usdFileNoSkin = os.path.abspath('UsdExportMesh_skelPosed_noskin.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFileNoSkin, shadingMode='none', exportSkin='none') stage = Usd.Stage.Open(usdFile) stageNS = Usd.Stage.Open(usdFileNoSkin) m = UsdGeom.Mesh.Get(stage, '/ExplicitSkelRoot/mesh') mNS = UsdGeom.Mesh.Get(stageNS, '/ExplicitSkelRoot/mesh') # Check Maya's output mesh versus the UsdSkel-computed result. skelRoot = UsdSkel.Root.Get(stage, '/ExplicitSkelRoot') UsdSkel.BakeSkinningLBS(skelRoot) points = m.GetPointsAttr().Get() refSkinnedPoints = mNS.GetPointsAttr().Get() self._AssertVec3fArrayAlmostEqual(points, refSkinnedPoints)
def testExportSkin_AnimatedSkeleton(self): """ Checks that the skeletal skinning works when the skeleton is animated. """ cmds.currentTime(1, edit=True) usdFile = os.path.abspath('UsdExportMesh_skelAnim.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFile, shadingMode='none', exportSkin='auto', frameRange=[1, 30]) usdFileNoSkin = os.path.abspath('UsdExportMesh_skelAnim_noskin.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFileNoSkin, shadingMode='none', exportSkin='none', frameRange=[1, 30]) stage = Usd.Stage.Open(usdFile) stageNS = Usd.Stage.Open(usdFileNoSkin) restPoints = Vt.Vec3fArray([(-0.5, -1, 0.5), (0.5, -1, 0.5), (-0.5, 0, 0.5), (0.5, 0, 0.5), (-0.5, 1, 0.5), (0.5, 1, 0.5), (-0.5, 1, -0.5), (0.5, 1, -0.5), (-0.5, 0, -0.5), (0.5, 0, -0.5), (-0.5, -1, -0.5), (0.5, -1, -0.5)]) m = UsdGeom.Mesh.Get(stage, '/ImplicitSkelRoot/animatedCube') self.assertEqual(m.GetPointsAttr().Get(1.0), restPoints) mNS = UsdGeom.Mesh.Get(stageNS, '/ImplicitSkelRoot/animatedCube') self._AssertVec3fArrayAlmostEqual(mNS.GetPointsAttr().Get(1.0), restPoints) # Check Maya's output mesh versus the UsdSkel-computed result. skelRoot = UsdSkel.Root.Get(stage, '/ImplicitSkelRoot') UsdSkel.BakeSkinningLBS(skelRoot) for i in xrange(1, 31): points = m.GetPointsAttr().Get(i) refSkinnedPoints = mNS.GetPointsAttr().Get(i) self._AssertVec3fArrayAlmostEqual(points, refSkinnedPoints)
def testExportSkin(self): """ Sanity check -- no animation, posed in rest pose. The skinning result should match the original mesh. """ cmds.currentTime(1, edit=True) usdFile = os.path.abspath('UsdExportMesh_skel.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFile, shadingMode='none', exportSkin='auto') usdFileNoSkin = os.path.abspath('UsdExportMesh_skel_noskin.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFileNoSkin, shadingMode='none', exportSkin='none') stage = Usd.Stage.Open(usdFile) stageNS = Usd.Stage.Open(usdFileNoSkin) restPoints = Vt.Vec3fArray([(-0.5, -1, 0.5), (0.5, -1, 0.5), (-0.5, 0, 0.5), (0.5, 0, 0.5), (-0.5, 1, 0.5), (0.5, 1, 0.5), (-0.5, 1, -0.5), (0.5, 1, -0.5), (-0.5, 0, -0.5), (0.5, 0, -0.5), (-0.5, -1, -0.5), (0.5, -1, -0.5)]) m = UsdGeom.Mesh.Get(stage, '/ImplicitSkelRoot/animatedCube') self.assertEqual(m.GetPointsAttr().Get(), restPoints) mNS = UsdGeom.Mesh.Get(stageNS, '/ImplicitSkelRoot/animatedCube') self._AssertVec3fArrayAlmostEqual(mNS.GetPointsAttr().Get(), restPoints) # Check Maya's output mesh versus the UsdSkel-computed result. skelRoot = UsdSkel.Root.Get(stage, '/ImplicitSkelRoot') UsdSkel.BakeSkinningLBS(skelRoot) points = m.GetPointsAttr().Get() refSkinnedPoints = mNS.GetPointsAttr().Get() self._AssertVec3fArrayAlmostEqual(points, refSkinnedPoints)