HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shapingAPI.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 USDLUX_GENERATED_SHAPINGAPI_H
25 #define USDLUX_GENERATED_SHAPINGAPI_H
26 
27 /// \file usdLux/shapingAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdLux/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdLux/tokens.h"
35 
36 #include "pxr/usd/usdShade/input.h"
37 #include "pxr/usd/usdShade/output.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 // SHAPINGAPI //
54 // -------------------------------------------------------------------------- //
55 
56 /// \class UsdLuxShapingAPI
57 ///
58 /// Controls for shaping a light's emission.
59 ///
61 {
62 public:
63  /// Compile time constant representing what kind of schema this class is.
64  ///
65  /// \sa UsdSchemaKind
67 
68  /// Construct a UsdLuxShapingAPI on UsdPrim \p prim .
69  /// Equivalent to UsdLuxShapingAPI::Get(prim.GetStage(), prim.GetPath())
70  /// for a \em valid \p prim, but will not immediately throw an error for
71  /// an invalid \p prim
72  explicit UsdLuxShapingAPI(const UsdPrim& prim=UsdPrim())
73  : UsdAPISchemaBase(prim)
74  {
75  }
76 
77  /// Construct a UsdLuxShapingAPI on the prim held by \p schemaObj .
78  /// Should be preferred over UsdLuxShapingAPI(schemaObj.GetPrim()),
79  /// as it preserves SchemaBase state.
80  explicit UsdLuxShapingAPI(const UsdSchemaBase& schemaObj)
81  : UsdAPISchemaBase(schemaObj)
82  {
83  }
84 
85  /// Destructor.
87  virtual ~UsdLuxShapingAPI();
88 
89  /// Return a vector of names of all pre-declared attributes for this schema
90  /// class and all its ancestor classes. Does not include attributes that
91  /// may be authored by custom/extended methods of the schemas involved.
93  static const TfTokenVector &
94  GetSchemaAttributeNames(bool includeInherited=true);
95 
96  /// Return a UsdLuxShapingAPI holding the prim adhering to this
97  /// schema at \p path on \p stage. If no prim exists at \p path on
98  /// \p stage, or if the prim at that path does not adhere to this schema,
99  /// return an invalid schema object. This is shorthand for the following:
100  ///
101  /// \code
102  /// UsdLuxShapingAPI(stage->GetPrimAtPath(path));
103  /// \endcode
104  ///
105  USDLUX_API
106  static UsdLuxShapingAPI
107  Get(const UsdStagePtr &stage, const SdfPath &path);
108 
109 
110  /// Returns true if this <b>single-apply</b> API schema can be applied to
111  /// the given \p prim. If this schema can not be a applied to the prim,
112  /// this returns false and, if provided, populates \p whyNot with the
113  /// reason it can not be applied.
114  ///
115  /// Note that if CanApply returns false, that does not necessarily imply
116  /// that calling Apply will fail. Callers are expected to call CanApply
117  /// before calling Apply if they want to ensure that it is valid to
118  /// apply a schema.
119  ///
120  /// \sa UsdPrim::GetAppliedSchemas()
121  /// \sa UsdPrim::HasAPI()
122  /// \sa UsdPrim::CanApplyAPI()
123  /// \sa UsdPrim::ApplyAPI()
124  /// \sa UsdPrim::RemoveAPI()
125  ///
126  USDLUX_API
127  static bool
128  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
129 
130  /// Applies this <b>single-apply</b> API schema to the given \p prim.
131  /// This information is stored by adding "ShapingAPI" to the
132  /// token-valued, listOp metadata \em apiSchemas on the prim.
133  ///
134  /// \return A valid UsdLuxShapingAPI object is returned upon success.
135  /// An invalid (or empty) UsdLuxShapingAPI object is returned upon
136  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
137  /// resulting in failure.
138  ///
139  /// \sa UsdPrim::GetAppliedSchemas()
140  /// \sa UsdPrim::HasAPI()
141  /// \sa UsdPrim::CanApplyAPI()
142  /// \sa UsdPrim::ApplyAPI()
143  /// \sa UsdPrim::RemoveAPI()
144  ///
145  USDLUX_API
146  static UsdLuxShapingAPI
147  Apply(const UsdPrim &prim);
148 
149 protected:
150  /// Returns the kind of schema this class belongs to.
151  ///
152  /// \sa UsdSchemaKind
153  USDLUX_API
154  UsdSchemaKind _GetSchemaKind() const override;
155 
156 private:
157  // needs to invoke _GetStaticTfType.
158  friend class UsdSchemaRegistry;
159  USDLUX_API
160  static const TfType &_GetStaticTfType();
161 
162  static bool _IsTypedSchema();
163 
164  // override SchemaBase virtuals.
165  USDLUX_API
166  const TfType &_GetTfType() const override;
167 
168 public:
169  // --------------------------------------------------------------------- //
170  // SHAPING:FOCUS
171  // --------------------------------------------------------------------- //
172  /// A control to shape the spread of light. Higher focus
173  /// values pull light towards the center and narrow the spread.
174  /// Implemented as an off-axis cosine power exponent.
175  /// TODO: clarify semantics
176  ///
177  /// | ||
178  /// | -- | -- |
179  /// | Declaration | `float inputs:shaping:focus = 0` |
180  /// | C++ Type | float |
181  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
182  USDLUX_API
184 
185  /// See GetShapingFocusAttr(), and also
186  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
187  /// If specified, author \p defaultValue as the attribute's default,
188  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
189  /// the default for \p writeSparsely is \c false.
190  USDLUX_API
191  UsdAttribute CreateShapingFocusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
192 
193 public:
194  // --------------------------------------------------------------------- //
195  // SHAPING:FOCUSTINT
196  // --------------------------------------------------------------------- //
197  /// Off-axis color tint. This tints the emission in the
198  /// falloff region. The default tint is black.
199  /// TODO: clarify semantics
200  ///
201  /// | ||
202  /// | -- | -- |
203  /// | Declaration | `color3f inputs:shaping:focusTint = (0, 0, 0)` |
204  /// | C++ Type | GfVec3f |
205  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3f |
206  USDLUX_API
208 
209  /// See GetShapingFocusTintAttr(), and also
210  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
211  /// If specified, author \p defaultValue as the attribute's default,
212  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
213  /// the default for \p writeSparsely is \c false.
214  USDLUX_API
215  UsdAttribute CreateShapingFocusTintAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
216 
217 public:
218  // --------------------------------------------------------------------- //
219  // SHAPING:CONE:ANGLE
220  // --------------------------------------------------------------------- //
221  /// Angular limit off the primary axis to restrict the
222  /// light spread.
223  ///
224  /// | ||
225  /// | -- | -- |
226  /// | Declaration | `float inputs:shaping:cone:angle = 90` |
227  /// | C++ Type | float |
228  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
229  USDLUX_API
231 
232  /// See GetShapingConeAngleAttr(), and also
233  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
234  /// If specified, author \p defaultValue as the attribute's default,
235  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
236  /// the default for \p writeSparsely is \c false.
237  USDLUX_API
238  UsdAttribute CreateShapingConeAngleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
239 
240 public:
241  // --------------------------------------------------------------------- //
242  // SHAPING:CONE:SOFTNESS
243  // --------------------------------------------------------------------- //
244  /// Controls the cutoff softness for cone angle.
245  /// TODO: clarify semantics
246  ///
247  /// | ||
248  /// | -- | -- |
249  /// | Declaration | `float inputs:shaping:cone:softness = 0` |
250  /// | C++ Type | float |
251  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
252  USDLUX_API
254 
255  /// See GetShapingConeSoftnessAttr(), and also
256  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
257  /// If specified, author \p defaultValue as the attribute's default,
258  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
259  /// the default for \p writeSparsely is \c false.
260  USDLUX_API
261  UsdAttribute CreateShapingConeSoftnessAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
262 
263 public:
264  // --------------------------------------------------------------------- //
265  // SHAPING:IES:FILE
266  // --------------------------------------------------------------------- //
267  /// An IES (Illumination Engineering Society) light
268  /// profile describing the angular distribution of light.
269  ///
270  /// | ||
271  /// | -- | -- |
272  /// | Declaration | `asset inputs:shaping:ies:file` |
273  /// | C++ Type | SdfAssetPath |
274  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
275  USDLUX_API
277 
278  /// See GetShapingIesFileAttr(), and also
279  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
280  /// If specified, author \p defaultValue as the attribute's default,
281  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
282  /// the default for \p writeSparsely is \c false.
283  USDLUX_API
284  UsdAttribute CreateShapingIesFileAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
285 
286 public:
287  // --------------------------------------------------------------------- //
288  // SHAPING:IES:ANGLESCALE
289  // --------------------------------------------------------------------- //
290  /// Rescales the angular distribution of the IES profile.
291  /// TODO: clarify semantics
292  ///
293  /// | ||
294  /// | -- | -- |
295  /// | Declaration | `float inputs:shaping:ies:angleScale = 0` |
296  /// | C++ Type | float |
297  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
298  USDLUX_API
300 
301  /// See GetShapingIesAngleScaleAttr(), and also
302  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
303  /// If specified, author \p defaultValue as the attribute's default,
304  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
305  /// the default for \p writeSparsely is \c false.
306  USDLUX_API
307  UsdAttribute CreateShapingIesAngleScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
308 
309 public:
310  // --------------------------------------------------------------------- //
311  // SHAPING:IES:NORMALIZE
312  // --------------------------------------------------------------------- //
313  /// Normalizes the IES profile so that it affects the shaping
314  /// of the light while preserving the overall energy output.
315  ///
316  /// | ||
317  /// | -- | -- |
318  /// | Declaration | `bool inputs:shaping:ies:normalize = 0` |
319  /// | C++ Type | bool |
320  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
321  USDLUX_API
323 
324  /// See GetShapingIesNormalizeAttr(), and also
325  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
326  /// If specified, author \p defaultValue as the attribute's default,
327  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
328  /// the default for \p writeSparsely is \c false.
329  USDLUX_API
330  UsdAttribute CreateShapingIesNormalizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
331 
332 public:
333  // ===================================================================== //
334  // Feel free to add custom code below this line, it will be preserved by
335  // the code generator.
336  //
337  // Just remember to:
338  // - Close the class declaration with };
339  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
340  // - Close the include guard with #endif
341  // ===================================================================== //
342  // --(BEGIN CUSTOM CODE)--
343 
344  // -------------------------------------------------------------------------
345  /// \name Conversion to and from UsdShadeConnectableAPI
346  ///
347  /// @{
348 
349  /// Constructor that takes a ConnectableAPI object.
350  /// Allow implicit conversion of UsdShadeConnectableAPI to
351  /// UsdLuxShapingAPI.
352  USDLUX_API
353  UsdLuxShapingAPI(const UsdShadeConnectableAPI &connectable);
354 
355  /// Contructs and returns a UsdShadeConnectableAPI object with this shaping
356  /// API prim. Note that a valid UsdLuxShapingAPI will only return a valid
357  /// UsdShadeConnectableAPI if the its prim's Typed schema type is actually
358  /// connectable.
359  USDLUX_API
361 
362  /// @}
363 
364  // -------------------------------------------------------------------------
365  /// \name Outputs API
366  ///
367  /// Outputs represent a typed attribute on a shaping API whose value is
368  /// computed externally.
369  ///
370  /// @{
371 
372  /// Create an output which can either have a value or can be connected.
373  /// The attribute representing the output is created in the "outputs:"
374  /// namespace. Outputs on a shaping API cannot be connected, as their
375  /// value is assumed to be computed externally.
376  ///
377  USDLUX_API
379  const SdfValueTypeName& typeName);
380 
381  /// Return the requested output if it exists.
382  ///
383  USDLUX_API
384  UsdShadeOutput GetOutput(const TfToken &name) const;
385 
386  /// Outputs are represented by attributes in the "outputs:" namespace.
387  /// If \p onlyAuthored is true (the default), then only return authored
388  /// attributes; otherwise, this also returns un-authored builtins.
389  ///
390  USDLUX_API
391  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
392 
393  /// @}
394 
395  // -------------------------------------------------------------------------
396 
397  /// \name Inputs API
398  ///
399  /// Inputs are connectable attribute with a typed value.
400  ///
401  /// Shaping API parameters are encoded as inputs.
402  ///
403  /// @{
404 
405  /// Create an input which can either have a value or can be connected.
406  /// The attribute representing the input is created in the "inputs:"
407  /// namespace. Inputs on shaping API are connectable.
408  ///
409  USDLUX_API
411  const SdfValueTypeName& typeName);
412 
413  /// Return the requested input if it exists.
414  ///
415  USDLUX_API
416  UsdShadeInput GetInput(const TfToken &name) const;
417 
418  /// Inputs are represented by attributes in the "inputs:" namespace.
419  /// If \p onlyAuthored is true (the default), then only return authored
420  /// attributes; otherwise, this also returns un-authored builtins.
421  ///
422  USDLUX_API
423  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
424 
425  /// @}
426 };
427 
429 
430 #endif
USDLUX_API UsdAttribute CreateShapingConeSoftnessAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
static USDLUX_API UsdLuxShapingAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USDLUX_API UsdAttribute GetShapingConeAngleAttr() const
USDLUX_API UsdAttribute CreateShapingIesNormalizeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdShadeConnectableAPI ConnectableAPI() const
USDLUX_API UsdAttribute CreateShapingFocusTintAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdLuxShapingAPI(const UsdPrim &prim=UsdPrim())
Definition: shapingAPI.h:72
#define USDLUX_API
Definition: api.h:40
USDLUX_API UsdAttribute GetShapingIesNormalizeAttr() const
static const UsdSchemaKind schemaKind
Definition: shapingAPI.h:66
USDLUX_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName)
GLuint const GLchar * name
Definition: glcorearb.h:786
USDLUX_API UsdAttribute CreateShapingIesFileAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdShadeOutput GetOutput(const TfToken &name) const
USDLUX_API UsdAttribute CreateShapingFocusAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:127
Single Apply API schema.
Definition: token.h:87
USDLUX_API UsdAttribute GetShapingConeSoftnessAttr() const
static USDLUX_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
static USDLUX_API UsdLuxShapingAPI Apply(const UsdPrim &prim)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
USDLUX_API UsdShadeInput GetInput(const TfToken &name) const
USDLUX_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
USDLUX_API UsdAttribute CreateShapingConeAngleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
virtual USDLUX_API ~UsdLuxShapingAPI()
Destructor.
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
Definition: path.h:290
USDLUX_API UsdAttribute GetShapingIesFileAttr() const
USDLUX_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
USDLUX_API UsdAttribute GetShapingIesAngleScaleAttr() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
USDLUX_API UsdAttribute GetShapingFocusAttr() const
USDLUX_API UsdAttribute GetShapingFocusTintAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
static USDLUX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDLUX_API UsdSchemaKind _GetSchemaKind() const override
UsdLuxShapingAPI(const UsdSchemaBase &schemaObj)
Definition: shapingAPI.h:80
USDLUX_API UsdAttribute CreateShapingIesAngleScaleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:166