/// <summary> /// Retuns a dictionary of paths and the times at which each path has a keyframe for the given /// attribute. Only paths rooted under the given rootPath are considered. /// </summary> public Dictionary <string, double[]> ComputeKeyFrames(string rootPath, string attribute) { var keys = new Dictionary <string, double[]>(); var prim = GetUsdPrim(GetSdfPath(rootPath)); if (!prim) { throw new ArgumentException("rootPath does not exist"); } var sdfRootPath = GetSdfPath(rootPath); var tfAttrName = new pxr.TfToken(attribute); foreach (var child in Stage.GetAllPrims()) { if (child.GetPath() == SdfPath.AbsoluteRootPath()) { Console.WriteLine("Was abs: {0}", child.GetPath()); continue; } if (child.GetTypeName() != "Mesh") { continue; } Console.WriteLine(child.GetPath()); if (!child.GetPath().HasPrefix(sdfRootPath)) { continue; } var stdDoubleVector = child.GetAttribute(tfAttrName).GetTimeSamples(); if (stdDoubleVector.Count == 0) { continue; } double[] times = new double[stdDoubleVector.Count]; stdDoubleVector.CopyTo(times); keys.Add(child.GetPath(), times); } return(keys); }
/// <summary> /// Searches the USD Stage to find prims which either match the schema type name or those /// which are derived from it. /// </summary> /// <typeparam name="T"> /// A type which inherits from SampleBase, adorned with a UsdSchemaAttribute. /// </typeparam> /// <returns> /// Returns a collection which will read each prim found and return the requested SampleBase /// object type. /// </returns> /// <remarks>Internally, this method reuses a single object while reading to minimize garbage /// generated during iteration.</remarks> public SampleCollection <T> ReadAll <T>() where T : SampleBase, new() { return(ReadAll <T>(rootPath: SdfPath.AbsoluteRootPath())); }
/// <summary> /// Searches the USD Stage to find prims which either match the schema type name declared /// for the given sample type, or those which derive from it. /// </summary> /// <typeparam name="T"> /// A type which inherits from SampleBase, adorned with a UsdSchemaAttribute. /// </typeparam> /// <returns> /// An iterable collection of the paths discovered /// </returns> public SdfPath[] Find <T>() where T : SampleBase, new() { return(Find <T>(rootPath: SdfPath.AbsoluteRootPath())); }