24 #ifndef PXR_IMAGING_HD_UNIT_TEST_DELEGATE_H
25 #define PXR_IMAGING_HD_UNIT_TEST_DELEGATE_H
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/material.h"
30 #include "pxr/imaging/hd/sceneDelegate.h"
31 #include "pxr/imaging/hd/tokens.h"
44 PXR_NAMESPACE_OPEN_SCOPE
57 void SetUseInstancePrimvars(
bool v) { _hasInstancePrimvars = v; }
60 void SetRefineLevel(
int level);
63 void SetVisibility(
bool vis);
68 void AddMesh(
SdfPath const&
id);
73 VtVec3fArray
const &points,
74 VtIntArray
const &numVerts,
75 VtIntArray
const &verts,
78 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark,
79 TfToken const &orientation=HdTokens->rightHanded,
80 bool doubleSided=
false);
85 VtVec3fArray
const &points,
86 VtIntArray
const &numVerts,
87 VtIntArray
const &verts,
88 VtIntArray
const &holes,
91 HdInterpolation colorInterpolation,
93 HdInterpolation opacityInterpolation,
96 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark,
97 TfToken const &orientation=HdTokens->rightHanded,
98 bool doubleSided=
false);
101 void AddMesh(
SdfPath const &
id,
103 VtVec3fArray
const &points,
104 VtIntArray
const &numVerts,
105 VtIntArray
const &verts,
106 VtIntArray
const &holes,
109 VtIntArray
const &colorIndices,
110 HdInterpolation colorInterpolation,
112 VtIntArray
const &opacityIndices,
113 HdInterpolation opacityInterpolation,
116 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark,
117 TfToken const &orientation=HdTokens->rightHanded,
118 bool doubleSided=
false);
124 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark);
129 bool rightHanded=
true,
bool doubleSided=
false,
136 bool rightHanded=
true,
bool doubleSided=
false,
143 bool rightHanded=
true,
bool doubleSided=
false,
150 bool rightHanded=
true,
bool doubleSided=
false,
155 void AddGridWithCustomColor(
SdfPath const &
id,
int nx,
int ny,
158 HdInterpolation colorInterpolation,
159 bool rightHanded=
true,
bool doubleSided=
false,
165 HdInterpolation colorInterp,
183 void AddBasisCurves(
SdfPath const &
id,
184 VtVec3fArray
const &points,
185 VtIntArray
const &curveVertexCounts,
186 VtVec3fArray
const &normals,
190 HdInterpolation colorInterpolation,
192 HdInterpolation opacityInterpolation,
194 HdInterpolation widthInterpolation,
201 HdInterpolation colorInterp=HdInterpolationConstant,
202 HdInterpolation widthInterp=HdInterpolationConstant,
203 bool authoredNormals=
false,
207 void AddPoints(
SdfPath const &
id,
208 VtVec3fArray
const &points,
210 HdInterpolation colorInterpolation,
212 HdInterpolation opacityInterpolation,
214 HdInterpolation widthInterpolation,
219 void AddPoints(
SdfPath const &
id,
221 HdInterpolation colorInterp=HdInterpolationConstant,
222 HdInterpolation widthInterp=HdInterpolationConstant,
232 void SetInstancerProperties(
SdfPath const &
id,
233 VtIntArray
const &prototypeIndex,
234 VtVec3fArray
const &scale,
235 VtVec4fArray
const &rotate,
236 VtVec3fArray
const &translate);
239 void UpdateInstancer(
SdfPath const& rprimId,
SdfPath const& instancerId);
246 HdInterpolation
const& interp,
248 VtIntArray
const& indices=VtIntArray(0));
251 void UpdatePrimvarValue(
SdfPath const&
id,
254 VtIntArray
const& indices=VtIntArray(0));
274 void BindMaterial(
SdfPath const &rprimId,
SdfPath const &materialId);
283 HdFormat format,
bool multiSampled);
295 _tasks[id] = _Task();
310 void HideRprim(
SdfPath const &
id);
314 void UnhideRprim(
SdfPath const &
id);
322 void SetRefineLevel(
SdfPath const &
id,
int refineLevel);
326 void SetVisibility(
SdfPath const &
id,
bool vis);
333 void UpdatePositions(
SdfPath const &
id,
float time);
335 void UpdateRprims(
float time);
337 void UpdateInstancerPrimvars(
float time);
339 void UpdateInstancerPrototypes(
float time);
341 void UpdateCurvePrimvarsInterpMode(
float time);
347 GfVec3f PopulateBasicTestSet();
349 GfVec3f PopulateInvalidPrimsSet();
377 VtIntArray *outIndices)
override;
381 virtual HdPrimvarDescriptorVector
383 HdInterpolation interpolation)
override;
387 SdfPath const& prototypeId)
override;
400 virtual VtValue GetMaterialResource(
SdfPath const &materialId)
override;
404 TfToken const ¶mName)
override;
424 VtVec3fArray
const &points,
425 VtIntArray
const &numVerts,
426 VtIntArray
const &verts,
427 VtIntArray
const &holes,
431 scheme(scheme), orientation(orientation),
432 transform(transform),
433 points(points), numVerts(numVerts), verts(verts),
434 holes(holes), subdivTags(subdivTags), guide(guide),
435 doubleSided(doubleSided) { }
451 _Curves(VtVec3fArray
const &points,
452 VtIntArray
const &curveVertexCounts,
455 points(points), curveVertexCounts(curveVertexCounts),
456 type(type), basis(basis) { }
459 VtIntArray curveVertexCounts;
465 _Points(VtVec3fArray
const &points) : points(points) { }
471 _Instancer(VtVec3fArray
const &scale,
472 VtVec4fArray
const &rotate,
473 VtVec3fArray
const &translate,
475 scale(scale), rotate(rotate), translate(translate),
476 rootTransform(rootTransform) {
480 VtVec3fArray translate;
481 VtIntArray prototypeIndices;
484 std::vector<SdfPath> prototypes;
490 HdInterpolation
const& _interp,
492 VtIntArray
const& _indices=VtIntArray(0)) :
501 HdInterpolation interp;
505 using _Primvars = std::vector<_Primvar>;
508 bool _FindPrimvar(
SdfPath const&
id,
510 _Primvars::iterator *pvIt);
521 struct _RenderBuffer {
523 _RenderBuffer(
GfVec3i const &d, HdFormat f,
bool ms)
524 : dims(d), format(f), multiSampled(ms) {}
530 std::map<SdfPath, _Mesh> _meshes;
531 std::map<SdfPath, _Curves> _curves;
532 std::map<SdfPath, _Points> _points;
533 std::map<SdfPath, _Instancer> _instancers;
534 std::map<SdfPath, _Primvars> _primvars;
535 std::map<SdfPath, VtValue> _materials;
536 std::map<SdfPath, _Camera> _cameras;
537 std::map<SdfPath, _RenderBuffer> _renderBuffers;
538 std::map<SdfPath, _Light> _lights;
539 std::map<SdfPath, _Task> _tasks;
540 TfHashSet<SdfPath, SdfPath::Hash> _hiddenRprims;
542 typedef std::map<SdfPath, SdfPath> SdfPathMap;
543 SdfPathMap _materialBindings;
544 SdfPathMap _instancerBindings;
546 bool _hasInstancePrimvars;
549 std::map<SdfPath, int> _refineLevels;
550 std::map<SdfPath, bool> _visibilities;
554 PXR_NAMESPACE_CLOSE_SCOPE
556 #endif // PXR_IMAGING_HD_UNIT_TEST_DELEGATE_H
HD_API void AddGridWithFaceVaryingColor(SdfPath const &id, int x, int y, GfMatrix4f const &transform, bool rightHanded=true, bool doubleSided=false, SdfPath const &instancerId=SdfPath())
Add a grid with division x*y.
Stores a 4x4 matrix of float elements.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Basic type: 3-dimensional floating point range.
HD_API void RebindMaterial(SdfPath const &rprimId, SdfPath const &materialId)
Example to update a material binding on the fly.
HD_API void AddCurves(SdfPath const &id, TfToken const &type, TfToken const &basis, GfMatrix4f const &transform, HdInterpolation colorInterp=HdInterpolationConstant, HdInterpolation widthInterp=HdInterpolationConstant, bool authoredNormals=false, SdfPath const &instancerId=SdfPath())
Add a basis curves prim containing two curves.
HD_API void AddSubdiv(SdfPath const &id, GfMatrix4f const &transform, SdfPath const &insatancerId=SdfPath())
Add a subdiv with various tags.
Describes how the geometry of a prim should be displayed.
virtual HD_API GfMatrix4d GetTransform(SdfPath const &id) override
Returns the object space transform, including all parent transforms.
virtual HD_API VtValue Get(SdfPath const &id, TfToken const &key) override
Returns a named value.
virtual HD_API HdMeshTopology GetMeshTopology(SdfPath const &id) override
Gets the topological mesh data for a given prim.
HD_API void AddCamera(SdfPath const &id)
Camera.
A map with string keys and VtValue values.
Describes the allocation structure of a render buffer bprim.
virtual HD_API VtValue GetIndexedPrimvar(SdfPath const &id, TfToken const &key, VtIntArray *outIndices) override
Returns a named primvar value.
Basic type for a vector of 3 float components.
virtual HD_API HdRenderBufferDescriptor GetRenderBufferDescriptor(SdfPath const &id) override
Returns the allocation descriptor for a given render buffer prim.
virtual HD_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id) override
Gets the topological curve data for a given prim.
virtual HD_API bool GetDoubleSided(SdfPath const &id) override
Returns the doubleSided state for the given prim.
HD_API void UpdateMaterialResource(SdfPath const &materialId, VtValue materialResource)
Update a material resource.
HD_API void AddGridWithFaceColor(SdfPath const &id, int x, int y, GfMatrix4f const &transform, bool rightHanded=true, bool doubleSided=false, SdfPath const &instancerId=SdfPath())
Add a grid with division x*y.
HD_API void AddGridWithVertexColor(SdfPath const &id, int x, int y, GfMatrix4f const &transform, bool rightHanded=true, bool doubleSided=false, SdfPath const &instancerId=SdfPath())
Add a grid with division x*y.
virtual HD_API SdfPath GetInstancerId(SdfPath const &primId) override
Returns the parent instancer of the given rprim or instancer.
HD_API void AddCube(SdfPath const &id, GfMatrix4f const &transform, bool guide=false, SdfPath const &instancerId=SdfPath(), TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark)
Add a cube.
Token for efficient comparison, assignment, and hashing of known strings.
HD_API void MarkRprimDirty(SdfPath path, HdDirtyBits flag)
Marks an rprim in the RenderIndex as dirty with the given dirty flags.
virtual HD_API PxOsdSubdivTags GetSubdivTags(SdfPath const &id) override
Gets the subdivision surface tags (sharpness, holes, etc).
Stores a 4x4 matrix of double elements.
Adapter class providing data exchange with the client scene graph.
HD_API void AddPolygons(SdfPath const &id, GfMatrix4f const &transform, HdInterpolation colorInterp, SdfPath const &instancerId=SdfPath())
Add a triangle, quad and pentagon.
HD_API void AddGrid(SdfPath const &id, int x, int y, GfMatrix4f const &transform, bool rightHanded=true, bool doubleSided=false, SdfPath const &instancerId=SdfPath())
Add a grid with division x*y.
Basic type for a vector of 3 int components.
HD_API void AddInstancer(SdfPath const &id, SdfPath const &parentId=SdfPath(), GfMatrix4f const &rootTransform=GfMatrix4f(1))
Instancer.
A path value used to locate objects in layers or scenegraphs.
virtual HD_API HdReprSelector GetReprSelector(SdfPath const &id) override
Returns the authored repr (if any) for the given prim.
HD_API void AddRenderBuffer(SdfPath const &id, GfVec3i const &dims, HdFormat format, bool multiSampled)
Render buffers.
Topology data for basisCurves.
virtual HD_API HdDisplayStyle GetDisplayStyle(SdfPath const &id) override
Returns the refinement level for the given prim in the range [0,8].
virtual HD_API HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolation) override
Returns descriptors for all primvars of the given interpolation type.
HD_API void AddMaterialResource(SdfPath const &id, VtValue materialResource)
Material.
virtual HD_API SdfPath GetMaterialId(SdfPath const &rprimId) override
Returns the material ID bound to the rprim rprimId.
virtual HD_API TfToken GetRenderTag(SdfPath const &id) override
Returns the render tag that will be used to bucket prims during render pass bucketing.
This file defines some macros that are useful for declaring and using static TfTokens.
Describes one or more authored display representations for an rprim.
virtual HD_API bool GetVisible(SdfPath const &id) override
Returns the authored visible state of the prim.
HD_API void Remove(SdfPath const &id)
Remove a prim.
virtual HD_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId) override
Returns the instancer transform.
HD_API void Clear()
Clear all prims.
virtual HD_API VtValue GetCameraParamValue(SdfPath const &cameraId, TfToken const ¶mName) override
Returns a single value for a given camera and parameter.
virtual HD_API GfRange3d GetExtent(SdfPath const &id) override
Gets the axis aligned bounds of a prim.
void AddTask(SdfPath const &id)
Tasks.
HD_API void UpdateTransform(SdfPath const &id, GfMatrix4f const &mat)
Transform.
void InsertTask(HdSceneDelegate *delegate, SdfPath const &id)
Inserts a new task into the render index with an identifier of id.
HD_API void AddFaceVaryingPolygons(SdfPath const &id, GfMatrix4f const &transform, SdfPath const &instancerId=SdfPath())
Add a triangle, quad and pentagon with face-varying displayColor and displayOpacity.
Topology data for meshes.
HdRenderIndex & GetRenderIndex()
Returns the RenderIndex owned by this delegate.
A simple delegate class for unit test driver.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
HD_API void AddPrimvar(SdfPath const &id, TfToken const &name, VtValue const &value, HdInterpolation const &interp, TfToken const &role, VtIntArray const &indices=VtIntArray(0))
Primvars.
virtual HD_API VtIntArray GetInstanceIndices(SdfPath const &instancerId, SdfPath const &prototypeId) override
Gets the extracted indices array of the prototype id used in the instancer.