forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmesh.h
436 lines (392 loc) · 20.2 KB
/
mesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
//
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef USDGEOM_GENERATED_MESH_H
#define USDGEOM_GENERATED_MESH_H
/// \file usdGeom/mesh.h
#include "pxr/usd/usdGeom/pointBased.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/stage.h"
#include "pxr/usd/usdGeom/tokens.h"
#include "pxr/usd/usd/timeCode.h"
#include "pxr/base/vt/value.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
class SdfAssetPath;
// -------------------------------------------------------------------------- //
// MESH //
// -------------------------------------------------------------------------- //
/// \class UsdGeomMesh
///
/// Encodes a mesh surface whose definition and feature-set
/// will converge with that of OpenSubdiv, http://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html. Current exceptions/divergences include:
///
/// 1. Certain interpolation ("tag") parameters not yet supported
///
/// 2. Does not (as of 9/2014) yet support hierarchical edits. We do intend
/// to provide some encoding in a future version of the schema.
///
/// A key property of this mesh schema is that it encodes both subdivision
/// surfaces, and non-subdived "polygonal meshes", by varying the
/// \em subdivisionScheme attribute.
///
/// \section UsdGeom_Mesh_Normals A Note About Normals
///
/// Although the \em normals attribute inherited from PointBased can be authored
/// on any mesh, they are almost never needed for subdivided meshes, and only
/// add rendering cost. You may consider only authoring them for polygonal
/// meshes.
///
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
/// as the value.
///
class UsdGeomMesh : public UsdGeomPointBased
{
public:
/// Compile-time constant indicating whether or not this class corresponds
/// to a concrete instantiable prim type in scene description. If this is
/// true, GetStaticPrimDefinition() will return a valid prim definition with
/// a non-empty typeName.
static const bool IsConcrete = true;
/// Construct a UsdGeomMesh on UsdPrim \p prim .
/// Equivalent to UsdGeomMesh::Get(prim.GetStage(), prim.GetPath())
/// for a \em valid \p prim, but will not immediately throw an error for
/// an invalid \p prim
explicit UsdGeomMesh(const UsdPrim& prim=UsdPrim())
: UsdGeomPointBased(prim)
{
}
/// Construct a UsdGeomMesh on the prim held by \p schemaObj .
/// Should be preferred over UsdGeomMesh(schemaObj.GetPrim()),
/// as it preserves SchemaBase state.
explicit UsdGeomMesh(const UsdSchemaBase& schemaObj)
: UsdGeomPointBased(schemaObj)
{
}
/// Destructor.
virtual ~UsdGeomMesh();
/// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that
/// may be authored by custom/extended methods of the schemas involved.
static const TfTokenVector &
GetSchemaAttributeNames(bool includeInherited=true);
/// Return a UsdGeomMesh holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on
/// \p stage, or if the prim at that path does not adhere to this schema,
/// return an invalid schema object. This is shorthand for the following:
///
/// \code
/// UsdGeomMesh(stage->GetPrimAtPath(path));
/// \endcode
///
static UsdGeomMesh
Get(const UsdStagePtr &stage, const SdfPath &path);
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
/// is defined (according to UsdPrim::IsDefined()) on this stage.
///
/// If a prim adhering to this schema at \p path is already defined on this
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
/// current EditTarget for any nonexistent, or existing but not \a Defined
/// ancestors.
///
/// The given \a path must be an absolute prim path that does not contain
/// any variant selections.
///
/// If it is impossible to author any of the necessary PrimSpecs, (for
/// example, in case \a path cannot map to the current UsdEditTarget's
/// namespace) issue an error and return an invalid \a UsdPrim.
///
/// Note that this method may return a defined prim whose typeName does not
/// specify this schema class, in case a stronger typeName opinion overrides
/// the opinion at the current EditTarget.
///
static UsdGeomMesh
Define(const UsdStagePtr &stage, const SdfPath &path);
private:
// needs to invoke _GetStaticTfType.
friend class UsdSchemaRegistry;
static const TfType &_GetStaticTfType();
static bool _IsTypedSchema();
// override SchemaBase virtuals.
virtual const TfType &_GetTfType() const;
public:
// --------------------------------------------------------------------- //
// FACEVERTEXINDICES
// --------------------------------------------------------------------- //
/// Flat list of the index (into the 'points' attribute) of each
/// vertex of each face in the mesh. If this attribute has more than
/// one timeSample, the mesh is considered to be topologically varying.
///
/// \n C++ Type: VtArray<int>
/// \n Usd Type: SdfValueTypeNames->IntArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: No Fallback
UsdAttribute GetFaceVertexIndicesAttr() const;
/// See GetFaceVertexIndicesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateFaceVertexIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// FACEVERTEXCOUNTS
// --------------------------------------------------------------------- //
/// Provides the number of vertices in each face of the mesh,
/// which is also the number of consecutive indices in 'faceVertexIndices'
/// that define the face. The length of this attribute is the number of
/// faces in the mesh. If this attribute has more than
/// one timeSample, the mesh is considered to be topologically varying.
///
/// \n C++ Type: VtArray<int>
/// \n Usd Type: SdfValueTypeNames->IntArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: No Fallback
UsdAttribute GetFaceVertexCountsAttr() const;
/// See GetFaceVertexCountsAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateFaceVertexCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// SUBDIVISIONSCHEME
// --------------------------------------------------------------------- //
/// The subdivision scheme to be applied to the surface.
/// Valid values are "catmullClark" (the default), "loop", "bilinear", and
/// "none" (i.e. a polymesh with no subdivision - the primary difference
/// between schemes "bilinear" and "none" is that bilinearly subdivided
/// meshes can be considered watertight, whereas there is no such guarantee
/// for un-subdivided polymeshes, and more mesh features (e.g. holes) may
/// apply to bilinear meshes but not polymeshes. Polymeshes \em may be
/// lighterweight and faster to render, depending on renderer and render
/// mode.)
///
/// \n C++ Type: TfToken
/// \n Usd Type: SdfValueTypeNames->Token
/// \n Variability: SdfVariabilityUniform
/// \n Fallback Value: catmullClark
/// \n \ref UsdGeomTokens "Allowed Values": [catmullClark, loop, bilinear, none]
UsdAttribute GetSubdivisionSchemeAttr() const;
/// See GetSubdivisionSchemeAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateSubdivisionSchemeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// INTERPOLATEBOUNDARY
// --------------------------------------------------------------------- //
/// Specifies how interpolation boundary face edges are
/// interpolated. Valid values are "none",
/// "edgeAndCorner" (the default), or "edgeOnly".
///
/// \n C++ Type: TfToken
/// \n Usd Type: SdfValueTypeNames->Token
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: edgeAndCorner
/// \n \ref UsdGeomTokens "Allowed Values": [none, edgeAndCorner, edgeOnly]
UsdAttribute GetInterpolateBoundaryAttr() const;
/// See GetInterpolateBoundaryAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateInterpolateBoundaryAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// FACEVARYINGLINEARINTERPOLATION
// --------------------------------------------------------------------- //
/// Specifies how face varying data is interpolated. Valid values
/// are "all" (no smoothing), "cornersPlus1" (the default, Smooth UV),
/// "none" (Same as "cornersPlus1" but does not infer the presence
/// of corners where two faceVarying edges meet at a single face), or
/// "boundaries" (smooth only near vertices that are not at a
/// discontinuous boundary).
///
/// See http://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#face-varying-interpolation-rules
///
/// \n C++ Type: TfToken
/// \n Usd Type: SdfValueTypeNames->Token
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: cornersPlus1
/// \n \ref UsdGeomTokens "Allowed Values": [all, none, boundaries, cornersOnly, cornersPlus1, cornersPlus2]
UsdAttribute GetFaceVaryingLinearInterpolationAttr() const;
/// See GetFaceVaryingLinearInterpolationAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateFaceVaryingLinearInterpolationAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// HOLEINDICES
// --------------------------------------------------------------------- //
/// The face indices (indexing into the 'faceVertexCounts'
/// attribute) of all faces that should be made invisible.
///
/// \n C++ Type: VtArray<int>
/// \n Usd Type: SdfValueTypeNames->IntArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
UsdAttribute GetHoleIndicesAttr() const;
/// See GetHoleIndicesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateHoleIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CORNERINDICES
// --------------------------------------------------------------------- //
/// The vertex indices of all vertices that are sharp corners.
///
/// \n C++ Type: VtArray<int>
/// \n Usd Type: SdfValueTypeNames->IntArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
UsdAttribute GetCornerIndicesAttr() const;
/// See GetCornerIndicesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateCornerIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CORNERSHARPNESSES
// --------------------------------------------------------------------- //
/// The sharpness values for corners: each corner gets a single
/// sharpness value (Usd.Mesh.SHARPNESS_INFINITE for a perfectly sharp
/// corner), so the size of this array must match that of
/// 'cornerIndices'
///
/// \n C++ Type: VtArray<float>
/// \n Usd Type: SdfValueTypeNames->FloatArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
UsdAttribute GetCornerSharpnessesAttr() const;
/// See GetCornerSharpnessesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateCornerSharpnessesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CREASEINDICES
// --------------------------------------------------------------------- //
/// The indices of all vertices forming creased edges. The size of
/// this array must be equal to the sum of all elements of the
/// 'creaseLengths' attribute.
///
/// \n C++ Type: VtArray<int>
/// \n Usd Type: SdfValueTypeNames->IntArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
UsdAttribute GetCreaseIndicesAttr() const;
/// See GetCreaseIndicesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateCreaseIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CREASELENGTHS
// --------------------------------------------------------------------- //
/// The length of this array specifies the number of creases on the
/// surface. Each element gives the number of (must be adjacent) vertices in
/// each crease, whose indices are linearly laid out in the 'creaseIndices'
/// attribute. Since each crease must be at least one edge long, each
/// element of this array should be greater than one.
///
/// \n C++ Type: VtArray<int>
/// \n Usd Type: SdfValueTypeNames->IntArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
UsdAttribute GetCreaseLengthsAttr() const;
/// See GetCreaseLengthsAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateCreaseLengthsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CREASESHARPNESSES
// --------------------------------------------------------------------- //
/// The per-crease or per-edge sharpness for all creases
/// (Usd.Mesh.SHARPNESS_INFINITE for a perfectly sharp crease). Since
/// 'creaseLengths' encodes the number of vertices in each crease, the
/// number of elements in this array will be either len(creaseLengths) or
/// the sum over all X of (creaseLengths[X] - 1). Note that while
/// the RI spec allows each crease to have either a single sharpness
/// or a value per-edge, USD will encode either a single sharpness
/// per crease on a mesh, or sharpnesses for all edges making up
/// the creases on a mesh.
///
/// \n C++ Type: VtArray<float>
/// \n Usd Type: SdfValueTypeNames->FloatArray
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
UsdAttribute GetCreaseSharpnessesAttr() const;
/// See GetCreaseSharpnessesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
UsdAttribute CreateCreaseSharpnessesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
// the code generator.
//
// Just remember to close the class delcaration with }; and complete the
// include guard with #endif
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
public:
/// \var const float SHARPNESS_INFINITE
/// As an element of a 'creaseSharpness' or 'cornerSharpness' array,
/// indicates that the crease or corner is perfectly sharp.
static const float SHARPNESS_INFINITE;
// A transition API which can read both the new (faceVaryingLinearInterpolation)
// and old(faceVaryingInterpolateBoundary) attributes, but only returns values
// in the new form. This aims to limit the number of consumers which need to
// handle both sets of values.
TfToken GetFaceVaryingLinearInterpolation(
UsdTimeCode time=UsdTimeCode::Default()) const;
};
#endif