HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
blendShape.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef USDSKEL_GENERATED_BLENDSHAPE_H
25 #define USDSKEL_GENERATED_BLENDSHAPE_H
26 
27 /// \file usdSkel/blendShape.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdSkel/api.h"
31 #include "pxr/usd/usd/typed.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdSkel/tokens.h"
35 
36 #include "pxr/base/tf/span.h"
38 
39 #include "pxr/base/vt/value.h"
40 
41 #include "pxr/base/gf/vec3d.h"
42 #include "pxr/base/gf/vec3f.h"
43 #include "pxr/base/gf/matrix4d.h"
44 
45 #include "pxr/base/tf/token.h"
46 #include "pxr/base/tf/type.h"
47 
49 
50 class SdfAssetPath;
51 
52 // -------------------------------------------------------------------------- //
53 // BLENDSHAPE //
54 // -------------------------------------------------------------------------- //
55 
56 /// \class UsdSkelBlendShape
57 ///
58 /// Describes a target blend shape, possibly containing inbetween
59 /// shapes.
60 ///
61 /// See the extended \ref UsdSkel_BlendShape "Blend Shape Schema
62 /// documentation for information.
63 ///
64 ///
66 {
67 public:
68  /// Compile time constant representing what kind of schema this class is.
69  ///
70  /// \sa UsdSchemaKind
72 
73  /// Construct a UsdSkelBlendShape on UsdPrim \p prim .
74  /// Equivalent to UsdSkelBlendShape::Get(prim.GetStage(), prim.GetPath())
75  /// for a \em valid \p prim, but will not immediately throw an error for
76  /// an invalid \p prim
77  explicit UsdSkelBlendShape(const UsdPrim& prim=UsdPrim())
78  : UsdTyped(prim)
79  {
80  }
81 
82  /// Construct a UsdSkelBlendShape on the prim held by \p schemaObj .
83  /// Should be preferred over UsdSkelBlendShape(schemaObj.GetPrim()),
84  /// as it preserves SchemaBase state.
85  explicit UsdSkelBlendShape(const UsdSchemaBase& schemaObj)
86  : UsdTyped(schemaObj)
87  {
88  }
89 
90  /// Destructor.
92  virtual ~UsdSkelBlendShape();
93 
94  /// Return a vector of names of all pre-declared attributes for this schema
95  /// class and all its ancestor classes. Does not include attributes that
96  /// may be authored by custom/extended methods of the schemas involved.
98  static const TfTokenVector &
99  GetSchemaAttributeNames(bool includeInherited=true);
100 
101  /// Return a UsdSkelBlendShape holding the prim adhering to this
102  /// schema at \p path on \p stage. If no prim exists at \p path on
103  /// \p stage, or if the prim at that path does not adhere to this schema,
104  /// return an invalid schema object. This is shorthand for the following:
105  ///
106  /// \code
107  /// UsdSkelBlendShape(stage->GetPrimAtPath(path));
108  /// \endcode
109  ///
111  static UsdSkelBlendShape
112  Get(const UsdStagePtr &stage, const SdfPath &path);
113 
114  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
115  /// is defined (according to UsdPrim::IsDefined()) on this stage.
116  ///
117  /// If a prim adhering to this schema at \p path is already defined on this
118  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
119  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
120  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
121  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
122  /// current EditTarget for any nonexistent, or existing but not \a Defined
123  /// ancestors.
124  ///
125  /// The given \a path must be an absolute prim path that does not contain
126  /// any variant selections.
127  ///
128  /// If it is impossible to author any of the necessary PrimSpecs, (for
129  /// example, in case \a path cannot map to the current UsdEditTarget's
130  /// namespace) issue an error and return an invalid \a UsdPrim.
131  ///
132  /// Note that this method may return a defined prim whose typeName does not
133  /// specify this schema class, in case a stronger typeName opinion overrides
134  /// the opinion at the current EditTarget.
135  ///
137  static UsdSkelBlendShape
138  Define(const UsdStagePtr &stage, const SdfPath &path);
139 
140 protected:
141  /// Returns the kind of schema this class belongs to.
142  ///
143  /// \sa UsdSchemaKind
145  UsdSchemaKind _GetSchemaKind() const override;
146 
147 private:
148  // needs to invoke _GetStaticTfType.
149  friend class UsdSchemaRegistry;
151  static const TfType &_GetStaticTfType();
152 
153  static bool _IsTypedSchema();
154 
155  // override SchemaBase virtuals.
157  const TfType &_GetTfType() const override;
158 
159 public:
160  // --------------------------------------------------------------------- //
161  // OFFSETS
162  // --------------------------------------------------------------------- //
163  /// **Required property**. Position offsets which, when added to the
164  /// base pose, provides the target shape.
165  ///
166  /// | ||
167  /// | -- | -- |
168  /// | Declaration | `uniform vector3f[] offsets` |
169  /// | C++ Type | VtArray<GfVec3f> |
170  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
171  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
174 
175  /// See GetOffsetsAttr(), and also
176  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
177  /// If specified, author \p defaultValue as the attribute's default,
178  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
179  /// the default for \p writeSparsely is \c false.
181  UsdAttribute CreateOffsetsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
182 
183 public:
184  // --------------------------------------------------------------------- //
185  // NORMALOFFSETS
186  // --------------------------------------------------------------------- //
187  /// **Required property**. Normal offsets which, when added to the
188  /// base pose, provides the normals of the target shape.
189  ///
190  /// | ||
191  /// | -- | -- |
192  /// | Declaration | `uniform vector3f[] normalOffsets` |
193  /// | C++ Type | VtArray<GfVec3f> |
194  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
195  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
198 
199  /// See GetNormalOffsetsAttr(), and also
200  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
201  /// If specified, author \p defaultValue as the attribute's default,
202  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
203  /// the default for \p writeSparsely is \c false.
205  UsdAttribute CreateNormalOffsetsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
206 
207 public:
208  // --------------------------------------------------------------------- //
209  // POINTINDICES
210  // --------------------------------------------------------------------- //
211  /// **Optional property**. Indices into the original mesh that
212  /// correspond to the values in *offsets* and of any inbetween shapes. If
213  /// authored, the number of elements must be equal to the number of elements
214  /// in the *offsets* array.
215  ///
216  /// | ||
217  /// | -- | -- |
218  /// | Declaration | `uniform int[] pointIndices` |
219  /// | C++ Type | VtArray<int> |
220  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
221  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
224 
225  /// See GetPointIndicesAttr(), and also
226  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
227  /// If specified, author \p defaultValue as the attribute's default,
228  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
229  /// the default for \p writeSparsely is \c false.
231  UsdAttribute CreatePointIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
232 
233 public:
234  // ===================================================================== //
235  // Feel free to add custom code below this line, it will be preserved by
236  // the code generator.
237  //
238  // Just remember to:
239  // - Close the class declaration with };
240  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
241  // - Close the include guard with #endif
242  // ===================================================================== //
243  // --(BEGIN CUSTOM CODE)--
244 
245  /// Author scene description to create an attribute on this prim that
246  /// will be recognized as an Inbetween (i.e. will present as a valid
247  /// UsdSkelInbetweenShape).
248  ///
249  /// The name of the created attribute or may or may not be the specified
250  /// \p attrName, due to the possible need to apply property namespacing.
251  /// Creation may fail and return an invalid Inbetwen if \p attrName
252  /// contains a reserved keyword.
253  ///
254  /// \return an invalid UsdSkelInbetweenShape if we failed to create a valid
255  /// attribute, a valid UsdSkelInbetweenShape otherwise. It is not an error
256  /// to create over an existing, compatible attribute.
257  ///
258  /// \sa UsdSkelInbetweenShape::IsInbetween()
261 
262  /// Return the Inbetween corresponding to the attribute named \p name,
263  /// which will be valid if an Inbetween attribute definition already exists.
264  ///
265  /// Name lookup will account for Inbetween namespacing, which means that
266  /// this method will succeed in some cases where
267  /// `UsdSkelInbetweenShape(prim->GetAttribute(name))` will not, unless
268  /// \p name has the proper namespace prefix.
269  ///
270  /// \sa HasInbetween()
273 
274  /// Return true if there is a defined Inbetween named \p name on this prim.
275  ///
276  /// Name lookup will account for Inbetween namespacing.
277  ///
278  /// \sa GetInbetween()
280  bool HasInbetween(const TfToken& name) const;
281 
282  /// Return valid UsdSkelInbetweenShape objects for all defined Inbetweens on
283  /// this prim.
285  std::vector<UsdSkelInbetweenShape> GetInbetweens() const;
286 
287  /// Like GetInbetweens(), but exclude inbetwens that have no authored scene
288  //// description.
290  std::vector<UsdSkelInbetweenShape> GetAuthoredInbetweens() const;
291 
292  /// Validates a set of point indices for a given point count.
293  /// This ensures that all point indices are in the range [0, numPoints).
294  /// Returns true if the indices are valid, or false otherwise.
295  /// If invalid and \p reason is non-null, an error message describing
296  /// the first validation error will be set.
299  size_t numPoints,
300  std::string* reason=nullptr);
301 
302 private:
303  std::vector<UsdSkelInbetweenShape>
304  _MakeInbetweens(const std::vector<UsdProperty>& props) const;
305 };
306 
308 
309 #endif
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
USDSKEL_API UsdSkelInbetweenShape GetInbetween(const TfToken &name) const
USDSKEL_API UsdSkelInbetweenShape CreateInbetween(const TfToken &name) const
USDSKEL_API std::vector< UsdSkelInbetweenShape > GetAuthoredInbetweens() const
Like GetInbetweens(), but exclude inbetwens that have no authored scene / description.
USDSKEL_API UsdAttribute GetPointIndicesAttr() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDSKEL_API UsdSkelBlendShape Define(const UsdStagePtr &stage, const SdfPath &path)
static USDSKEL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDSKEL_API UsdAttribute GetOffsetsAttr() const
UsdSkelBlendShape(const UsdPrim &prim=UsdPrim())
Definition: blendShape.h:77
Definition: token.h:87
Represents a concrete typed schema.
Definition: span.h:87
USDSKEL_API UsdAttribute CreatePointIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:135
Definition: typed.h:61
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
GLuint const GLchar * name
Definition: glcorearb.h:786
USDSKEL_API std::vector< UsdSkelInbetweenShape > GetInbetweens() const
#define USDSKEL_API
Definition: api.h:40
Definition: path.h:291
USDSKEL_API UsdAttribute GetNormalOffsetsAttr() const
USDSKEL_API UsdSchemaKind _GetSchemaKind() const override
USDSKEL_API UsdAttribute CreateOffsetsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:127
USDSKEL_API UsdAttribute CreateNormalOffsetsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDSKEL_API UsdSkelBlendShape Get(const UsdStagePtr &stage, const SdfPath &path)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
USDSKEL_API bool HasInbetween(const TfToken &name) const
UsdSkelBlendShape(const UsdSchemaBase &schemaObj)
Definition: blendShape.h:85
static const UsdSchemaKind schemaKind
Definition: blendShape.h:71
Definition: value.h:167
static USDSKEL_API bool ValidatePointIndices(TfSpan< const int > indices, size_t numPoints, std::string *reason=nullptr)
virtual USDSKEL_API ~UsdSkelBlendShape()
Destructor.
GLenum GLuint GLsizei const GLenum * props
Definition: glcorearb.h:2525