HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialAPI.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 USDPHYSICS_GENERATED_MATERIALAPI_H
8 #define USDPHYSICS_GENERATED_MATERIALAPI_H
9 
10 /// \file usdPhysics/materialAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdPhysics/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 // PHYSICSMATERIALAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdPhysicsMaterialAPI
37 ///
38 /// Adds simulation material properties to a Material. All collisions
39 /// that have a relationship to this material will have their collision response
40 /// defined through this material.
41 ///
43 {
44 public:
45  /// Compile time constant representing what kind of schema this class is.
46  ///
47  /// \sa UsdSchemaKind
49 
50  /// Construct a UsdPhysicsMaterialAPI on UsdPrim \p prim .
51  /// Equivalent to UsdPhysicsMaterialAPI::Get(prim.GetStage(), prim.GetPath())
52  /// for a \em valid \p prim, but will not immediately throw an error for
53  /// an invalid \p prim
54  explicit UsdPhysicsMaterialAPI(const UsdPrim& prim=UsdPrim())
55  : UsdAPISchemaBase(prim)
56  {
57  }
58 
59  /// Construct a UsdPhysicsMaterialAPI on the prim held by \p schemaObj .
60  /// Should be preferred over UsdPhysicsMaterialAPI(schemaObj.GetPrim()),
61  /// as it preserves SchemaBase state.
62  explicit UsdPhysicsMaterialAPI(const UsdSchemaBase& schemaObj)
63  : UsdAPISchemaBase(schemaObj)
64  {
65  }
66 
67  /// Destructor.
69  virtual ~UsdPhysicsMaterialAPI();
70 
71  /// Return a vector of names of all pre-declared attributes for this schema
72  /// class and all its ancestor classes. Does not include attributes that
73  /// may be authored by custom/extended methods of the schemas involved.
75  static const TfTokenVector &
76  GetSchemaAttributeNames(bool includeInherited=true);
77 
78  /// Return a UsdPhysicsMaterialAPI holding the prim adhering to this
79  /// schema at \p path on \p stage. If no prim exists at \p path on
80  /// \p stage, or if the prim at that path does not adhere to this schema,
81  /// return an invalid schema object. This is shorthand for the following:
82  ///
83  /// \code
84  /// UsdPhysicsMaterialAPI(stage->GetPrimAtPath(path));
85  /// \endcode
86  ///
89  Get(const UsdStagePtr &stage, const SdfPath &path);
90 
91 
92  /// Returns true if this <b>single-apply</b> API schema can be applied to
93  /// the given \p prim. If this schema can not be a applied to the prim,
94  /// this returns false and, if provided, populates \p whyNot with the
95  /// reason it can not be applied.
96  ///
97  /// Note that if CanApply returns false, that does not necessarily imply
98  /// that calling Apply will fail. Callers are expected to call CanApply
99  /// before calling Apply if they want to ensure that it is valid to
100  /// apply a schema.
101  ///
102  /// \sa UsdPrim::GetAppliedSchemas()
103  /// \sa UsdPrim::HasAPI()
104  /// \sa UsdPrim::CanApplyAPI()
105  /// \sa UsdPrim::ApplyAPI()
106  /// \sa UsdPrim::RemoveAPI()
107  ///
109  static bool
110  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
111 
112  /// Applies this <b>single-apply</b> API schema to the given \p prim.
113  /// This information is stored by adding "PhysicsMaterialAPI" to the
114  /// token-valued, listOp metadata \em apiSchemas on the prim.
115  ///
116  /// \return A valid UsdPhysicsMaterialAPI object is returned upon success.
117  /// An invalid (or empty) UsdPhysicsMaterialAPI object is returned upon
118  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
119  /// resulting in failure.
120  ///
121  /// \sa UsdPrim::GetAppliedSchemas()
122  /// \sa UsdPrim::HasAPI()
123  /// \sa UsdPrim::CanApplyAPI()
124  /// \sa UsdPrim::ApplyAPI()
125  /// \sa UsdPrim::RemoveAPI()
126  ///
128  static UsdPhysicsMaterialAPI
129  Apply(const UsdPrim &prim);
130 
131 protected:
132  /// Returns the kind of schema this class belongs to.
133  ///
134  /// \sa UsdSchemaKind
136  UsdSchemaKind _GetSchemaKind() const override;
137 
138 private:
139  // needs to invoke _GetStaticTfType.
140  friend class UsdSchemaRegistry;
142  static const TfType &_GetStaticTfType();
143 
144  static bool _IsTypedSchema();
145 
146  // override SchemaBase virtuals.
148  const TfType &_GetTfType() const override;
149 
150 public:
151  // --------------------------------------------------------------------- //
152  // DYNAMICFRICTION
153  // --------------------------------------------------------------------- //
154  /// Dynamic friction coefficient. Unitless.
155  ///
156  /// | ||
157  /// | -- | -- |
158  /// | Declaration | `float physics:dynamicFriction = 0` |
159  /// | C++ Type | float |
160  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
163 
164  /// See GetDynamicFrictionAttr(), and also
165  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
166  /// If specified, author \p defaultValue as the attribute's default,
167  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
168  /// the default for \p writeSparsely is \c false.
170  UsdAttribute CreateDynamicFrictionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
171 
172 public:
173  // --------------------------------------------------------------------- //
174  // STATICFRICTION
175  // --------------------------------------------------------------------- //
176  /// Static friction coefficient. Unitless.
177  ///
178  /// | ||
179  /// | -- | -- |
180  /// | Declaration | `float physics:staticFriction = 0` |
181  /// | C++ Type | float |
182  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
185 
186  /// See GetStaticFrictionAttr(), and also
187  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
188  /// If specified, author \p defaultValue as the attribute's default,
189  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
190  /// the default for \p writeSparsely is \c false.
192  UsdAttribute CreateStaticFrictionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
193 
194 public:
195  // --------------------------------------------------------------------- //
196  // RESTITUTION
197  // --------------------------------------------------------------------- //
198  /// Restitution coefficient. Unitless.
199  ///
200  /// | ||
201  /// | -- | -- |
202  /// | Declaration | `float physics:restitution = 0` |
203  /// | C++ Type | float |
204  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
207 
208  /// See GetRestitutionAttr(), and also
209  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
210  /// If specified, author \p defaultValue as the attribute's default,
211  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
212  /// the default for \p writeSparsely is \c false.
214  UsdAttribute CreateRestitutionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
215 
216 public:
217  // --------------------------------------------------------------------- //
218  // DENSITY
219  // --------------------------------------------------------------------- //
220  /// If non-zero, defines the density of the material. This can be
221  /// used for body mass computation, see PhysicsMassAPI.
222  /// Note that if the density is 0.0 it is ignored.
223  /// Units: mass/distance/distance/distance.
224  ///
225  /// | ||
226  /// | -- | -- |
227  /// | Declaration | `float physics:density = 0` |
228  /// | C++ Type | float |
229  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
232 
233  /// See GetDensityAttr(), and also
234  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
235  /// If specified, author \p defaultValue as the attribute's default,
236  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
237  /// the default for \p writeSparsely is \c false.
239  UsdAttribute CreateDensityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
240 
241 public:
242  // ===================================================================== //
243  // Feel free to add custom code below this line, it will be preserved by
244  // the code generator.
245  //
246  // Just remember to:
247  // - Close the class declaration with };
248  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
249  // - Close the include guard with #endif
250  // ===================================================================== //
251  // --(BEGIN CUSTOM CODE)--
252 };
253 
255 
256 #endif
static USDPHYSICS_API UsdPhysicsMaterialAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USDPHYSICS_API UsdAttribute GetDensityAttr() const
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual USDPHYSICS_API ~UsdPhysicsMaterialAPI()
Destructor.
USDPHYSICS_API UsdAttribute CreateDensityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDPHYSICS_API UsdAttribute GetDynamicFrictionAttr() const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
static USDPHYSICS_API UsdPhysicsMaterialAPI Apply(const UsdPrim &prim)
USDPHYSICS_API UsdAttribute GetStaticFrictionAttr() const
static USDPHYSICS_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
#define USDPHYSICS_API
Definition: api.h:23
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDPHYSICS_API UsdAttribute GetRestitutionAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
static const UsdSchemaKind schemaKind
Definition: materialAPI.h:48
USDPHYSICS_API UsdAttribute CreateDynamicFrictionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDPHYSICS_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDPHYSICS_API UsdAttribute CreateStaticFrictionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdPhysicsMaterialAPI(const UsdSchemaBase &schemaObj)
Definition: materialAPI.h:62
USDPHYSICS_API UsdAttribute CreateRestitutionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146
UsdPhysicsMaterialAPI(const UsdPrim &prim=UsdPrim())
Definition: materialAPI.h:54