HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
motionAPI.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 USDGEOM_GENERATED_MOTIONAPI_H
25 #define USDGEOM_GENERATED_MOTIONAPI_H
26 
27 /// \file usdGeom/motionAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdGeom/tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // MOTIONAPI //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdGeomMotionAPI
54 ///
55 /// UsdGeomMotionAPI encodes data that can live on any prim that
56 /// may affect computations involving:
57 /// - computed motion for motion blur
58 /// - sampling for motion blur
59 ///
60 /// The \ref GetMotionBlurScaleAttr() "motion:blurScale" attribute allows
61 /// artists to scale the __amount__ of motion blur to be rendered for parts
62 /// of the scene without changing the recorded animation. See
63 /// \ref UsdGeomMotionAPI_blurScale for use and implementation details.
64 ///
65 ///
66 ///
68 {
69 public:
70  /// Compile time constant representing what kind of schema this class is.
71  ///
72  /// \sa UsdSchemaKind
74 
75  /// Construct a UsdGeomMotionAPI on UsdPrim \p prim .
76  /// Equivalent to UsdGeomMotionAPI::Get(prim.GetStage(), prim.GetPath())
77  /// for a \em valid \p prim, but will not immediately throw an error for
78  /// an invalid \p prim
79  explicit UsdGeomMotionAPI(const UsdPrim& prim=UsdPrim())
80  : UsdAPISchemaBase(prim)
81  {
82  }
83 
84  /// Construct a UsdGeomMotionAPI on the prim held by \p schemaObj .
85  /// Should be preferred over UsdGeomMotionAPI(schemaObj.GetPrim()),
86  /// as it preserves SchemaBase state.
87  explicit UsdGeomMotionAPI(const UsdSchemaBase& schemaObj)
88  : UsdAPISchemaBase(schemaObj)
89  {
90  }
91 
92  /// Destructor.
94  virtual ~UsdGeomMotionAPI();
95 
96  /// Return a vector of names of all pre-declared attributes for this schema
97  /// class and all its ancestor classes. Does not include attributes that
98  /// may be authored by custom/extended methods of the schemas involved.
100  static const TfTokenVector &
101  GetSchemaAttributeNames(bool includeInherited=true);
102 
103  /// Return a UsdGeomMotionAPI holding the prim adhering to this
104  /// schema at \p path on \p stage. If no prim exists at \p path on
105  /// \p stage, or if the prim at that path does not adhere to this schema,
106  /// return an invalid schema object. This is shorthand for the following:
107  ///
108  /// \code
109  /// UsdGeomMotionAPI(stage->GetPrimAtPath(path));
110  /// \endcode
111  ///
113  static UsdGeomMotionAPI
114  Get(const UsdStagePtr &stage, const SdfPath &path);
115 
116 
117  /// Returns true if this <b>single-apply</b> API schema can be applied to
118  /// the given \p prim. If this schema can not be a applied to the prim,
119  /// this returns false and, if provided, populates \p whyNot with the
120  /// reason it can not be applied.
121  ///
122  /// Note that if CanApply returns false, that does not necessarily imply
123  /// that calling Apply will fail. Callers are expected to call CanApply
124  /// before calling Apply if they want to ensure that it is valid to
125  /// apply a schema.
126  ///
127  /// \sa UsdPrim::GetAppliedSchemas()
128  /// \sa UsdPrim::HasAPI()
129  /// \sa UsdPrim::CanApplyAPI()
130  /// \sa UsdPrim::ApplyAPI()
131  /// \sa UsdPrim::RemoveAPI()
132  ///
134  static bool
135  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
136 
137  /// Applies this <b>single-apply</b> API schema to the given \p prim.
138  /// This information is stored by adding "MotionAPI" to the
139  /// token-valued, listOp metadata \em apiSchemas on the prim.
140  ///
141  /// \return A valid UsdGeomMotionAPI object is returned upon success.
142  /// An invalid (or empty) UsdGeomMotionAPI object is returned upon
143  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
144  /// resulting in failure.
145  ///
146  /// \sa UsdPrim::GetAppliedSchemas()
147  /// \sa UsdPrim::HasAPI()
148  /// \sa UsdPrim::CanApplyAPI()
149  /// \sa UsdPrim::ApplyAPI()
150  /// \sa UsdPrim::RemoveAPI()
151  ///
153  static UsdGeomMotionAPI
154  Apply(const UsdPrim &prim);
155 
156 protected:
157  /// Returns the kind of schema this class belongs to.
158  ///
159  /// \sa UsdSchemaKind
161  UsdSchemaKind _GetSchemaKind() const override;
162 
163 private:
164  // needs to invoke _GetStaticTfType.
165  friend class UsdSchemaRegistry;
167  static const TfType &_GetStaticTfType();
168 
169  static bool _IsTypedSchema();
170 
171  // override SchemaBase virtuals.
173  const TfType &_GetTfType() const override;
174 
175 public:
176  // --------------------------------------------------------------------- //
177  // MOTIONBLURSCALE
178  // --------------------------------------------------------------------- //
179  /// BlurScale is an __inherited__ float attribute that stipulates
180  /// the rendered motion blur (as typically specified via UsdGeomCamera's
181  /// _shutter:open_ and _shutter:close_ properties) should be scaled for
182  /// __all objects__ at and beneath the prim in namespace on which the
183  /// _motion:blurScale_ value is specified.
184  ///
185  /// Without changing any other data in the scene, _blurScale_ allows artists to
186  /// "dial in" the amount of blur on a per-object basis. A _blurScale_
187  /// value of zero removes all blur, a value of 0.5 reduces blur by half,
188  /// and a value of 2.0 doubles the blur. The legal range for _blurScale_
189  /// is [0, inf), although very high values may result in extremely expensive
190  /// renders, and may exceed the capabilities of some renderers.
191  ///
192  /// Although renderers are free to implement this feature however they see
193  /// fit, see \ref UsdGeomMotionAPI_blurScale for our guidance on implementing
194  /// the feature universally and efficiently.
195  ///
196  /// \sa ComputeMotionBlurScale()
197  ///
198  ///
199  /// | ||
200  /// | -- | -- |
201  /// | Declaration | `float motion:blurScale = 1` |
202  /// | C++ Type | float |
203  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
206 
207  /// See GetMotionBlurScaleAttr(), and also
208  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
209  /// If specified, author \p defaultValue as the attribute's default,
210  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
211  /// the default for \p writeSparsely is \c false.
213  UsdAttribute CreateMotionBlurScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
214 
215 public:
216  // --------------------------------------------------------------------- //
217  // VELOCITYSCALE
218  // --------------------------------------------------------------------- //
219  /// \deprecated
220  ///
221  /// VelocityScale is an **inherited** float attribute that
222  /// velocity-based schemas (e.g. PointBased, PointInstancer) can consume
223  /// to compute interpolated positions and orientations by applying
224  /// velocity and angularVelocity, which is required for interpolating
225  /// between samples when topology is varying over time. Although these
226  /// quantities are generally physically computed by a simulator, sometimes
227  /// we require more or less motion-blur to achieve the desired look.
228  /// VelocityScale allows artists to dial-in, as a post-sim correction,
229  /// a scale factor to be applied to the velocity prior to computing
230  /// interpolated positions from it.
231  ///
232  /// | ||
233  /// | -- | -- |
234  /// | Declaration | `float motion:velocityScale = 1` |
235  /// | C++ Type | float |
236  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
239 
240  /// See GetVelocityScaleAttr(), and also
241  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
242  /// If specified, author \p defaultValue as the attribute's default,
243  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
244  /// the default for \p writeSparsely is \c false.
246  UsdAttribute CreateVelocityScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
247 
248 public:
249  // --------------------------------------------------------------------- //
250  // NONLINEARSAMPLECOUNT
251  // --------------------------------------------------------------------- //
252  /// Determines the number of position or transformation samples
253  /// created when motion is described by attributes contributing non-linear
254  /// terms.
255  ///
256  /// To give an example, imagine an application (such as a
257  /// renderer) consuming 'points' and the USD document also
258  /// contains 'accelerations' for the same prim. Unless the
259  /// application can consume these 'accelerations' itself, an
260  /// intermediate layer has to compute samples within the sampling
261  /// interval for the point positions based on the value of
262  /// 'points', 'velocities' and 'accelerations'. The number of these
263  /// samples is given by 'nonlinearSampleCount'. The samples are
264  /// equally spaced within the sampling interval.
265  ///
266  /// Another example involves the PointInstancer where
267  /// 'nonlinearSampleCount' is relevant when 'angularVelocities'
268  /// or 'accelerations' are authored.
269  ///
270  /// 'nonlinearSampleCount' is an **inherited** attribute, also
271  /// see ComputeNonlinearSampleCount()
272  ///
273  /// | ||
274  /// | -- | -- |
275  /// | Declaration | `int motion:nonlinearSampleCount = 3` |
276  /// | C++ Type | int |
277  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
280 
281  /// See GetNonlinearSampleCountAttr(), and also
282  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
283  /// If specified, author \p defaultValue as the attribute's default,
284  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
285  /// the default for \p writeSparsely is \c false.
287  UsdAttribute CreateNonlinearSampleCountAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
288 
289 public:
290  // ===================================================================== //
291  // Feel free to add custom code below this line, it will be preserved by
292  // the code generator.
293  //
294  // Just remember to:
295  // - Close the class declaration with };
296  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
297  // - Close the include guard with #endif
298  // ===================================================================== //
299  // --(BEGIN CUSTOM CODE)--
300 
301  /// \deprecated
302  ///
303  /// Compute the inherited value of *velocityScale* at \p time, i.e. the
304  /// authored value on the prim closest to this prim in namespace, resolved
305  /// upwards through its ancestors in namespace.
306  ///
307  /// \return the inherited value, or 1.0 if neither the prim nor any
308  /// of its ancestors possesses an authored value.
309  ///
310  /// \note this is a reference implementation that is not particularly
311  /// efficient if evaluating over many prims, because it does not share
312  /// inherited results.
315 
316  /// Compute the inherited value of *nonlinearSampleCount* at \p time,
317  /// i.e. the authored value on the prim closest to this prim in namespace,
318  /// resolved upwards through its ancestors in namespace.
319  ///
320  /// \return the inherited value, or 3 if neither the prim nor any
321  /// of its ancestors possesses an authored value.
322  ///
323  /// \note this is a reference implementation that is not particularly
324  /// efficient if evaluating over many prims, because it does not share
325  /// inherited results.
329 
330  /// Compute the inherited value of *motion:blurScale* at \p time, i.e. the
331  /// authored value on the prim closest to this prim in namespace, resolved
332  /// upwards through its ancestors in namespace.
333  ///
334  /// \return the inherited value, or 1.0 if neither the prim nor any
335  /// of its ancestors possesses an authored value.
336  ///
337  /// \note this is a reference implementation that is not particularly
338  /// efficient if evaluating over many prims, because it does not share
339  /// inherited results.
343 
344 };
345 
347 
348 #endif
static const UsdSchemaKind schemaKind
Definition: motionAPI.h:73
static constexpr UsdTimeCode Default()
Definition: timeCode.h:112
USDGEOM_API UsdAttribute CreateMotionBlurScaleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
GT_API const UT_StringHolder time
Single Apply API schema.
USDGEOM_API UsdAttribute GetMotionBlurScaleAttr() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDGEOM_API UsdAttribute CreateVelocityScaleAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API int ComputeNonlinearSampleCount(UsdTimeCode time=UsdTimeCode::Default()) const
USDGEOM_API UsdAttribute GetVelocityScaleAttr() const
UsdGeomMotionAPI(const UsdSchemaBase &schemaObj)
Definition: motionAPI.h:87
USDGEOM_API float ComputeMotionBlurScale(UsdTimeCode time=UsdTimeCode::Default()) const
USDGEOM_API UsdAttribute GetNonlinearSampleCountAttr() const
UsdGeomMotionAPI(const UsdPrim &prim=UsdPrim())
Definition: motionAPI.h:79
Definition: prim.h:135
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
Definition: path.h:291
USDGEOM_API UsdAttribute CreateNonlinearSampleCountAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API float ComputeVelocityScale(UsdTimeCode time=UsdTimeCode::Default()) const
UsdSchemaKind
Definition: common.h:127
static USDGEOM_API UsdGeomMotionAPI Apply(const UsdPrim &prim)
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
virtual USDGEOM_API ~UsdGeomMotionAPI()
Destructor.
#define USDGEOM_API
Definition: api.h:40
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
static USDGEOM_API UsdGeomMotionAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:167
static USDGEOM_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)