def test_RoundTripHermite(self): time = Usd.TimeCode.EarliestTime() prim = self.stage.GetPrimAtPath('/Cubic/Ribbons/VaryingWidth') schema = UsdGeom.HermiteCurves(prim) # Interpolation metadata normalsInterpolation = schema.GetNormalsInterpolation() widthsInterpolation = schema.GetWidthsInterpolation() self.assertEqual(normalsInterpolation, UsdGeom.Tokens.varying) self.assertEqual(widthsInterpolation, UsdGeom.Tokens.varying) # These attributes may be varying time sampled curveVertexCounts = schema.GetCurveVertexCountsAttr().Get(time) points = schema.GetPointsAttr().Get(time) tangents = schema.GetTangentsAttr().Get(time) widths = schema.GetWidthsAttr().Get(time) normals = schema.GetNormalsAttr().Get(time) self._assertElementsAlmostEqual(points, [(0, 0, 0), (1, 1, 0), (2, 0, 0)]) self._assertElementsAlmostEqual(tangents, [(0, 1, 0), (1, 0, 0), (0, -1, 0)]) self._assertElementsAlmostEqual(widths, [0, .5, 0]) self._assertElementsAlmostEqual(normals, [(0, 0, 1), (0, 0, 1), (0, 0, 1)]) self.assertEqual(list(curveVertexCounts), [3])
def test_RoundTripHermiteWithVelocities(self): """Round tripping velocities is ambiguous""" time = Usd.TimeCode.EarliestTime() prim = self.stage.GetPrimAtPath('/Cubic/Tubes/WithVelocities') schema = UsdGeom.HermiteCurves(prim) # Interpolation metadata widthsInterpolation = schema.GetWidthsInterpolation() self.assertEqual(widthsInterpolation, UsdGeom.Tokens.varying) # These attributes may be varying time sampled curveVertexCounts = schema.GetCurveVertexCountsAttr().Get(time) points = schema.GetPointsAttr().Get(time) velocities = schema.GetVelocitiesAttr().Get(time) tangents = schema.GetTangentsAttr().Get(time) widths = schema.GetWidthsAttr().Get(time) self._assertElementsAlmostEqual(points, [(0, 0, 0), (1, 1, 0)]) self._assertElementsAlmostEqual(tangents, [(0, 1, 0), (1, 0, 0)]) self._assertElementsAlmostEqual(widths, [0, .5]) self._assertEmpty(velocities) self.assertEqual(list(curveVertexCounts), [2])