HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
generativeProceduralAPI.h
Go to the documentation of this file.
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 USDHYDRA_GENERATED_GENERATIVEPROCEDURALAPI_H
8 #define USDHYDRA_GENERATED_GENERATIVEPROCEDURALAPI_H
9 
10 /// \file usdHydra/generativeProceduralAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdHydra/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // HYDRAGENERATIVEPROCEDURALAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdHydraGenerativeProceduralAPI
37 ///
38 ///
39 /// This API extends and configures the core UsdProcGenerativeProcedural schema
40 /// defined within usdProc for use with hydra generative procedurals as defined
41 /// within hdGp.
42 ///
43 ///
44 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
45 /// that are text/tokens, the actual token is published and defined in \ref UsdHydraTokens.
46 /// So to set an attribute to the value "rightHanded", use UsdHydraTokens->rightHanded
47 /// as the value.
48 ///
50 {
51 public:
52  /// Compile time constant representing what kind of schema this class is.
53  ///
54  /// \sa UsdSchemaKind
56 
57  /// Construct a UsdHydraGenerativeProceduralAPI on UsdPrim \p prim .
58  /// Equivalent to UsdHydraGenerativeProceduralAPI::Get(prim.GetStage(), prim.GetPath())
59  /// for a \em valid \p prim, but will not immediately throw an error for
60  /// an invalid \p prim
62  : UsdAPISchemaBase(prim)
63  {
64  }
65 
66  /// Construct a UsdHydraGenerativeProceduralAPI on the prim held by \p schemaObj .
67  /// Should be preferred over UsdHydraGenerativeProceduralAPI(schemaObj.GetPrim()),
68  /// as it preserves SchemaBase state.
70  : UsdAPISchemaBase(schemaObj)
71  {
72  }
73 
74  /// Destructor.
77 
78  /// Return a vector of names of all pre-declared attributes for this schema
79  /// class and all its ancestor classes. Does not include attributes that
80  /// may be authored by custom/extended methods of the schemas involved.
82  static const TfTokenVector &
83  GetSchemaAttributeNames(bool includeInherited=true);
84 
85  /// Return a UsdHydraGenerativeProceduralAPI holding the prim adhering to this
86  /// schema at \p path on \p stage. If no prim exists at \p path on
87  /// \p stage, or if the prim at that path does not adhere to this schema,
88  /// return an invalid schema object. This is shorthand for the following:
89  ///
90  /// \code
91  /// UsdHydraGenerativeProceduralAPI(stage->GetPrimAtPath(path));
92  /// \endcode
93  ///
96  Get(const UsdStagePtr &stage, const SdfPath &path);
97 
98 
99  /// Returns true if this <b>single-apply</b> API schema can be applied to
100  /// the given \p prim. If this schema can not be a applied to the prim,
101  /// this returns false and, if provided, populates \p whyNot with the
102  /// reason it can not be applied.
103  ///
104  /// Note that if CanApply returns false, that does not necessarily imply
105  /// that calling Apply will fail. Callers are expected to call CanApply
106  /// before calling Apply if they want to ensure that it is valid to
107  /// apply a schema.
108  ///
109  /// \sa UsdPrim::GetAppliedSchemas()
110  /// \sa UsdPrim::HasAPI()
111  /// \sa UsdPrim::CanApplyAPI()
112  /// \sa UsdPrim::ApplyAPI()
113  /// \sa UsdPrim::RemoveAPI()
114  ///
116  static bool
117  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
118 
119  /// Applies this <b>single-apply</b> API schema to the given \p prim.
120  /// This information is stored by adding "HydraGenerativeProceduralAPI" to the
121  /// token-valued, listOp metadata \em apiSchemas on the prim.
122  ///
123  /// \return A valid UsdHydraGenerativeProceduralAPI object is returned upon success.
124  /// An invalid (or empty) UsdHydraGenerativeProceduralAPI object is returned upon
125  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
126  /// resulting in failure.
127  ///
128  /// \sa UsdPrim::GetAppliedSchemas()
129  /// \sa UsdPrim::HasAPI()
130  /// \sa UsdPrim::CanApplyAPI()
131  /// \sa UsdPrim::ApplyAPI()
132  /// \sa UsdPrim::RemoveAPI()
133  ///
136  Apply(const UsdPrim &prim);
137 
138 protected:
139  /// Returns the kind of schema this class belongs to.
140  ///
141  /// \sa UsdSchemaKind
143  UsdSchemaKind _GetSchemaKind() const override;
144 
145 private:
146  // needs to invoke _GetStaticTfType.
147  friend class UsdSchemaRegistry;
149  static const TfType &_GetStaticTfType();
150 
151  static bool _IsTypedSchema();
152 
153  // override SchemaBase virtuals.
155  const TfType &_GetTfType() const override;
156 
157 public:
158  // --------------------------------------------------------------------- //
159  // PROCEDURALTYPE
160  // --------------------------------------------------------------------- //
161  /// The registered name of a HdGpGenerativeProceduralPlugin to
162  /// be executed.
163  ///
164  /// | ||
165  /// | -- | -- |
166  /// | Declaration | `token primvars:hdGp:proceduralType` |
167  /// | C++ Type | TfToken |
168  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
171 
172  /// See GetProceduralTypeAttr(), and also
173  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
174  /// If specified, author \p defaultValue as the attribute's default,
175  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
176  /// the default for \p writeSparsely is \c false.
178  UsdAttribute CreateProceduralTypeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
179 
180 public:
181  // --------------------------------------------------------------------- //
182  // PROCEDURALSYSTEM
183  // --------------------------------------------------------------------- //
184  ///
185  /// This value should correspond to a configured instance of
186  /// HdGpGenerativeProceduralResolvingSceneIndex which will evaluate the
187  /// procedural. The default value of "hydraGenerativeProcedural" matches
188  /// the equivalent default of HdGpGenerativeProceduralResolvingSceneIndex.
189  /// Multiple instances of the scene index can be used to determine where
190  /// within a scene index chain a given procedural will be evaluated.
191  ///
192  ///
193  /// | ||
194  /// | -- | -- |
195  /// | Declaration | `token proceduralSystem = "hydraGenerativeProcedural"` |
196  /// | C++ Type | TfToken |
197  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
200 
201  /// See GetProceduralSystemAttr(), and also
202  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
203  /// If specified, author \p defaultValue as the attribute's default,
204  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
205  /// the default for \p writeSparsely is \c false.
207  UsdAttribute CreateProceduralSystemAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
208 
209 public:
210  // ===================================================================== //
211  // Feel free to add custom code below this line, it will be preserved by
212  // the code generator.
213  //
214  // Just remember to:
215  // - Close the class declaration with };
216  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
217  // - Close the include guard with #endif
218  // ===================================================================== //
219  // --(BEGIN CUSTOM CODE)--
220 };
221 
223 
224 #endif
UsdHydraGenerativeProceduralAPI(const UsdSchemaBase &schemaObj)
USDHYDRA_API UsdAttribute GetProceduralSystemAttr() const
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDHYDRA_API UsdAttribute GetProceduralTypeAttr() const
USDHYDRA_API UsdSchemaKind _GetSchemaKind() const override
#define USDHYDRA_API
Definition: api.h:23
static USDHYDRA_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
static const UsdSchemaKind schemaKind
static USDHYDRA_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
UsdHydraGenerativeProceduralAPI(const UsdPrim &prim=UsdPrim())
USDHYDRA_API UsdAttribute CreateProceduralSystemAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
static USDHYDRA_API UsdHydraGenerativeProceduralAPI Get(const UsdStagePtr &stage, const SdfPath &path)
UsdSchemaKind
Definition: common.h:112
static USDHYDRA_API UsdHydraGenerativeProceduralAPI Apply(const UsdPrim &prim)
USDHYDRA_API UsdAttribute CreateProceduralTypeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
virtual USDHYDRA_API ~UsdHydraGenerativeProceduralAPI()
Destructor.
Definition: value.h:146