22 const pxr::SdfPath &prototype_root)
24 return pxr::HdInstancedBySchema::Builder()
26 pxr::HdRetainedTypedSampledDataSource<pxr::VtArray<pxr::SdfPath>>::New({instancer_path}))
28 pxr::HdRetainedTypedSampledDataSource<pxr::VtArray<pxr::SdfPath>>::New({prototype_root}))
35 const pxr::VtMatrix4dArray &transforms)
37 pxr::VtArray<pxr::SdfPath> proto_array(prototypes.
begin(), prototypes.
end());
43 for (
const pxr::VtIntArray &indices : instance_indices) {
44 idx_values.
append(pxr::HdRetainedTypedSampledDataSource<pxr::VtIntArray>::New(indices));
46 pxr::HdVectorDataSourceHandle indices_ds = pxr::HdRetainedSmallVectorDataSource::New(
47 idx_values.
size(), idx_values.
data());
49 pxr::HdContainerDataSourceHandle topology =
50 pxr::HdInstancerTopologySchema::Builder()
52 pxr::HdRetainedTypedSampledDataSource<pxr::VtArray<pxr::SdfPath>>::New(proto_array))
53 .SetInstanceIndices(indices_ds)
57 pxr::HdContainerDataSourceHandle xforms_primvar =
58 pxr::HdPrimvarSchema::Builder()
60 pxr::HdRetainedTypedSampledDataSource<pxr::VtMatrix4dArray>::New(transforms))
61 .SetInterpolation(pxr::HdPrimvarSchema::BuildInterpolationDataSource(
62 pxr::HdPrimvarSchemaTokens->instance))
63 .SetRole(pxr::HdPrimvarSchema::BuildRoleDataSource(pxr::HdPrimvarRoleTokens->none))
65 pxr::HdContainerDataSourceHandle primvars = pxr::HdRetainedContainerDataSource::New(
66 pxr::HdInstancerTokens->instanceTransforms, xforms_primvar);
68 pxr::HdContainerDataSourceHandle xform =
69 pxr::HdXformSchema::Builder()
71 pxr::HdRetainedTypedSampledDataSource<pxr::GfMatrix4d>::New(pxr::GfMatrix4d(1.0)))
72 .SetResetXformStack(pxr::HdRetainedTypedSampledDataSource<bool>::New(
true))
76 b.add(pxr::HdInstancerTopologySchema::GetSchemaToken(), topology);
77 b.add(pxr::HdPrimvarsSchema::GetSchemaToken(), primvars);
78 b.add(pxr::HdXformSchema::GetSchemaToken(), xform);