Class MultiBody

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class MultiBody extends NativePhysicsObject
An articulated rigid body based on Bullet's btMultiBody. Uses Featherstone's algorithm.
  • Field Details

    • logger

      public static final Logger logger
      message logger for this class
  • Constructor Details

    • MultiBody

      public MultiBody(int numLinks, float baseMass, Vector3f baseInertia, boolean fixedBase, boolean canSleep)
      Instantiate a MultiBody. Note that "sleep" is synonym for "deactivate".
      Parameters:
      numLinks - the desired number of links, not including the base (≥0)
      baseMass - the desired mass of the base (in physics-space units, >0)
      baseInertia - the desired rotational inertia of the base (not null, all elements positive)
      fixedBase - true → base is fixed, false → base can move
      canSleep - true → can sleep, false → won't sleep
  • Method Details

    • addBaseCollider

      public MultiBodyCollider addBaseCollider(CollisionShape shape)
      Add a collider for the base.
      Parameters:
      shape - (not null, alias created)
      Returns:
      a new collider
    • addBaseForce

      public void addBaseForce(Vector3f force)
      Add an external force to the base.
      Parameters:
      force - the force to add (in physics-space coordinates, not null, unaffected)
    • addBaseTorque

      public void addBaseTorque(Vector3f torque)
      Add an external torque to the base.
      Parameters:
      torque - the torque to add (in physics-space coordinates, not null, unaffected)
    • angularDamping

      public float angularDamping()
      Determine the angular damping.
      Returns:
      the damping
    • baseAngularVelocity

      public Vector3f baseAngularVelocity(Vector3f storeResult)
      Determine the angular velocity of the base.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the angular-velocity vector (either storeResult or a new vector, not null)
    • baseForce

      public Vector3f baseForce(Vector3f storeResult)
      Determine the net force on the base.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the force vector (either storeResult or a new vector, not null)
    • baseInertia

      public Vector3f baseInertia(Vector3f storeResult)
      Determine the rotational inertia of the base.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the principal (diagonal) components of the inertia tensor (in the base's local coordinates, either storeResult or a new vector, not null)
    • baseLocation

      public Vector3f baseLocation(Vector3f storeResult)
      Determine the location of the base's center of mass.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the location vector (in physics-space coordinates, either storeResult or a new vector, not null)
    • baseMass

      public float baseMass()
      Determine the mass of the base.
      Returns:
      the mass (in physics-space units, >0)
    • baseOrientation

      public Quaternion baseOrientation(Quaternion storeResult)
      Determine the orientation of the base.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the orientation (either storeResult or a new instance, not null)
    • baseTorque

      public Vector3f baseTorque(Vector3f storeResult)
      Determine the net torque on the base.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the torque vector (either storeResult or a new vector, not null)
    • baseTransform

      public Transform baseTransform(Transform storeResult)
      Determine the transform of the base.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the transform from local coordinates to physics-space coordinates (either storeResult or a new instance, not null, scale=1)
    • baseVelocity

      public Vector3f baseVelocity(Vector3f storeResult)
      Determine the linear velocity of the base's center of mass.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the velocity vector (in physics-space coordinates, either storeResult or a new vector, not null)
    • canSleep

      public boolean canSleep()
      Test whether this MultiBody can sleep. Note that "sleep" is synonym for "deactivate".
      Returns:
      true if it can sleep, otherwise false
    • canWakeup

      public boolean canWakeup()
      Test whether this MultiBody can wake up.
      Returns:
      true if it can wake up, otherwise false
    • clearConstraintForces

      public void clearConstraintForces()
      Clear all constraint forces.
    • clearForcesAndTorques

      public void clearForcesAndTorques()
      Clear all external forces and torques.
    • clearVelocities

      public void clearVelocities()
      Zero out all velocities.
    • collideWithGroups

      public int collideWithGroups()
      Return the set of collision groups with which this multibody can collide.
      Returns:
      the bitmask
    • collisionGroup

      public int collisionGroup()
      Return the collision group of this multibody.
      Returns:
      the collision group (bitmask with exactly one bit set)
    • configureFixedLink

      public MultiBodyLink configureFixedLink(float mass, Vector3f inertia, MultiBodyLink parent, Quaternion orientation, Vector3f parent2Pivot, Vector3f pivot2Link)
      Configure a new link that is fixed to its parent.
      Parameters:
      mass - the desired mass of the link (>0)
      inertia - the desired moment of inertia of the link (not null, unaffected)
      parent - the parent link, or null if parented by the base
      orientation - the orientation of the link relative to its parent (not null, unaffected)
      parent2Pivot - the offset of the pivot from the parent's center of mass (not null, unaffected)
      pivot2Link - the offset of the child's center of mass from the pivot (not null, unaffected)
      Returns:
      a new link
    • configurePlanarLink

      public MultiBodyLink configurePlanarLink(float mass, Vector3f inertia, MultiBodyLink parent, Quaternion orientation, Vector3f axis, Vector3f parent2Link, boolean disableCollision)
      Configure a link that is joined to its parent with a planar joint.
      Parameters:
      mass - the desired mass of the link (>0)
      inertia - the desired moment of inertia of the link (not null, unaffected)
      parent - the parent link, or null if parented by the base
      orientation - the orientation of the link relative to its parent (not null, unaffected)
      axis - the axis of rotation, which is also the plane's normal vector (not null, unaffected)
      parent2Link - the offset of the child's center of mass from the parent's center of mass (not null, unaffected)
      disableCollision - true to ignore collisions between the link and its parent
      Returns:
      a new link
    • configurePrismaticLink

      public MultiBodyLink configurePrismaticLink(float mass, Vector3f inertia, MultiBodyLink parent, Quaternion orientation, Vector3f axis, Vector3f parent2Pivot, Vector3f pivot2Link, boolean disableCollision)
      Configure a link that is joined to its parent with a prismatic joint.
      Parameters:
      mass - the desired mass of the link (>0)
      inertia - the desired moment of inertia of the link (not null, unaffected)
      parent - the parent link, or null if parented by the base
      orientation - the orientation of the link relative to its parent (not null, unaffected)
      axis - the axis of rotation (not null, unaffected)
      parent2Pivot - the offset of the pivot from the parent's center of mass (not null, unaffected)
      pivot2Link - the offset of the child's center of mass from the pivot (not null, unaffected)
      disableCollision - true to ignore collisions between the link and its parent
      Returns:
      a new link
    • configureRevoluteLink

      public MultiBodyLink configureRevoluteLink(float mass, Vector3f inertia, MultiBodyLink parent, Quaternion orientation, Vector3f axis, Vector3f parent2Pivot, Vector3f pivot2Link, boolean disableCollision)
      Configure a link that is joined to its parent with a revolute joint.
      Parameters:
      mass - the desired mass of the link (>0)
      inertia - the desired moment of inertia of the link (not null, unaffected)
      parent - the parent link, or null if parented by the base
      orientation - the orientation of the link relative to its parent (not null, unaffected)
      axis - the axis of rotation (not null, unaffected)
      parent2Pivot - the offset of the pivot from the parent's center of mass (not null, unaffected)
      pivot2Link - the offset of the child's center of mass from the pivot (not null, unaffected)
      disableCollision - true to ignore collisions between the link and its parent
      Returns:
      a new link
    • configureSphericalLink

      public MultiBodyLink configureSphericalLink(float mass, Vector3f inertia, MultiBodyLink parent, Quaternion orientation, Vector3f parent2Pivot, Vector3f pivot2Link, boolean disableCollision)
      Configure a link that is joined to its parent with a spherical joint.
      Parameters:
      mass - the desired mass of the link (>0)
      inertia - the desired moment of inertia of the link (not null, unaffected)
      parent - the parent link, or null if parented by the base
      orientation - the orientation of the link relative to its parent (not null, unaffected)
      parent2Pivot - the offset of the pivot from the parent's center of mass (not null, unaffected)
      pivot2Link - the offset of the child's center of mass from the pivot (not null, unaffected)
      disableCollision - true to ignore collisions between the link and its parent
      Returns:
      a new link
    • contains

      public boolean contains(MultiBodyCollider collider)
      Test whether the specified collider is part of this MultiBody.
      Parameters:
      collider - the collider to search for (not null, unaffected)
      Returns:
      true if included, otherwise false
    • countConfiguredLinks

      public int countConfiguredLinks()
      Count the configured links in this MultiBody.
      Returns:
      the count (≥0)
    • countDofs

      public int countDofs()
      Count the degrees of freedom.
      Returns:
      the count (≥0)
    • countPositionVariables

      public int countPositionVariables()
      Count the position variables in this MultiBody.
      Returns:
      the count (≥0)
    • getBaseCollider

      public MultiBodyCollider getBaseCollider()
      Access the collider for the base.
      Returns:
      the pre-existing instance, or null if none
    • getLink

      public MultiBodyLink getLink(int linkIndex)
      Access the index link of this MultiBody.
      Parameters:
      linkIndex - (≥0, <numConfigured)
      Returns:
      the pre-existing instance (not null)
    • hasFixedBase

      public boolean hasFixedBase()
      Test whether this MultiBody has a fixed base.
      Returns:
      true → fixed, false → movable
    • isUsingGlobalVelocities

      public boolean isUsingGlobalVelocities()
      Test whether this MultiBody uses global variables.
      Returns:
      true if using global variables, otherwise false
    • isUsingGyroTerm

      public boolean isUsingGyroTerm()
      Test whether this MultiBody uses the gyro term.
      Returns:
      true if using the gyro term, otherwise false
    • isUsingRK4

      public boolean isUsingRK4()
      Test whether this MultiBody uses RK4 integration.
      Returns:
      true if using RK4, otherwise false
    • linearDamping

      public float linearDamping()
      Determine the linear damping.
      Returns:
      the damping
    • listColliders

      public List<MultiBodyCollider> listColliders()
      Enumerate the colliders in this MultiBody.
      Returns:
      a new collection of pre-existing instances
    • maxAppliedImpulse

      public float maxAppliedImpulse()
      Determine the maximum applied impulse.
      Returns:
      the impulse
    • maxCoordinateVelocity

      public float maxCoordinateVelocity()
      Determine the maximum coordinate velocity.
      Returns:
      the velocity
    • setBaseAngularVelocity

      public void setBaseAngularVelocity(Vector3f angularVelocity)
      Alter the angular velocity of the base.
      Parameters:
      angularVelocity - the desired angular-velocity vector (in physics-space coordinates, not null, unaffected, default=(0,0,0))
    • setBaseLocation

      public void setBaseLocation(Vector3f location)
      Alter the location of the base's center of mass.
      Parameters:
      location - the desired location vector (in physics-space coordinates, not null, unaffected, default=(0,0,0))
    • setBaseOrientation

      public void setBaseOrientation(Quaternion orientation)
      Alter the orientation of the base.
      Parameters:
      orientation - the desired orientation (in physics-space coordinates, not null, unaffected)
    • setBaseTransform

      public void setBaseTransform(Transform transform)
      Alter the transform of the base.
      Parameters:
      transform - the desired transform from local coordinates to physics-space coordinates (not null, unaffected, scale ignored)
    • setBaseVelocity

      public void setBaseVelocity(Vector3f velocity)
      Alter the linear velocity of the base.
      Parameters:
      velocity - the desired velocity vector (in physics-space coordinates, not null, unaffected, default=(0,0,0))
    • setCollideWithGroups

      public void setCollideWithGroups(int groups)
      Directly alter the collision groups with which this MultiBody can collide.
      Parameters:
      groups - the desired groups, ORed together (bitmask, default=COLLISION_GROUP_01)
    • setCollisionGroup

      public void setCollisionGroup(int group)
      Alter which collision group this MultiBody belongs to.

      Groups are represented by bitmasks with exactly one bit set. Manifest constants are defined in PhysicsCollisionObject.

      Two objects can collide only if one of them has the collisionGroup of the other in its collideWithGroups set.

      Parameters:
      group - the collisionGroup to apply (bitmask with exactly one bit set, default=COLLISION_GROUP_01)
    • setUserIndex

      public void setUserIndex(int index)
      Alter the primary user index. Applications may use this parameter for any purpose (native field: m_userIndex).
      Parameters:
      index - the desired value (default=-1)
    • setUserIndex2

      public void setUserIndex2(int index)
      Alter the secondary user index. Applications may use this parameter for any purpose (native field: m_userIndex2).
      Parameters:
      index - the desired value (default=-1)
    • spaceId

      public long spaceId()
      Determine the ID of the MultiBodySpace to which this MultiBody is added.
      Returns:
      the ID, or zero if not in any space
    • useGlobalVelocities

      public void useGlobalVelocities(boolean setting)
      Alter whether this MultiBody uses global velocities.
      Parameters:
      setting - true to use global velocities (default=false)
    • useRK4

      public void useRK4(boolean setting)
      Alter whether this MultiBody uses RK4 integration.
      Parameters:
      setting - true to use RK4 (default=false)
    • userIndex

      public int userIndex()
      Return the primary user index (native field: m_userIndex).
      Returns:
      the value
    • userIndex2

      public int userIndex2()
      Return the secondary user index (native field: m_userIndex2).
      Returns:
      the value