Exemplo n.º 1
0
 def test_XformOpOperators(self):
     s = Usd.Stage.CreateInMemory()
     rootXform = UsdGeom.Xform.Define(s, "/Root")
     translateOp = rootXform.AddTranslateOp()
     scaleOp = rootXform.AddScaleOp()
     self.assertFalse(UsdGeom.XformOp())
     self.assertTrue(translateOp)
     self.assertTrue(scaleOp)
     xformOps = rootXform.GetOrderedXformOps()
     self.assertEqual(xformOps, [translateOp, scaleOp])
     xformOps.remove(translateOp)
     self.assertEqual(xformOps, [scaleOp])
Exemplo n.º 2
0
    def test_InvalidXformOps(self):
        s = Usd.Stage.CreateInMemory()
        p = s.DefinePrim('/World', 'Xform')
        x = UsdGeom.Xformable(p)

        # Create an attribute that is not in the xformOp namespace.
        attr1 = p.CreateAttribute("myXformOp:transform", Sdf.ValueTypeNames.Matrix4d)
        self._TestInvalidXformOp(attr1)

        # Create an xform op with an invalid optype.
        attr2 = p.CreateAttribute("xformOp:translateXYZ", Sdf.ValueTypeNames.Double3)
        self._TestInvalidXformOp(attr2)

        # Create an xform op with opType=transform and typeName=Matrix4f.
        with self.assertRaises(RuntimeError):
            xformOp = x.AddTransformOp(precision=UsdGeom.XformOp.PrecisionFloat)

        # Test Validity of XformOp with no attr
        xformOp = UsdGeom.XformOp(Usd.Attribute())
        self.assertFalse(xformOp.IsDefined())
        self.assertFalse(bool(xformOp))
Exemplo n.º 3
0
            def checkParentDone():
                # The xform now has the capsule as its child.
                xformChildren = xformHier.children()
                self.assertEqual(len(xformChildren), 1)
                self.assertIn('Capsule1', childrenNames(xformChildren))

                # Confirm that the capsule has not moved in world space.  Must
                # re-create the prim and its scene item after path change.
                capsulePath = ufe.Path([
                    proxyShapePathSegment,
                    usdUtils.createUfePathSegment('/Xform1/Capsule1')
                ])
                capsulePrim = mayaUsd.ufe.ufePathToPrim(
                    ufe.PathString.string(capsulePath))
                capsuleXformable = UsdGeom.Xformable(capsulePrim)
                capsuleItem = ufe.Hierarchy.createItem(capsulePath)
                capsuleT3d = ufe.Transform3d.transform3d(capsuleItem)
                capsuleWorld = capsuleT3d.inclusiveMatrix()
                assertVectorAlmostEqual(self, capsuleWorldPre,
                                        matrixToList(capsuleWorld))

                # No change in the capsule's transform ops.
                self.assertEqual(capsuleXformable.GetXformOpOrderAttr().Get(),
                                 Vt.TokenArray(matrixOps))

                # Matrix ops that were not targeted did not change.
                for checkMatrixOp in matrixOps:
                    if checkMatrixOp == matrixOp:
                        continue
                    op = UsdGeom.XformOp(
                        capsulePrim.GetAttribute(checkMatrixOp))
                    self.assertEqual(
                        op.GetOpTransform(
                            mayaUsd.ufe.getTime(
                                ufe.PathString.string(capsulePath))),
                        matrixValues[checkMatrixOp])
Exemplo n.º 4
0
 def _TestInvalidXformOp(self, attr):
     with self.assertRaises(RuntimeError):
         op = UsdGeom.XformOp(attr, isInverseOp=False)