28 #ifndef __usd_HydraDelegate__ 29 #define __usd_HydraDelegate__ 31 #include "pxr/imaging/hd/sceneDelegate.h" 32 #include "pxr/imaging/hd/tokens.h" 33 #include "pxr/imaging/pxOsd/tokens.h" 34 #include "pxr/imaging/glf/texture.h" 36 #include "pxr/base/gf/vec3f.h" 37 #include "pxr/base/gf/vec3d.h" 38 #include "pxr/base/gf/vec4f.h" 39 #include "pxr/base/gf/vec4d.h" 40 #include "pxr/base/gf/matrix4f.h" 41 #include "pxr/base/gf/matrix4d.h" 42 #include "pxr/base/vt/array.h" 43 #include "pxr/base/tf/staticTokens.h" 45 #define TEST_TOKENS (geometryAndGuides) 47 TF_DECLARE_PUBLIC_TOKENS(TestTokens,TEST_TOKENS);
55 SdfPath
const& delegateID);
57 void SetUseInstancePrimVars(
bool v) { m_hasInstancePrimVars = v; }
59 void SetRefineLevel(
int level);
61 void SetCamera(GfMatrix4d
const &viewMatrix,
62 GfMatrix4d
const &projMatrix);
63 void SetCamera(SdfPath
const &
id, GfMatrix4d
const &viewMatrix,
64 GfMatrix4d
const &projMatrix);
65 void AddCamera(SdfPath
const &
id);
67 bool HasLight(SdfPath
const &
id);
68 void AddLight(SdfPath
const &
id, GlfSimpleLight
const &light);
69 void SetLight(SdfPath
const &
id, TfToken
const &key, VtValue value);
71 void AddRenderTask(SdfPath
const &
id);
72 void AddRenderSetupTask(SdfPath
const &
id);
73 void AddSimpleLightTask(SdfPath
const &
id);
74 void AddShadowTask(SdfPath
const &
id);
75 void AddSelectionTask(SdfPath
const &
id);
77 void AdjustRenderSetupTask(SdfPath
const &
id,BWORD a_lighting,
78 const GfVec4f& viewport);
80 void SetTaskParam(SdfPath
const &
id,
81 TfToken
const &name, VtValue val);
82 VtValue GetTaskParam(SdfPath
const &
id, TfToken
const &name);
84 HdTaskSharedPtrVector GetRenderTasks(
void);
86 void AddMesh(SdfPath
const &
id,
87 GfMatrix4f
const &transform,
88 VtVec3rArray
const &points,
89 VtIntArray
const &numVerts,
90 VtIntArray
const &verts,
91 VtVec3rArray
const &normals,
92 PxOsdSubdivTags
const &subdivTags,
94 HdInterpolation uvInterpolation,
96 HdInterpolation colorInterpolation,
98 SdfPath
const &instancerId=SdfPath(),
99 TfToken
const &scheme=PxOsdOpenSubdivTokens->catmullClark,
100 TfToken
const &orientation=HdTokens->rightHanded,
101 bool doubleSided=
false);
103 void AddBasisCurves(SdfPath
const &
id,
104 GfMatrix4f
const &transform,
105 VtVec3rArray
const &points,
106 VtIntArray
const &curveVertexCounts,
107 VtVec3rArray
const &normals,
108 TfToken
const &basis,
109 VtValue
const &color,
110 HdInterpolation colorInterpolation,
111 VtValue
const &width,
112 HdInterpolation widthInterpolation,
113 SdfPath
const &instancerId=SdfPath());
115 void AddPoints(SdfPath
const &
id,
116 GfMatrix4f
const &transform,
117 VtVec3rArray
const &points,
118 VtVec3rArray
const &normals,
119 VtValue
const &color,
120 HdInterpolation colorInterpolation,
121 VtValue
const &width,
122 HdInterpolation widthInterpolation,
123 SdfPath
const &instancerId=SdfPath());
125 void AddInstancer(SdfPath
const &
id,
126 SdfPath
const &parentId=SdfPath(),
127 GfMatrix4f
const &rootTransform=GfMatrix4f(1));
129 void SetInstancerProperties(SdfPath
const &
id,
130 VtIntArray
const &prototypeIndex,
131 VtVec3rArray
const &scale,
132 VtVec4fArray
const &rotate,
133 VtVec3rArray
const &translate);
139 void AddTexture(SdfPath
const&
id,
140 GlfTextureRefPtr
const& texture);
144 VtValue materialResource);
148 VtValue materialResource);
150 void BindMaterial(SdfPath
const &rprimId,
151 SdfPath
const &materialId);
155 SdfPath
const &materialId);
157 virtual SdfPath GetMaterialId(SdfPath
const& rprimId)
override;
159 virtual VtValue GetMaterialResource(SdfPath
const &materialId)
override;
161 void Remove(SdfPath
const &
id);
174 HdReprSelector
const &reprSelector);
177 void SetRefineLevel(SdfPath
const &
id,
int refineLevel);
182 HdChangeTracker::RprimDirtyBits flag);
184 void UpdatePositions(SdfPath
const &
id,
float time);
185 void UpdateRprims(
float time);
186 void UpdateInstancerPrimVars(
float time);
187 void UpdateInstancerPrototypes(
float time);
189 void UpdateCamera(SdfPath
const &
id,
190 TfToken
const &key, VtValue value);
192 void BindSurfaceShader(SdfPath
const &rprimId,
193 SdfPath
const &shaderId)
194 { m_surfaceShaderBindings[rprimId] = shaderId; }
196 GfRange3d GetExtents(
void);
198 virtual bool IsInCollection(SdfPath
const&
id,
199 TfToken
const& collectionName);
200 virtual HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath
const&
id);
201 virtual PxOsdSubdivTags GetSubdivTags(SdfPath
const&
id);
202 virtual GfRange3d GetExtent(SdfPath
const &
id)
override;
203 virtual GfMatrix4d GetTransform(SdfPath
const &
id)
override;
204 virtual bool GetVisible(SdfPath
const &
id)
override;
205 virtual HdMeshTopology GetMeshTopology(SdfPath
const&
id)
override;
206 virtual bool GetDoubleSided(SdfPath
const &
id);
208 virtual HdDisplayStyle GetDisplayStyle(SdfPath
const &
id)
override;
209 virtual VtValue Get(SdfPath
const&
id, TfToken
const& key);
211 virtual HdReprSelector GetReprSelector(SdfPath
const &
id)
override;
213 #if HD_API_VERSION>=32 214 virtual HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath
const&
id,
215 HdInterpolation interpolation)
override;
217 virtual TfTokenVector GetPrimVarVertexNames(SdfPath
const&
id);
218 virtual TfTokenVector GetPrimVarVaryingNames(SdfPath
const&
id);
219 virtual TfTokenVector GetPrimVarFacevaryingNames(SdfPath
const&
id);
220 virtual TfTokenVector GetPrimVarUniformNames(SdfPath
const&
id);
221 virtual TfTokenVector GetPrimVarConstantNames(SdfPath
const&
id);
222 virtual TfTokenVector GetPrimVarInstanceNames(SdfPath
const&
id);
223 virtual int GetPrimVarDataType(SdfPath
const&
id,
225 virtual int GetPrimVarComponents(SdfPath
const&
id,
229 virtual VtIntArray GetInstanceIndices(SdfPath
const& instancerId,
230 SdfPath
const& prototypeId)
override;
231 virtual GfMatrix4d GetInstancerTransform(
232 SdfPath
const& instancerId)
override;
233 virtual VtValue GetCameraParamValue(
234 SdfPath
const &cameraId,
235 TfToken
const ¶mName)
override;
246 void SetTransform(SdfPath
const&
id,
247 GfMatrix4f
const &transform);
254 Mesh(TfToken
const &scheme,
255 TfToken
const &orientation,
256 GfMatrix4f
const &transform,
257 VtVec3rArray
const &points,
258 VtIntArray
const &numVerts,
259 VtIntArray
const &verts,
260 VtVec3rArray
const &normals,
261 PxOsdSubdivTags
const &subdivTags,
263 HdInterpolation uvInterpolation,
264 VtValue
const &color,
265 HdInterpolation colorInterpolation,
269 orientation(orientation),
270 transform(transform),
275 subdivTags(subdivTags),
277 uvInterpolation(uvInterpolation),
279 colorInterpolation(colorInterpolation),
281 doubleSided(doubleSided) {}
285 GfMatrix4f transform;
289 VtVec3rArray normals;
290 PxOsdSubdivTags subdivTags;
292 HdInterpolation uvInterpolation;
294 HdInterpolation colorInterpolation;
297 HdReprSelector reprSelector;
305 GfMatrix4f
const &transform,
306 VtIntArray
const &curveVertexCounts,
307 VtIntArray
const &curveIndices,
308 VtVec3rArray
const &points,
309 VtVec3rArray
const &normals,
310 TfToken
const &basis,
311 VtValue
const &color,
312 HdInterpolation colorInterpolation,
313 VtValue
const &width,
314 HdInterpolation widthInterpolation) :
315 curveVertexCounts(curveVertexCounts),
316 curveIndices(curveIndices),
321 colorInterpolation(colorInterpolation),
323 widthInterpolation(widthInterpolation) {}
325 GfMatrix4f transform;
326 VtIntArray curveVertexCounts;
327 VtIntArray curveIndices;
329 VtVec3rArray normals;
332 HdInterpolation colorInterpolation;
334 HdInterpolation widthInterpolation;
335 HdReprSelector reprSelector;
343 GfMatrix4f
const &transform,
344 VtVec3rArray
const &points,
345 VtVec3rArray
const &normals,
346 VtValue
const &color,
347 HdInterpolation colorInterpolation,
348 VtValue
const &width,
349 HdInterpolation widthInterpolation):
353 colorInterpolation(colorInterpolation),
355 widthInterpolation(widthInterpolation) {}
357 GfMatrix4f transform;
359 VtVec3rArray normals;
361 HdInterpolation colorInterpolation;
363 HdInterpolation widthInterpolation;
364 HdReprSelector reprSelector;
371 Instancer(VtVec3rArray
const &scale,
372 VtVec4fArray
const &rotate,
373 VtVec3rArray
const &translate,
374 GfMatrix4f
const &rootTransform):
377 translate(translate),
378 rootTransform(rootTransform) {}
382 VtVec3rArray translate;
383 VtIntArray prototypeIndices;
384 GfMatrix4f rootTransform;
385 std::vector<SdfPath> prototypes;
405 Texture(GlfTextureRefPtr
const &tex):
407 GlfTextureRefPtr texture;
410 std::map<SdfPath,Mesh> m_meshes;
411 std::map<SdfPath,Curves> m_curves;
412 std::map<SdfPath,Points> m_points;
413 std::map<SdfPath,Instancer> m_instancers;
415 std::map<SdfPath,SdfPath> m_surfaceShaderBindings;
416 std::map<SdfPath,Texture> m_textures;
417 std::map<SdfPath, VtValue> m_materials;
418 TfHashSet<SdfPath,SdfPath::Hash> m_hiddenRprims;
420 typedef std::map<SdfPath, SdfPath> SdfPathMap;
421 SdfPathMap m_materialBindings;
425 bool m_hasInstancePrimVars;
427 std::map<SdfPath, int> m_refineLevels;
429 typedef TfHashMap<TfToken, VtValue, TfToken::HashFunctor> ValueCache;
430 typedef TfHashMap<SdfPath, ValueCache, SdfPath::Hash> ValueCacheMap;
432 ValueCacheMap m_valueCacheMap;
435 #endif // __usd_HydraDelegate__ void AddMaterialResource(SdfPath const &id, VtValue materialResource)
Material.
Definition: HydraDelegate.cc:713
void SetReprSelector(SdfPath const &id, HdReprSelector const &reprSelector)
set per-prim repr
Definition: HydraDelegate.cc:787
void Clear(void)
Remove all.
Definition: HydraDelegate.cc:1744
void UnhideRprim(SdfPath const &id)
Un-hides an rprim, invalidating all collections it was in.
Definition: HydraDelegate.cc:781
A simple delegate class for unit test driver.
Definition: HydraDelegate.h:51
void MarkRprimDirty(SdfPath path, HdChangeTracker::RprimDirtyBits flag)
Marks an rprim in the RenderIndex as dirty with the given dirty flags.
Definition: HydraDelegate.cc:1749
void HideRprim(SdfPath const &id)
Hides an rprim, invalidating all collections it was in.
Definition: HydraDelegate.cc:775
void UpdateMaterialResource(SdfPath const &materialId, VtValue materialResource)
Update a material resource.
Definition: HydraDelegate.cc:721
void RebindMaterial(SdfPath const &rprimId, SdfPath const &materialId)
Example to update a material binding on the fly.
Definition: HydraDelegate.cc:747