Class PxMassProperties

java.lang.Object
physx.NativeObject
physx.extensions.PxMassProperties

public class PxMassProperties extends NativeObject
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.

  • 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

      public PxMassProperties(float m, PxMat33 inertiaT, PxVec3 com)
      Construct from individual elements.
    • PxMassProperties

      public PxMassProperties(PxGeometry geometry)
      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

      public static PxMassProperties wrapPointer(long address)
    • arrayGet

      public static PxMassProperties arrayGet(long baseAddress, int index)
    • destroy

      public void destroy()
    • getInertiaTensor

      public PxMat33 getInertiaTensor()
      The inertia tensor of the object.
    • setInertiaTensor

      public void setInertiaTensor(PxMat33 value)
      The inertia tensor of the object.
    • getCenterOfMass

      public PxVec3 getCenterOfMass()
      The center of mass of the object.
    • setCenterOfMass

      public void setCenterOfMass(PxVec3 value)
      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

      public void translate(PxVec3 t)
      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

      public static PxVec3 getMassSpaceInertia(PxMat33 inertia, PxQuat massFrame)
      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

      public static PxMat33 translateInertia(PxMat33 inertia, float mass, PxVec3 t)
      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

      public static PxMat33 rotateInertia(PxMat33 inertia, PxQuat q)
      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

      public static PxMat33 scaleInertia(PxMat33 inertia, PxQuat scaleRotation, PxVec3 scale)
      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

      public static PxMassProperties sum(PxMassProperties props, PxTransform transforms, int count)
      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.