usdrt::UsdPhysicsMassAPI

Defined in usdrt/scenegraph/usd/usdPhysics/massAPI.h

class UsdPhysicsMassAPI : public usdrt::UsdAPISchemaBase

Defines explicit mass properties (mass, density, inertia etc.). MassAPI can be applied to any object that has a PhysicsCollisionAPI or a PhysicsRigidBodyAPI.

Public Functions

inline explicit UsdPhysicsMassAPI(const UsdPrim &prim = UsdPrim())

Construct a UsdPhysicsMassAPI on UsdPrim prim. Equivalent to UsdPhysicsMassAPI::Get(prim.GetStage(), prim.GetPath()) for a valid prim , but will not immediately throw an error for an invalid prim.

inline explicit UsdPhysicsMassAPI(const UsdSchemaBase &schemaObj)

Construct a UsdPhysicsMassAPI on the prim held by schemaObj . Should be preferred over UsdPhysicsMassAPI(schemaObj.GetPrim()), as it preserves SchemaBase state.

inline virtual ~UsdPhysicsMassAPI()

Destructor.

inline UsdAttribute GetMassAttr() const

If non-zero, directly specifies the mass of the object. Note that any child prim can also have a mass when they apply massAPI. In this case, the precedence rule is ‘parent mass overrides the child’s’. This may come as counter-intuitive, but mass is a computed quantity and in general not accumulative. For example, if a parent has mass of 10, and one of two children has mass of 20, allowing child’s mass to override its parent results in a mass of -10 for the other child. Note if mass is 0.0 it is ignored. Units: mass.

Declaration

float physics:mass = 0

C++ Type

float

Usd Type

SdfValueTypeNames->Float

inline UsdAttribute CreateMassAttr() const

See GetMassAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

inline UsdAttribute GetDensityAttr() const

If non-zero, specifies the density of the object. In the context of rigid body physics, density indirectly results in setting mass via (mass = density x volume of the object). How the volume is computed is up to implementation of the physics system. It is generally computed from the collision approximation rather than the graphical mesh. In the case where both density and mass are specified for the same object, mass has precedence over density. Unlike mass, child’s prim’s density overrides parent prim’s density as it is accumulative. Note that density of a collisionAPI can be also alternatively set through a PhysicsMaterialAPI. The material density has the weakest precedence in density definition. Note if density is 0.0 it is ignored. Units: mass/distance/distance/distance.

Declaration

float physics:density = 0

C++ Type

float

Usd Type

SdfValueTypeNames->Float

inline UsdAttribute CreateDensityAttr() const

See GetDensityAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

inline UsdAttribute GetCenterOfMassAttr() const

Center of mass in the prim’s local space. Units: distance.

Declaration

point3f physics:centerOfMass = (-inf, -inf, -inf)

C++ Type

GfVec3f

Usd Type

SdfValueTypeNames->Point3f

inline UsdAttribute CreateCenterOfMassAttr() const

See GetCenterOfMassAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

inline UsdAttribute GetDiagonalInertiaAttr() const

If non-zero, specifies diagonalized inertia tensor along the principal axes. Note if diagonalInertial is (0.0, 0.0, 0.0) it is ignored. Units: mass*distance*distance.

Declaration

float3 physics:diagonalInertia = (0, 0, 0)

C++ Type

GfVec3f

Usd Type

SdfValueTypeNames->Float3

inline UsdAttribute CreateDiagonalInertiaAttr() const

See GetDiagonalInertiaAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

inline UsdAttribute GetPrincipalAxesAttr() const

Orientation of the inertia tensor’s principal axes in the prim’s local space.

Declaration

quatf physics:principalAxes = (0, 0, 0, 0)

C++ Type

GfQuatf

Usd Type

SdfValueTypeNames->Quatf

inline UsdAttribute CreatePrincipalAxesAttr() const

See GetPrincipalAxesAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

UsdPrim GetPrim() const

Return this schema object’s held prim.

SdfPath GetPath() const

Return the SdfPath to this schema object’s held prim.

inline explicit operator bool() const

Check if this schema object is compatible with it’s held prim and that the prim is valid.

A typed schema object is compatible if the held prim’s type is or is a subtype of the schema’s type. Based on prim.IsA().

An API schema object is compatible if the API is of type SingleApplyAPI or UsdSchemaType::MultipleApplyAPI, and the schema has been applied to the prim. Based on prim.HasAPI.

This method invokes polymorphic behaviour.

Returns

True if the help prim is valid, and the schema object is compatible with its held prim.

Public Static Functions

static inline UsdPhysicsMassAPI Apply(const UsdPrim &prim)

Applies this single-apply API schema to the given prim. This information is stored by adding “PhysicsMassAPI” to the token-valued, listOp metadata apiSchemas on the prim.

Returns

A valid UsdPhysicsMassAPI object is returned upon success. An invalid (or empty) UsdPhysicsMassAPI object is returned upon failure. See UsdPrim::ApplyAPI() for conditions resulting in failure.

Public Static Attributes

static const UsdSchemaType schemaType = UsdSchemaType::SingleApplyAPI

Compile time constant representing what kind of schema this class is.

See also

UsdSchemaType

Protected Functions

inline const TfToken &_GetInstanceName() const

Returns the instance name of the API schema object belonging to a multiple-apply API schema.

The returned instance name will be empty for non-applied and single-apply API schemas.

inline virtual bool _IsCompatible() const

Check whether this APISchema object is valid for the currently held prim.

If this is an applied API schema, this returns true if the held prim is valid and already has the API schema applied to it, along with the instanceName (in the case of multiple-apply). The instanceName should not be empty in the case of a multiple-apply API schema.

This check is performed when clients invoke the explicit bool conversion operator, implemented in UsdSchemaBase.

inline const TfToken _GetType() const

Helper for subclasses to get this schema’s type token.

Note

This diverges from Usd and returns a TfToken, since we don’t implements TfType.

Returns

The token representing the schema’s TfType.