HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primvarSchema.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 // This file is generated by a script. Do not edit directly. Edit the
26 // schema.template.h file to make changes.
27 
28 #ifndef PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
29 #define PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
30 
31 #include "pxr/imaging/hd/api.h"
32 
33 #include "pxr/imaging/hd/schema.h"
34 
36 
37 //-----------------------------------------------------------------------------
38 
39 #define HDPRIMVAR_SCHEMA_TOKENS \
40  (primvarValue) \
41  (indexedPrimvarValue) \
42  (indices) \
43  (interpolation) \
44  (role) \
45  (constant) \
46  (uniform) \
47  (varying) \
48  (vertex) \
49  (faceVarying) \
50  (instance) \
51  (point) \
52  (normal) \
53  (vector) \
54  (color) \
55  (pointIndex) \
56  (edgeIndex) \
57  (faceIndex) \
58  (textureCoordinate) \
59  (transform) \
60 
61 TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API,
63 
64 //-----------------------------------------------------------------------------
65 
66 class HdPrimvarSchema : public HdSchema
67 {
68 public:
69  HdPrimvarSchema(HdContainerDataSourceHandle container)
70  : HdSchema(container) {}
71 
72  //ACCESSORS
73 
74 
75  // If the primvar does not have indices, GetPrimvarValue() and
76  // GetIndexedPrimvarValue() will return the same thing. If the primvar
77  // does has indices, GetPrimvarValue() will return the flattened value,
78  // while GetIndexedPrimvarValue() will return the unflattened value.
79  HD_API
80  HdSampledDataSourceHandle GetPrimvarValue();
81  HD_API
82  HdSampledDataSourceHandle GetIndexedPrimvarValue();
83  HD_API
85  HD_API
87  HD_API
89 
90  // RETRIEVING AND CONSTRUCTING
91 
92  /// Builds a container data source which includes the provided child data
93  /// sources. Parameters with nullptr values are excluded. This is a
94  /// low-level interface. For cases in which it's desired to define
95  /// the container with a sparse set of child fields, the Builder class
96  /// is often more convenient and readable.
97  HD_API
98  static HdContainerDataSourceHandle
100  const HdSampledDataSourceHandle &primvarValue,
101  const HdSampledDataSourceHandle &indexedPrimvarValue,
103  const HdTokenDataSourceHandle &interpolation,
104  const HdTokenDataSourceHandle &role
105  );
106 
107  /// \class HdPrimvarSchema::Builder
108  ///
109  /// Utility class for setting sparse sets of child data source fields to be
110  /// filled as arguments into BuildRetained. Because all setter methods
111  /// return a reference to the instance, this can be used in the "builder
112  /// pattern" form.
113  class Builder
114  {
115  public:
116  HD_API
118  const HdSampledDataSourceHandle &primvarValue);
119  HD_API
121  const HdSampledDataSourceHandle &indexedPrimvarValue);
122  HD_API
125  HD_API
127  const HdTokenDataSourceHandle &interpolation);
128  HD_API
129  Builder &SetRole(
130  const HdTokenDataSourceHandle &role);
131 
132  /// Returns a container data source containing the members set thus far.
133  HD_API
134  HdContainerDataSourceHandle Build();
135 
136  private:
137  HdSampledDataSourceHandle _primvarValue;
138  HdSampledDataSourceHandle _indexedPrimvarValue;
140  HdTokenDataSourceHandle _interpolation;
142  };
143  // Returns true if it contains data sources for an indexed primvar value
144  // and for indices.
145  HD_API
146  bool IsIndexed();
147 
148 
149  /// Returns token data source for use as interpolation value.
150  /// Values of...
151  /// - HdPrimvarSchemaTokens->constant
152  /// - HdPrimvarSchemaTokens->uniform
153  /// - HdPrimvarSchemaTokens->varying
154  /// - HdPrimvarSchemaTokens->vertex
155  /// - HdPrimvarSchemaTokens->faceVarying
156  /// - HdPrimvarSchemaTokens->instance
157  /// ...will be stored statically and reused for future calls.
158  HD_API
160  const TfToken &interpolation);
161  /// Returns token data source for use as role value.
162  /// Values of...
163  /// - HdPrimvarSchemaTokens->point
164  /// - HdPrimvarSchemaTokens->normal
165  /// - HdPrimvarSchemaTokens->vector
166  /// - HdPrimvarSchemaTokens->color
167  /// - HdPrimvarSchemaTokens->pointIndex
168  /// - HdPrimvarSchemaTokens->edgeIndex
169  /// - HdPrimvarSchemaTokens->faceIndex
170  /// - HdPrimvarSchemaTokens->textureCoordinate
171  /// ...will be stored statically and reused for future calls.
172  HD_API
174  const TfToken &role);
175 
176 };
177 
179 
180 #endif
HD_API bool IsIndexed()
HD_API Builder & SetRole(const HdTokenDataSourceHandle &role)
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
static HD_API HdTokenDataSourceHandle BuildInterpolationDataSource(const TfToken &interpolation)
static HD_API HdContainerDataSourceHandle BuildRetained(const HdSampledDataSourceHandle &primvarValue, const HdSampledDataSourceHandle &indexedPrimvarValue, const HdIntArrayDataSourceHandle &indices, const HdTokenDataSourceHandle &interpolation, const HdTokenDataSourceHandle &role)
HdPrimvarSchema(HdContainerDataSourceHandle container)
Definition: primvarSchema.h:69
#define HD_API
Definition: api.h:40
HD_API Builder & SetPrimvarValue(const HdSampledDataSourceHandle &primvarValue)
HD_API Builder & SetInterpolation(const HdTokenDataSourceHandle &interpolation)
Definition: token.h:87
HD_API HdSampledDataSourceHandle GetPrimvarValue()
HdIntArrayDataSource::Handle HdIntArrayDataSourceHandle
HD_API HdTokenDataSourceHandle GetInterpolation()
HD_API Builder & SetIndices(const HdIntArrayDataSourceHandle &indices)
static HD_API HdTokenDataSourceHandle BuildRoleDataSource(const TfToken &role)
TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API, HDPRIMVAR_SCHEMA_TOKENS)
HD_API HdIntArrayDataSourceHandle GetIndices()
#define HDPRIMVAR_SCHEMA_TOKENS
Definition: primvarSchema.h:39
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
HD_API Builder & SetIndexedPrimvarValue(const HdSampledDataSourceHandle &indexedPrimvarValue)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HD_API HdTokenDataSourceHandle GetRole()
HdTokenDataSource::Handle HdTokenDataSourceHandle
HD_API HdSampledDataSourceHandle GetIndexedPrimvarValue()