7#ifndef PXR_IMAGING_HD_UNIT_TEST_DELEGATE_H
8#define PXR_IMAGING_HD_UNIT_TEST_DELEGATE_H
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/enums.h"
13#include "pxr/imaging/hd/material.h"
14#include "pxr/imaging/hd/sceneDelegate.h"
15#include "pxr/imaging/hd/tokens.h"
28PXR_NAMESPACE_OPEN_SCOPE
42 void SetUseInstancePrimvars(
bool v) { _hasInstancePrimvars = v; }
45 void SetRefineLevel(
int level);
48 void SetVisibility(
bool vis);
53 void AddMesh(
SdfPath const&
id);
58 VtVec3fArray
const &points,
59 VtIntArray
const &numVerts,
60 VtIntArray
const &verts,
63 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark,
64 TfToken const &orientation=HdTokens->rightHanded,
65 bool doubleSided=
false);
70 VtVec3fArray
const &points,
71 VtIntArray
const &numVerts,
72 VtIntArray
const &verts,
73 VtIntArray
const &holes,
76 HdInterpolation colorInterpolation,
78 HdInterpolation opacityInterpolation,
81 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark,
82 TfToken const &orientation=HdTokens->rightHanded,
83 bool doubleSided=
false);
88 VtVec3fArray
const &points,
89 VtIntArray
const &numVerts,
90 VtIntArray
const &verts,
91 VtIntArray
const &holes,
94 VtIntArray
const &colorIndices,
95 HdInterpolation colorInterpolation,
97 VtIntArray
const &opacityIndices,
98 HdInterpolation opacityInterpolation,
101 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark,
102 TfToken const &orientation=HdTokens->rightHanded,
103 bool doubleSided=
false);
106 void SetMeshCullStyle(
SdfPath const &
id, HdCullStyle
const &cullstyle);
112 TfToken const &scheme=PxOsdOpenSubdivTokens->catmullClark);
117 VtValue const &color, HdInterpolation colorInterpolation,
118 VtValue const &opacity, HdInterpolation opacityInterpolation);
123 bool rightHanded=
true,
bool doubleSided=
false,
130 bool rightHanded=
true,
bool doubleSided=
false,
137 bool rightHanded=
true,
bool doubleSided=
false,
144 bool rightHanded=
true,
bool doubleSided=
false,
149 void AddGridWithCustomColor(
SdfPath const &
id,
int nx,
int ny,
152 HdInterpolation colorInterpolation,
153 bool rightHanded=
true,
bool doubleSided=
false,
159 HdInterpolation colorInterp,
177 void AddBasisCurves(
SdfPath const &
id,
178 VtVec3fArray
const &points,
179 VtIntArray
const &curveVertexCounts,
180 VtIntArray
const &curveIndices,
181 VtVec3fArray
const &normals,
185 HdInterpolation colorInterpolation,
187 HdInterpolation opacityInterpolation,
189 HdInterpolation widthInterpolation,
196 HdInterpolation colorInterp=HdInterpolationConstant,
197 HdInterpolation widthInterp=HdInterpolationConstant,
198 bool authoredNormals=
false,
205 void AddPoints(
SdfPath const &
id,
206 VtVec3fArray
const &points,
208 HdInterpolation colorInterpolation,
210 HdInterpolation opacityInterpolation,
212 HdInterpolation widthInterpolation,
219 HdInterpolation colorInterp=HdInterpolationConstant,
220 HdInterpolation widthInterp=HdInterpolationConstant,
230 void SetInstancerProperties(
SdfPath const &
id,
231 VtIntArray
const &prototypeIndex,
232 VtVec3fArray
const &scale,
233 VtVec4fArray
const &rotate,
234 VtVec3fArray
const &translate);
237 void UpdateInstancer(
SdfPath const& rprimId,
SdfPath const& instancerId);
244 HdInterpolation
const& interp,
246 VtIntArray
const& indices=VtIntArray(0));
249 void UpdatePrimvarValue(
SdfPath const&
id,
252 VtIntArray
const& indices=VtIntArray(0));
272 void BindMaterial(
SdfPath const &rprimId,
SdfPath const &materialId);
279 void SetUseSceneMaterials(
bool useSceneMaterials);
286 void UpdateRenderBuffer(
SdfPath const &
id,
299 _tasks[id] = _Task();
314 void HideRprim(
SdfPath const &
id);
318 void UnhideRprim(
SdfPath const &
id);
326 void SetRefineLevel(
SdfPath const &
id,
int refineLevel);
330 void SetVisibility(
SdfPath const &
id,
bool vis);
337 void UpdatePositions(
SdfPath const &
id,
float time);
339 void UpdateRprims(
float time);
341 void UpdateInstancerPrimvars(
float time);
343 void UpdateInstancerPrototypes(
float time);
345 void UpdateCurvePrimvarsInterpMode(
float time);
351 GfVec3f PopulateBasicTestSet();
353 GfVec3f PopulateInvalidPrimsSet();
385 VtIntArray *outIndices)
override;
389 virtual HdPrimvarDescriptorVector
391 HdInterpolation interpolation)
override;
395 SdfPath const& prototypeId)
override;
412 virtual VtValue GetMaterialResource(
SdfPath const &materialId)
override;
416 TfToken const ¶mName)
override;
436 VtVec3fArray
const &points,
437 VtIntArray
const &numVerts,
438 VtIntArray
const &verts,
439 VtIntArray
const &holes,
443 scheme(scheme), orientation(orientation),
444 transform(transform),
445 points(points), numVerts(numVerts), verts(verts),
446 holes(holes), subdivTags(subdivTags), guide(guide),
447 doubleSided(doubleSided), cullStyle(HdCullStyleDontCare) { }
460 HdCullStyle cullStyle;
464 _Curves(VtVec3fArray
const &points,
465 VtIntArray
const &curveVertexCounts,
466 VtIntArray
const &curveIndices,
469 TfToken const &wrap = HdTokens->nonperiodic) :
470 points(points), curveVertexCounts(curveVertexCounts),
471 curveIndices(curveIndices), type(type), basis(basis), wrap(wrap) { }
474 VtIntArray curveVertexCounts;
475 VtIntArray curveIndices;
482 _Points(VtVec3fArray
const &points) : points(points) { }
488 _Instancer(VtVec3fArray
const &scale,
489 VtVec4fArray
const &rotate,
490 VtVec3fArray
const &translate,
492 scale(scale), rotate(rotate), translate(translate),
493 rootTransform(rootTransform) {
497 VtVec3fArray translate;
498 VtIntArray prototypeIndices;
501 std::vector<SdfPath> prototypes;
507 HdInterpolation
const& _interp,
509 VtIntArray
const& _indices=VtIntArray(0)) :
518 HdInterpolation interp;
522 using _Primvars = std::vector<_Primvar>;
525 bool _FindPrimvar(
SdfPath const&
id,
527 _Primvars::iterator *pvIt);
539 struct _RenderBuffer {
541 _RenderBuffer(
GfVec3i const &d, HdFormat f,
bool ms)
542 : dims(d), format(f), multiSampled(ms) {}
548 std::map<SdfPath, _Mesh> _meshes;
549 std::map<SdfPath, _Curves> _curves;
550 std::map<SdfPath, _Points> _points;
551 std::map<SdfPath, _Instancer> _instancers;
552 std::map<SdfPath, _Primvars> _primvars;
553 std::map<SdfPath, VtValue> _materials;
554 std::map<SdfPath, VtValue> _sceneMaterials;
555 std::map<SdfPath, _Camera> _cameras;
556 std::map<SdfPath, _RenderBuffer> _renderBuffers;
557 std::map<SdfPath, _Light> _lights;
558 std::map<SdfPath, _Task> _tasks;
559 TfHashSet<SdfPath, SdfPath::Hash> _hiddenRprims;
561 typedef std::map<SdfPath, SdfPath> SdfPathMap;
562 SdfPathMap _materialBindings;
563 SdfPathMap _instancerBindings;
565 bool _hasInstancePrimvars;
568 std::map<SdfPath, int> _refineLevels;
569 std::map<SdfPath, bool> _visibilities;
573PXR_NAMESPACE_CLOSE_SCOPE
Stores a 4x4 matrix of double elements.
Stores a 4x4 matrix of float elements.
Basic type: 3-dimensional floating point range.
Basic type for a vector of 3 float components.
Basic type for a vector of 3 int components.
Topology data for basisCurves.
Topology data for meshes.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
void InsertTask(HdSceneDelegate *delegate, SdfPath const &id)
Describes one or more authored display representations for an rprim.
Adapter class providing data exchange with the client scene graph.
HdRenderIndex & GetRenderIndex()
Returns the RenderIndex owned by this delegate.
A simple delegate class for unit test driver.
virtual HD_API VtValue Get(SdfPath const &id, TfToken const &key) override
Returns a named value.
virtual HD_API GfRange3d GetExtent(SdfPath const &id) override
Gets the axis aligned bounds of a prim.
virtual HD_API HdMeshTopology GetMeshTopology(SdfPath const &id) override
Gets the topological mesh data for a given prim.
virtual HD_API SdfPath GetInstancerId(SdfPath const &primId) override
Returns the parent instancer of the given rprim or instancer.
HD_API void Remove(SdfPath const &id)
Remove a prim.
virtual HD_API HdRenderBufferDescriptor GetRenderBufferDescriptor(SdfPath const &id) override
Returns the allocation descriptor for a given render buffer prim.
virtual HD_API bool GetDoubleSided(SdfPath const &id) override
Returns the doubleSided state for the given prim.
virtual HD_API SdfPath GetMaterialId(SdfPath const &rprimId) override
Returns the material ID bound to the rprim rprimId.
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.
HD_API void Clear()
Clear all prims.
virtual HD_API SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId) override
Returns a list of prototypes of this instancer.
HD_API void AddMaterialResource(SdfPath const &id, VtValue materialResource)
Material.
void AddTask(SdfPath const &id)
Tasks.
HD_API void UpdateMaterialResource(SdfPath const &materialId, VtValue materialResource)
Update a material resource.
HD_API void AddInstancer(SdfPath const &id, SdfPath const &parentId=SdfPath(), GfMatrix4f const &rootTransform=GfMatrix4f(1))
Instancer.
virtual HD_API HdCullStyle GetCullStyle(SdfPath const &id) override
Returns the cullstyle for the given prim.
HD_API void MarkRprimDirty(SdfPath path, HdDirtyBits flag)
Marks an rprim in the RenderIndex as dirty with the given dirty flags.
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.
virtual HD_API HdReprSelector GetReprSelector(SdfPath const &id) override
Returns the authored repr (if any) for the given prim.
virtual HD_API HdDisplayStyle GetDisplayStyle(SdfPath const &id) override
Returns the display style for the given prim.
HD_API void AddCamera(SdfPath const &id)
Camera.
virtual HD_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id) override
Gets the topological curve data for a given prim.
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.
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 AddFaceVaryingPolygons(SdfPath const &id, GfMatrix4f const &transform, SdfPath const &instancerId=SdfPath())
Add a triangle, quad and pentagon with face-varying displayColor and displayOpacity
HD_API void AddPoints(SdfPath const &id, GfMatrix4f const &transform, HdInterpolation colorInterp=HdInterpolationConstant, HdInterpolation widthInterp=HdInterpolationConstant, SdfPath const &instancerId=SdfPath())
Add a points prim.
virtual HD_API TfToken GetRenderTag(SdfPath const &id) override
Returns the render tag that will be used to bucket prims during render pass bucketing.
virtual HD_API VtValue GetIndexedPrimvar(SdfPath const &id, TfToken const &key, VtIntArray *outIndices) override
Returns a named primvar value.
virtual HD_API HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolation) override
Returns descriptors for all primvars of the given interpolation type.
HD_API void AddSubdiv(SdfPath const &id, GfMatrix4f const &transform, SdfPath const &insatancerId=SdfPath())
Add a subdiv with various tags.
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.
HD_API void UpdateTransform(SdfPath const &id, GfMatrix4f const &mat)
Transform.
virtual HD_API GfMatrix4d GetTransform(SdfPath const &id) override
Returns the object space transform, including all parent transforms.
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.
HD_API void RebindMaterial(SdfPath const &rprimId, SdfPath const &materialId)
Example to update a material binding on the fly.
virtual HD_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId) override
Returns the instancer transform.
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.
HD_API void AddRenderBuffer(SdfPath const &id, HdRenderBufferDescriptor const &desc)
Render buffers.
virtual HD_API VtValue GetCameraParamValue(SdfPath const &cameraId, TfToken const ¶mName) override
Returns a single value for a given camera and parameter.
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 bool GetVisible(SdfPath const &id) override
Returns the authored visible state of the prim.
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.
virtual HD_API PxOsdSubdivTags GetSubdivTags(SdfPath const &id) override
Gets the subdivision surface tags (sharpness, holes, etc).
A path value used to locate objects in layers or scenegraphs.
Token for efficient comparison, assignment, and hashing of known strings.
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
This file defines some macros that are useful for declaring and using static TfTokens.
Describes how the geometry of a prim should be displayed.
Describes the allocation structure of a render buffer bprim.
std::vector< TfToken > TfTokenVector
Convenience types.