Loading...
Searching...
No Matches
mesh.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_MESH_H
8#define PXR_IMAGING_HD_MESH_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/version.h"
13#include "pxr/imaging/hd/enums.h"
14#include "pxr/imaging/hd/meshTopology.h"
15#include "pxr/imaging/hd/rprim.h"
16#include "pxr/imaging/hd/tokens.h"
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21#define HD_MESH_REPR_DESC_TOKENS \
22 (surfaceShader) \
23 (surfaceShaderUnlit) \
24 (surfaceShaderSheer) \
25 (surfaceShaderOutline) \
26 (constantColor) \
27 (hullColor) \
28 (pointColor)
29
30TF_DECLARE_PUBLIC_TOKENS(HdMeshReprDescTokens, HD_API,
31 HD_MESH_REPR_DESC_TOKENS);
32
38{
39 HdMeshReprDesc(HdMeshGeomStyle geomStyle = HdMeshGeomStyleInvalid,
40 HdCullStyle cullStyle = HdCullStyleDontCare,
41 TfToken shadingTerminal = HdMeshReprDescTokens->surfaceShader,
42 bool flatShadingEnabled = false,
43 bool blendWireframeColor = true,
44 bool forceOpaqueEdges = true,
45 bool doubleSided = false,
46 float lineWidth = 0,
47 bool useCustomDisplacement = true,
48 bool enableScalarOverride = true)
59 {}
60
61 bool IsEmpty() const {
62 return geomStyle == HdMeshGeomStyleInvalid;
63 }
64
66 HdMeshGeomStyle geomStyle;
68 HdCullStyle cullStyle;
84 float lineWidth;
91};
92
95class HdMesh : public HdRprim
96{
97public:
98 HD_API
99 ~HdMesh() override;
100
104 inline bool IsDoubleSided(HdSceneDelegate* delegate) const;
105 inline HdCullStyle GetCullStyle(HdSceneDelegate* delegate) const;
106 inline VtValue GetShadingStyle(HdSceneDelegate* delegate) const;
107
111 inline HdMeshTopology GetMeshTopology(HdSceneDelegate* delegate) const;
112 inline HdDisplayStyle GetDisplayStyle(HdSceneDelegate* delegate) const;
113 inline PxOsdSubdivTags GetSubdivTags(HdSceneDelegate* delegate) const;
114
116 virtual HdMeshTopologySharedPtr GetTopology() const;
117
121 inline VtValue GetPoints(HdSceneDelegate* delegate) const;
122 inline VtValue GetNormals(HdSceneDelegate* delegate) const;
123
124 HD_API
125 TfTokenVector const & GetBuiltinPrimvarNames() const override;
126
131 HD_API
132 static void ConfigureRepr(TfToken const &reprName,
133 HdMeshReprDesc desc1,
135
136protected:
139 HD_API
140 HdMesh(SdfPath const& id);
141
142 // We allow up to 2 repr descs per repr for meshes (see ConfigureRepr above)
143 using _MeshReprConfig = _ReprDescConfigs<HdMeshReprDesc, 2>;
144
145 HD_API
146 static _MeshReprConfig::DescArray _GetReprDesc(TfToken const &reprName);
147
148private:
149
150 // Class can not be default constructed or copied.
151 HdMesh() = delete;
152 HdMesh(const HdMesh &) = delete;
153 HdMesh &operator =(const HdMesh &) = delete;
154
155 static _MeshReprConfig _reprDescConfig;
156};
157
158inline bool
160{
161 return delegate->GetDoubleSided(GetId());
162}
163
164inline HdCullStyle
165HdMesh::GetCullStyle(HdSceneDelegate* delegate) const
166{
167 return delegate->GetCullStyle(GetId());
168}
169
170inline VtValue
171HdMesh::GetShadingStyle(HdSceneDelegate* delegate) const
172{
173 return delegate->GetShadingStyle(GetId());
174}
175
176inline HdMeshTopology
178{
179 return delegate->GetMeshTopology(GetId());
180}
181
182inline HdDisplayStyle
183HdMesh::GetDisplayStyle(HdSceneDelegate* delegate) const
184{
185 return delegate->GetDisplayStyle(GetId());
186}
187
188inline PxOsdSubdivTags
189HdMesh::GetSubdivTags(HdSceneDelegate* delegate) const
190{
191 return delegate->GetSubdivTags(GetId());
192}
193
194inline HdMeshTopologySharedPtr
196{
197 return HdMeshTopologySharedPtr();
198}
199
200inline VtValue
202{
203 return GetPrimvar(delegate, HdTokens->points);
204}
205
206inline VtValue
207HdMesh::GetNormals(HdSceneDelegate* delegate) const
208{
209 return GetPrimvar(delegate, HdTokens->normals);
210}
211
212
213PXR_NAMESPACE_CLOSE_SCOPE
214
215#endif //PXR_IMAGING_HD_MESH_H
Hydra Schema for a subdivision surface or poly-mesh object.
Definition: mesh.h:96
HD_API HdMesh(SdfPath const &id)
Constructor.
virtual HdMeshTopologySharedPtr GetTopology() const
Topology getter.
Definition: mesh.h:195
VtValue GetPoints(HdSceneDelegate *delegate) const
Primvars Accessors.
Definition: mesh.h:201
HD_API TfTokenVector const & GetBuiltinPrimvarNames() const override
Returns the names of built-in primvars, i.e.
static HD_API void ConfigureRepr(TfToken const &reprName, HdMeshReprDesc desc1, HdMeshReprDesc desc2=HdMeshReprDesc())
Configure the geometric style of the mesh for a given representation.
HdMeshTopology GetMeshTopology(HdSceneDelegate *delegate) const
Topological accessors via the scene delegate.
Definition: mesh.h:177
bool IsDoubleSided(HdSceneDelegate *delegate) const
Render State.
Definition: mesh.h:159
Topology data for meshes.
Definition: meshTopology.h:38
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:38
SdfPath const & GetId() const
Returns the identifier of this Rprim.
Definition: rprim.h:146
Adapter class providing data exchange with the client scene graph.
virtual HD_API HdDisplayStyle GetDisplayStyle(SdfPath const &id)
Returns the refinement level for the given prim in the range [0,8].
virtual HD_API VtValue GetShadingStyle(SdfPath const &id)
Returns the shading style for the given prim.
virtual HD_API bool GetDoubleSided(SdfPath const &id)
Returns the doubleSided state for the given prim.
virtual HD_API HdMeshTopology GetMeshTopology(SdfPath const &id)
Gets the topological mesh data for a given prim.
virtual HD_API PxOsdSubdivTags GetSubdivTags(SdfPath const &id)
Gets the subdivision surface tags (sharpness, holes, etc).
virtual HD_API HdCullStyle GetCullStyle(SdfPath const &id)
Returns the cullstyle for the given prim.
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:26
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:81
Describes how the geometry of a prim should be displayed.
Definition: sceneDelegate.h:64
Descriptor to configure the drawItem(s) for a repr.
Definition: mesh.h:38
bool flatShadingEnabled
Does this mesh want flat shading?
Definition: mesh.h:73
HdCullStyle cullStyle
The culling style: draw front faces, back faces, etc.
Definition: mesh.h:68
bool enableScalarOverride
Should scalar override be allowed on this drawItem.
Definition: mesh.h:90
HdMeshGeomStyle geomStyle
The rendering style: draw refined/unrefined, edge, points, etc.
Definition: mesh.h:66
bool forceOpaqueEdges
If the geom style includes edges, should those edges be forced to be fully opaque,...
Definition: mesh.h:79
bool doubleSided
Should this mesh be treated as double-sided? The resolved value is (prim.doubleSided || repr....
Definition: mesh.h:82
float lineWidth
How big (in pixels) should line drawing be?
Definition: mesh.h:84
TfToken shadingTerminal
Specifies how the fragment color should be computed from surfaceShader; this can be used to render a ...
Definition: mesh.h:71
bool useCustomDisplacement
Should this mesh use displacementShader() to displace points?
Definition: mesh.h:86
bool blendWireframeColor
Should the wireframe color be blended into the color primvar?
Definition: mesh.h:75
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440