I’m quite new with usd and I’m learning the sdk with c++.
Let’s say I have my Gprim like USDPluginExamples/src/usdTri at main · wetadigital/USDPluginExamples · GitHub
In my mind ( I expected at least ) there was a mechanism a callback system or an instancing system during the loading of a stage that automatically build the types based on plugin loaded. In few words: during the loading if a usd triangle is loaded let’s instanciate UsdTriTriangle with the primitive.
For sure I’m wrong so if I need to do stuff with my gprim during the loading the only way is?
UsdStageRefPtr stage = UsdStage::Open(__path__);
for (UsdPrim prim : stage->TraverseAll())
{
if (prim.IsA<UsdTriTriangle>())
{
UsdTriTriangle tri(prim);
// do your stuff based prim attirbutes
}
}
Hi @gennz , When Opened, a UsdStage will contain a complete “type definition” for all primTypes defined in plugins. However, C++ schema objects for USD prim types are entirely optional (you can search on “codeless schemas”). Further, given that those schema objects may not capture a prim’s complete definition (e.g. because it may have many applied schemas, as well), there is no single C++ schema object that could be pre-manufactured that would satisfy the needs of all consumers.
So we make a clean break between the generic data containers that populate the stage (UsdPrim) which contain the type information for the full prim definition – but do not instantiate any objects based on it – and code-based schema objects provided by schema plugins. This way:
A UsdStage remains lighter and simpler
Each client gets to decide and instantiate only the schema objects required for its needs