HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instancerTopologySchema.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 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 
26 /* ************************************************************************** */
27 /* ** ** */
28 /* ** This file is generated by a script. ** */
29 /* ** ** */
30 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
31 /* ** Edit hdGen/schema.py instead to make changes. ** */
32 /* ** ** */
33 /* ************************************************************************** */
34 
35 #ifndef PXR_IMAGING_HD_INSTANCER_TOPOLOGY_SCHEMA_H
36 #define PXR_IMAGING_HD_INSTANCER_TOPOLOGY_SCHEMA_H
37 
38 #include "pxr/imaging/hd/api.h"
40 
41 #include "pxr/imaging/hd/schema.h"
42 
43 // --(BEGIN CUSTOM CODE: Includes)--
44 // --(END CUSTOM CODE: Includes)--
45 
47 
48 //-----------------------------------------------------------------------------
49 
50 // --(BEGIN CUSTOM CODE: Declares)--
51 // --(END CUSTOM CODE: Declares)--
52 
53 //-----------------------------------------------------------------------------
54 
55 #define HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS \
56  (instancerTopology) \
57  (prototypes) \
58  (instanceIndices) \
59  (mask) \
60  (instanceLocations) \
61 
62 TF_DECLARE_PUBLIC_TOKENS(HdInstancerTopologySchemaTokens, HD_API,
64 
65 //-----------------------------------------------------------------------------
66 // Since the instancing schema is complicated:
67 //
68 // An instancer is a prim at a certain scenegraph location that causes other
69 // prims to be duplicated. The instancer can also hold instance-varying data
70 // like constant primvars or material relationships.
71 //
72 // The important things an instancer has is:
73 //
74 // 1.) Instancer topology, describing how exactly the prims are duplicated;
75 //
76 // 2.) Instance-rate data, meaning data that varies per instance, such as
77 // primvars or material bindings.
78 //
79 // If an instancer causes prims "/A" and "/B" to be duplicated, we encode that
80 // by setting prototypes = ["/A", "/B"]. Note that "/A" and "/B" can be
81 // subtrees, not direct gprims. instanceIndices encodes both multiplicity and
82 // position in arrays of instance-rate data, per prototype path; if
83 // instanceIndices = { [0,2], [1] }, then we draw /A twice (with instance
84 // primvar indices 0 and 2); and /B once (with instance primvar index 1). Mask
85 // is an auxiliary parameter that can be used to deactivate certain instances;
86 // mask = [true, true, false] would disable the second copy of "/A". An empty
87 // mask array is the same as all-true.
88 //
89 // Scenes generally specify instancing in one of two ways:
90 //
91 // 1.) Explicit instancing: prim /Instancer wants to draw its subtree at an
92 // array of locations. This is a data expansion form.
93 //
94 // 2.) Implicit instancing: prims /X and /Y are marked as being identical, and
95 // scene load replaces them with a single prim and an instancer. This is a
96 // data coalescing form.
97 //
98 // For implicit instancing, we want to know the original paths of /X and /Y,
99 // for doing things like resolving inheritance. This is encoded in the
100 // "instanceLocations" path, while the prototype prims (e.g. /_Prototype/Cube,
101 // the deduplicated version of /X/Cube and /Y/Cube) is encoded in the
102 // "prototypes" path.
103 //
104 // For explicit instancing, the "instanceLocations" attribute is meaningless
105 // and should be left null.
106 //
108 {
109 public:
110  HdInstancerTopologySchema(HdContainerDataSourceHandle container)
111  : HdSchema(container) {}
112 
113 // --(BEGIN CUSTOM CODE: Schema Methods)--
114 
115  HD_API
117 
118 // --(END CUSTOM CODE: Schema Methods)--
119 
120  //ACCESSORS
121 
122 
123  HD_API
125 
126  HD_API
128 
129  HD_API
131 
132  HD_API
134 
135  // RETRIEVING AND CONSTRUCTING
136 
137  /// Builds a container data source which includes the provided child data
138  /// sources. Parameters with nullptr values are excluded. This is a
139  /// low-level interface. For cases in which it's desired to define
140  /// the container with a sparse set of child fields, the Builder class
141  /// is often more convenient and readable.
142  HD_API
143  static HdContainerDataSourceHandle
145  const HdPathArrayDataSourceHandle &prototypes,
146  const HdVectorDataSourceHandle &instanceIndices,
148  const HdPathArrayDataSourceHandle &instanceLocations
149  );
150 
151  /// \class HdInstancerTopologySchema::Builder
152  ///
153  /// Utility class for setting sparse sets of child data source fields to be
154  /// filled as arguments into BuildRetained. Because all setter methods
155  /// return a reference to the instance, this can be used in the "builder
156  /// pattern" form.
157  class Builder
158  {
159  public:
160  HD_API
162  const HdPathArrayDataSourceHandle &prototypes);
163  HD_API
165  const HdVectorDataSourceHandle &instanceIndices);
166  HD_API
167  Builder &SetMask(
169  HD_API
171  const HdPathArrayDataSourceHandle &instanceLocations);
172 
173  /// Returns a container data source containing the members set thus far.
174  HD_API
175  HdContainerDataSourceHandle Build();
176 
177  private:
178  HdPathArrayDataSourceHandle _prototypes;
179  HdVectorDataSourceHandle _instanceIndices;
181  HdPathArrayDataSourceHandle _instanceLocations;
182  };
183 
184  /// Retrieves a container data source with the schema's default name token
185  /// "instancerTopology" from the parent container and constructs a
186  /// HdInstancerTopologySchema instance.
187  /// Because the requested container data source may not exist, the result
188  /// should be checked with IsDefined() or a bool comparison before use.
189  HD_API
191  const HdContainerDataSourceHandle &fromParentContainer);
192 
193  /// Returns a token where the container representing this schema is found in
194  /// a container by default.
195  HD_API
196  static const TfToken &GetSchemaToken();
197 
198  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
199  /// where the container representing this schema is found by default.
200  HD_API
201  static const HdDataSourceLocator &GetDefaultLocator();
202 
203 };
204 
206 
207 #endif
HD_API HdIntArrayVectorSchema GetInstanceIndices()
HD_API Builder & SetPrototypes(const HdPathArrayDataSourceHandle &prototypes)
HdBoolArrayDataSource::Handle HdBoolArrayDataSourceHandle
HD_API HdPathArrayDataSourceHandle GetPrototypes()
HdPathArrayDataSource::Handle HdPathArrayDataSourceHandle
static HD_API HdContainerDataSourceHandle BuildRetained(const HdPathArrayDataSourceHandle &prototypes, const HdVectorDataSourceHandle &instanceIndices, const HdBoolArrayDataSourceHandle &mask, const HdPathArrayDataSourceHandle &instanceLocations)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define HD_API
Definition: api.h:40
TF_DECLARE_PUBLIC_TOKENS(HdInstancerTopologySchemaTokens, HD_API, HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS)
HD_API Builder & SetInstanceIndices(const HdVectorDataSourceHandle &instanceIndices)
static HD_API HdInstancerTopologySchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
HD_API Builder & SetInstanceLocations(const HdPathArrayDataSourceHandle &instanceLocations)
HD_API Builder & SetMask(const HdBoolArrayDataSourceHandle &mask)
Definition: token.h:87
HD_API VtArray< int > ComputeInstanceIndicesForProto(SdfPath const &path)
static HD_API const TfToken & GetSchemaToken()
GLint GLuint mask
Definition: glcorearb.h:124
Definition: types.h:170
Definition: path.h:290
HdInstancerTopologySchema(HdContainerDataSourceHandle container)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HD_API HdPathArrayDataSourceHandle GetInstanceLocations()
static HD_API const HdDataSourceLocator & GetDefaultLocator()
HD_API HdBoolArrayDataSourceHandle GetMask()