Package com.jme3.bullet
Class MultiBody
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.MultiBody
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
An articulated rigid body based on Bullet's
btMultiBody
. Uses
Featherstone's algorithm.-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddBaseCollider
(CollisionShape shape) Add a collider for the base.void
addBaseForce
(Vector3f force) Add an external force to the base.void
addBaseTorque
(Vector3f torque) Add an external torque to the base.float
Determine the angular damping.baseAngularVelocity
(Vector3f storeResult) Determine the angular velocity of the base.Determine the net force on the base.baseInertia
(Vector3f storeResult) Determine the rotational inertia of the base.baseLocation
(Vector3f storeResult) Determine the location of the base's center of mass.float
baseMass()
Determine the mass of the base.baseOrientation
(Quaternion storeResult) Determine the orientation of the base.baseTorque
(Vector3f storeResult) Determine the net torque on the base.baseTransform
(Transform storeResult) Determine the transform of the base.baseVelocity
(Vector3f storeResult) Determine the linear velocity of the base's center of mass.boolean
canSleep()
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.int
Return the set of collision groups with which this multibody can collide.int
Return the collision group of this multibody.configureFixedLink
(float mass, Vector3f inertia, MultiBodyLink parent, Quaternion orientation, Vector3f parent2Pivot, Vector3f pivot2Link) Configure a new link that is fixed to its parent.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.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.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.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.boolean
contains
(MultiBodyCollider collider) 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.float
Determine the linear damping.Enumerate the colliders in this MultiBody.float
Determine the maximum applied impulse.float
Determine the maximum coordinate velocity.void
setBaseAngularVelocity
(Vector3f angularVelocity) Alter the angular velocity of the base.void
setBaseLocation
(Vector3f location) Alter the location of the base's center of mass.void
setBaseOrientation
(Quaternion orientation) Alter the orientation of the base.void
setBaseTransform
(Transform transform) Alter the transform of the base.void
setBaseVelocity
(Vector3f velocity) Alter the linear velocity of the base.void
setCollideWithGroups
(int groups) 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
spaceId()
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.Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObject
-
Field Details
-
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 movecanSleep
- true → can sleep, false → won't sleep
-
-
Method Details
-
addBaseCollider
Add a collider for the base.- Parameters:
shape
- (not null, alias created)- Returns:
- a new collider
-
addBaseForce
Add an external force to the base.- Parameters:
force
- the force to add (in physics-space coordinates, not null, unaffected)
-
addBaseTorque
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
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
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
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
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
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
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
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
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 baseorientation
- 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 baseorientation
- 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 baseorientation
- 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 baseorientation
- 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 baseorientation
- 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
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
Access the collider for the base.- Returns:
- the pre-existing instance, or null if none
-
getLink
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
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
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
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
Alter the orientation of the base.- Parameters:
orientation
- the desired orientation (in physics-space coordinates, not null, unaffected)
-
setBaseTransform
Alter the transform of the base.- Parameters:
transform
- the desired transform from local coordinates to physics-space coordinates (not null, unaffected, scale ignored)
-
setBaseVelocity
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
-