HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
meshLightAPI.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 USDLUX_GENERATED_MESHLIGHTAPI_H
8 #define USDLUX_GENERATED_MESHLIGHTAPI_H
9 
10 /// \file usdLux/meshLightAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdLux/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdLux/tokens.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 // MESHLIGHTAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdLuxMeshLightAPI
37 ///
38 /// This is the preferred API schema to apply to
39 /// \ref UsdGeomMesh "Mesh" type prims when adding light behaviors to a mesh.
40 /// At its base, this API schema has the built-in behavior of applying LightAPI
41 /// to the mesh and overriding the default materialSyncMode to allow the
42 /// emission/glow of the bound material to affect the color of the light.
43 /// But, it additionally serves as a hook for plugins to attach additional
44 /// properties to "mesh lights" through the creation of API schemas which are
45 /// authored to auto-apply to MeshLightAPI.
46 /// \see \ref Usd_AutoAppliedAPISchemas
47 ///
48 ///
50 {
51 public:
52  /// Compile time constant representing what kind of schema this class is.
53  ///
54  /// \sa UsdSchemaKind
56 
57  /// Construct a UsdLuxMeshLightAPI on UsdPrim \p prim .
58  /// Equivalent to UsdLuxMeshLightAPI::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
61  explicit UsdLuxMeshLightAPI(const UsdPrim& prim=UsdPrim())
62  : UsdAPISchemaBase(prim)
63  {
64  }
65 
66  /// Construct a UsdLuxMeshLightAPI on the prim held by \p schemaObj .
67  /// Should be preferred over UsdLuxMeshLightAPI(schemaObj.GetPrim()),
68  /// as it preserves SchemaBase state.
69  explicit UsdLuxMeshLightAPI(const UsdSchemaBase& schemaObj)
70  : UsdAPISchemaBase(schemaObj)
71  {
72  }
73 
74  /// Destructor.
76  virtual ~UsdLuxMeshLightAPI();
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 UsdLuxMeshLightAPI 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  /// UsdLuxMeshLightAPI(stage->GetPrimAtPath(path));
92  /// \endcode
93  ///
95  static UsdLuxMeshLightAPI
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  ///
115  USDLUX_API
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 "MeshLightAPI" to the
121  /// token-valued, listOp metadata \em apiSchemas on the prim.
122  ///
123  /// \return A valid UsdLuxMeshLightAPI object is returned upon success.
124  /// An invalid (or empty) UsdLuxMeshLightAPI 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  ///
134  USDLUX_API
135  static UsdLuxMeshLightAPI
136  Apply(const UsdPrim &prim);
137 
138 protected:
139  /// Returns the kind of schema this class belongs to.
140  ///
141  /// \sa UsdSchemaKind
142  USDLUX_API
143  UsdSchemaKind _GetSchemaKind() const override;
144 
145 private:
146  // needs to invoke _GetStaticTfType.
147  friend class UsdSchemaRegistry;
148  USDLUX_API
149  static const TfType &_GetStaticTfType();
150 
151  static bool _IsTypedSchema();
152 
153  // override SchemaBase virtuals.
154  USDLUX_API
155  const TfType &_GetTfType() const override;
156 
157 public:
158  // ===================================================================== //
159  // Feel free to add custom code below this line, it will be preserved by
160  // the code generator.
161  //
162  // Just remember to:
163  // - Close the class declaration with };
164  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
165  // - Close the include guard with #endif
166  // ===================================================================== //
167  // --(BEGIN CUSTOM CODE)--
168 };
169 
171 
172 #endif
static const UsdSchemaKind schemaKind
Definition: meshLightAPI.h:55
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdLuxMeshLightAPI(const UsdSchemaBase &schemaObj)
Definition: meshLightAPI.h:69
#define USDLUX_API
Definition: api.h:23
static USDLUX_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
virtual USDLUX_API ~UsdLuxMeshLightAPI()
Destructor.
static USDLUX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
static USDLUX_API UsdLuxMeshLightAPI Apply(const UsdPrim &prim)
USDLUX_API UsdSchemaKind _GetSchemaKind() const override
UsdLuxMeshLightAPI(const UsdPrim &prim=UsdPrim())
Definition: meshLightAPI.h:61
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
UsdSchemaKind
Definition: common.h:112
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
static USDLUX_API UsdLuxMeshLightAPI Get(const UsdStagePtr &stage, const SdfPath &path)