java.lang.Object
physx.NativeObject
physx.extensions.PxMassProperties
Utility class to compute and manipulate mass and inertia tensor properties.
In most cases #PxRigidBodyExt::updateMassAndInertia(), #PxRigidBodyExt::setMassAndUpdateInertia() should be enough to setup the mass properties of a rigid body. This utility class targets users that need to customize the mass properties computation.
-
Nested Class Summary
Nested classes/interfaces inherited from class physx.NativeObject
NativeObject.Allocator<T> -
Field Summary
FieldsFields inherited from class physx.NativeObject
address, isExternallyAllocated, SIZEOF_BYTE, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_POINTER, SIZEOF_SHORT -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor.PxMassProperties(float m, PxMat33 inertiaT, PxVec3 com) Construct from individual elements.protectedPxMassProperties(long address) PxMassProperties(PxGeometry geometry) Compute mass properties based on a provided geometry structure. -
Method Summary
Modifier and TypeMethodDescriptionstatic PxMassPropertiesarrayGet(long baseAddress, int index) voiddestroy()The center of mass of the object.The inertia tensor of the object.floatgetMass()The mass of the object.static PxVec3getMassSpaceInertia(PxMat33 inertia, PxQuat massFrame) Get the entries of the diagonalized inertia tensor and the corresponding reference rotation.static PxMat33rotateInertia(PxMat33 inertia, PxQuat q) Rotate an inertia tensor around the center of massstatic PxMat33scaleInertia(PxMat33 inertia, PxQuat scaleRotation, PxVec3 scale) Non-uniform scaling of the inertia tensorvoidsetCenterOfMass(PxVec3 value) The center of mass of the object.voidsetInertiaTensor(PxMat33 value) The inertia tensor of the object.voidsetMass(float value) The mass of the object.static PxMassPropertiessum(PxMassProperties props, PxTransform transforms, int count) Sum up individual mass properties.voidTranslate the center of mass by a given vector and adjust the inertia tensor accordingly.static PxMat33translateInertia(PxMat33 inertia, float mass, PxVec3 t) Translate an inertia tensor using the parallel axis theoremstatic PxMassPropertieswrapPointer(long address) Methods inherited from class physx.NativeObject
checkNotNull, equals, getAddress, hashCode
-
Field Details
-
SIZEOF
public static final int SIZEOF -
ALIGNOF
public static final int ALIGNOF- See Also:
-
-
Constructor Details
-
PxMassProperties
protected PxMassProperties(long address) -
PxMassProperties
public PxMassProperties()Default constructor. -
PxMassProperties
Construct from individual elements. -
PxMassProperties
Compute mass properties based on a provided geometry structure.This constructor assumes the geometry has a density of 1. Mass and inertia tensor scale linearly with density.
- Parameters:
geometry- The geometry to compute the mass properties for. Supported geometry types are: sphere, box, capsule and convex mesh.
-
-
Method Details
-
wrapPointer
-
arrayGet
-
destroy
public void destroy() -
getInertiaTensor
The inertia tensor of the object. -
setInertiaTensor
The inertia tensor of the object. -
getCenterOfMass
The center of mass of the object. -
setCenterOfMass
The center of mass of the object. -
getMass
public float getMass()The mass of the object. -
setMass
public void setMass(float value) The mass of the object. -
translate
Translate the center of mass by a given vector and adjust the inertia tensor accordingly.- Parameters:
t- The translation vector for the center of mass.
-
getMassSpaceInertia
Get the entries of the diagonalized inertia tensor and the corresponding reference rotation.- Parameters:
inertia- The inertia tensor to diagonalize.massFrame- The frame the diagonalized tensor refers to.- Returns:
- The entries of the diagonalized inertia tensor.
-
translateInertia
Translate an inertia tensor using the parallel axis theorem- Parameters:
inertia- The inertia tensor to translate.mass- The mass of the object.t- The relative frame to translate the inertia tensor to.- Returns:
- The translated inertia tensor.
-
rotateInertia
Rotate an inertia tensor around the center of mass- Parameters:
inertia- The inertia tensor to rotate.q- The rotation from the new to the old coordinate frame, i.e. q.rotate(v) transforms the coordinates of vector v from the old to the new coordinate frame.- Returns:
- The rotated inertia tensor.
-
scaleInertia
Non-uniform scaling of the inertia tensor- Parameters:
inertia- The inertia tensor to scale.scaleRotation- The rotation from the scaling frame to the frame that inertia is expressed in. I.e. scaleRotation.rotate(v) transforms the coordinates of vertex v from inertia's frame to the scaling-axes frame.scale- The scaling factor for each axis (relative to the frame specified with scaleRotation).- Returns:
- The scaled inertia tensor.
-
sum
Sum up individual mass properties.- Parameters:
props- Array of mass properties to sum up.transforms- Reference transforms for each mass properties entry.count- The number of mass properties to sum up.- Returns:
- The summed up mass properties.
-