Class MultiBody

All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, Comparable<NativePhysicsObject>

public class MultiBody extends NativePhysicsObject implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
An articulated rigid body based on Bullet's btMultiBody. Uses Featherstone's algorithm.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Logger
    message logger for this class

    Fields inherited from class com.jme3.bullet.NativePhysicsObject

    loggerN
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    No-argument constructor needed by SavableClassUtil.
     
    MultiBody(int numLinks, float baseMass, com.jme3.math.Vector3f baseInertia, boolean fixedBase, boolean canSleep)
    Instantiate a MultiBody.
  • Method Summary

    Modifier and Type
    Method
    Description
    Add a collider for the base.
    void
    addBaseForce(com.jme3.math.Vector3f force)
    Add an external force to the base.
    void
    addBaseTorque(com.jme3.math.Vector3f torque)
    Add an external torque to the base.
    float
    Determine the angular damping.
    com.jme3.math.Vector3f
    baseAngularVelocity(com.jme3.math.Vector3f storeResult)
    Determine the angular velocity of the base.
    com.jme3.math.Vector3f
    baseForce(com.jme3.math.Vector3f storeResult)
    Determine the net force on the base.
    com.jme3.math.Vector3f
    baseInertia(com.jme3.math.Vector3f storeResult)
    Determine the rotational inertia of the base.
    com.jme3.math.Vector3f
    baseLocation(com.jme3.math.Vector3f storeResult)
    Determine the location of the base's center of mass.
    float
    Determine the mass of the base.
    com.jme3.math.Quaternion
    baseOrientation(com.jme3.math.Quaternion storeResult)
    Determine the orientation of the base.
    com.jme3.math.Vector3f
    baseTorque(com.jme3.math.Vector3f storeResult)
    Determine the net torque on the base.
    com.jme3.math.Transform
    baseTransform(com.jme3.math.Transform storeResult)
    Determine the transform of the base.
    com.jme3.math.Vector3f
    baseVelocity(com.jme3.math.Vector3f storeResult)
    Determine the linear velocity of the base's center of mass.
    boolean
    Test whether this MultiBody can sleep.
    boolean
    Test whether this MultiBody can wake up.
    void
    Clear all constraint forces.
    void
    Clear all external forces and torques.
    void
    Zero out all velocities.
    void
    cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
    Callback from Cloner to convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.
    int
    Return the set of collision groups with which this multibody can collide.
    int
    Return the collision group of this multibody.
    configureFixedLink(float mass, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.Vector3f pivot2Link)
    Configure a new link that is fixed to its parent.
    configurePlanarLink(float mass, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f axis, com.jme3.math.Vector3f parent2Link, boolean disableCollision)
    Configure a link that is joined to its parent with a planar joint.
    configurePrismaticLink(float mass, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f axis, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.Vector3f pivot2Link, boolean disableCollision)
    Configure a link that is joined to its parent with a prismatic joint.
    configureRevoluteLink(float mass, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f axis, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.Vector3f pivot2Link, boolean disableCollision)
    Configure a link that is joined to its parent with a revolute joint.
    configureSphericalLink(float mass, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.Vector3f pivot2Link, boolean disableCollision)
    Configure a link that is joined to its parent with a spherical joint.
    boolean
    Test whether the specified collider is part of this MultiBody.
    int
    Count the configured links in this MultiBody.
    int
    Count the degrees of freedom.
    int
    Count the position variables in this MultiBody.
    Access the collider for the base.
    getLink(int linkIndex)
    Access the index link of this MultiBody.
    boolean
    Test whether this MultiBody has a fixed base.
    boolean
    Test whether this MultiBody uses global variables.
    boolean
    Test whether this MultiBody uses the gyro term.
    boolean
    Test whether this MultiBody uses RK4 integration.
    Create a shallow clone for the JME cloner.
    float
    Determine the linear damping.
    Enumerate the colliders in this MultiBody.
    float
    Determine the maximum applied impulse.
    float
    Determine the maximum coordinate velocity.
    void
    read(com.jme3.export.JmeImporter importer)
    De-serialize this object from the specified importer, for example when loading from a J3O file.
    void
    setBaseAngularVelocity(com.jme3.math.Vector3f angularVelocity)
    Alter the angular velocity of the base.
    void
    setBaseLocation(com.jme3.math.Vector3f location)
    Alter the location of the base's center of mass.
    void
    setBaseOrientation(com.jme3.math.Quaternion orientation)
    Alter the orientation of the base.
    void
    setBaseTransform(com.jme3.math.Transform transform)
    Alter the transform of the base.
    void
    setBaseVelocity(com.jme3.math.Vector3f velocity)
    Alter the linear velocity of the base.
    void
    Directly alter the collision groups with which this MultiBody can collide.
    void
    setCollisionGroup(int group)
    Alter which collision group this MultiBody belongs to.
    void
    setUserIndex(int index)
    Alter the primary user index.
    void
    setUserIndex2(int index)
    Alter the secondary user index.
    long
    Determine the ID of the MultiBodySpace to which this MultiBody is added.
    void
    useGlobalVelocities(boolean setting)
    Alter whether this MultiBody uses global velocities.
    int
    Return the primary user index (native field: m_userIndex).
    int
    Return the secondary user index (native field: m_userIndex2).
    void
    useRK4(boolean setting)
    Alter whether this MultiBody uses RK4 integration.
    void
    write(com.jme3.export.JmeExporter exporter)
    Serialize this object to the specified exporter, for example when saving to a J3O file.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • logger

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

    • MultiBody

      protected MultiBody()
      No-argument constructor needed by SavableClassUtil.
    • MultiBody

      public MultiBody(int numLinks, float baseMass, com.jme3.math.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(com.jme3.math.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(com.jme3.math.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 com.jme3.math.Vector3f baseAngularVelocity(com.jme3.math.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 com.jme3.math.Vector3f baseForce(com.jme3.math.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 com.jme3.math.Vector3f baseInertia(com.jme3.math.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 com.jme3.math.Vector3f baseLocation(com.jme3.math.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 com.jme3.math.Quaternion baseOrientation(com.jme3.math.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 com.jme3.math.Vector3f baseTorque(com.jme3.math.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 com.jme3.math.Transform baseTransform(com.jme3.math.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 com.jme3.math.Vector3f baseVelocity(com.jme3.math.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, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.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, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f axis, com.jme3.math.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, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f axis, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.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, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f axis, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.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, com.jme3.math.Vector3f inertia, MultiBodyLink parent, com.jme3.math.Quaternion orientation, com.jme3.math.Vector3f parent2Pivot, com.jme3.math.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(com.jme3.math.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(com.jme3.math.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(com.jme3.math.Quaternion orientation)
      Alter the orientation of the base.
      Parameters:
      orientation - the desired orientation (in physics-space coordinates, not null, unaffected)
    • setBaseTransform

      public void setBaseTransform(com.jme3.math.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(com.jme3.math.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
    • cloneFields

      public void cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
      Callback from Cloner to convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.
      Specified by:
      cloneFields in interface com.jme3.util.clone.JmeCloneable
      Parameters:
      cloner - the Cloner that's cloning this object (not null)
      original - the instance from which this object was shallow-cloned (not null, unaffected)
    • jmeClone

      public MultiBody jmeClone()
      Create a shallow clone for the JME cloner. Note that the cloned MultiBody won't be added to any PhysicsSpace, even if the original was.
      Specified by:
      jmeClone in interface com.jme3.util.clone.JmeCloneable
      Returns:
      a new instance
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this object from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this object to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter