public class PhysicsRigidBody extends PhysicsBody
btRigidBody.| Modifier and Type | Field and Description |
|---|---|
static java.util.logging.Logger |
logger2
message logger for this class
|
protected float |
mass
JVM copy of the mass (>0) of a dynamic body, or 0 for a static body
|
massForStaticCOLLISION_GROUP_01, COLLISION_GROUP_02, COLLISION_GROUP_03, COLLISION_GROUP_04, COLLISION_GROUP_05, COLLISION_GROUP_06, COLLISION_GROUP_07, COLLISION_GROUP_08, COLLISION_GROUP_09, COLLISION_GROUP_10, COLLISION_GROUP_11, COLLISION_GROUP_12, COLLISION_GROUP_13, COLLISION_GROUP_14, COLLISION_GROUP_15, COLLISION_GROUP_16, COLLISION_GROUP_NONE, loggerloggerN| Constructor and Description |
|---|
PhysicsRigidBody(CollisionShape shape)
Instantiate a responsive, dynamic body with mass=1 and the specified
CollisionShape.
|
PhysicsRigidBody(CollisionShape shape,
float mass)
Instantiate a responsive dynamic or static body with the specified
CollisionShape and mass.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Reactivate this body if it has been deactivated due to lack of motion.
|
void |
applyCentralForce(Vector3f force)
Apply a central force to the body.
|
void |
applyCentralImpulse(Vector3f impulse)
Apply a central impulse to the body.
|
void |
applyForce(Vector3f force,
Vector3f offset)
Apply a force to the body.
|
void |
applyImpulse(Vector3f impulse,
Vector3f offset)
Apply an impulse to the body.
|
void |
applyTorque(Vector3f torque)
Apply a torque to the body.
|
void |
applyTorqueImpulse(Vector3f torqueImpulse)
Apply a torque impulse to the body.
|
void |
clearForces()
Clear all forces and torques acting on this body, including gravity.
|
float |
getAngularDamping()
Read this body's angular damping.
|
Vector3f |
getAngularFactor(Vector3f storeResult)
Copy this body's angular factor.
|
float |
getAngularSleepingThreshold()
Read this body's angular-motion sleeping threshold.
|
Vector3f |
getAngularVelocity(Vector3f storeResult)
Copy this body's angular velocity.
|
Vec3d |
getAngularVelocityDp(Vec3d storeResult)
Copy this body's angular velocity.
|
Vector3f |
getAngularVelocityLocal(Vector3f storeResult)
Calculate this body's angular velocity in its local coordinates.
|
Vector3f |
getGravity(Vector3f storeResult)
Copy this body's gravitational acceleration.
|
Vec3d |
getGravityDp(Vec3d storeResult)
Copy this body's gravitational acceleration.
|
Vector3f |
getInverseInertiaLocal(Vector3f storeResult)
Copy the principal (diagonal) elements of the inverse inertia tensor in
the body's local coordinates.
|
Matrix3f |
getInverseInertiaWorld(Matrix3f storeResult)
Compute the inverse inertia tensor in physics-space coordinates.
|
float |
getLinearDamping()
Read this body's linear damping.
|
Vector3f |
getLinearFactor(Vector3f storeResult)
Copy this body's linear factors.
|
float |
getLinearSleepingThreshold()
Read this body's linear-motion sleeping threshold.
|
Vector3f |
getLinearVelocity(Vector3f storeResult)
Copy the linear velocity of this body's center of mass.
|
Vec3d |
getLinearVelocityDp(Vec3d storeResult)
Copy the linear velocity of this body's center of mass.
|
float |
getMass()
Read this body's mass.
|
RigidBodyMotionState |
getMotionState()
Access this body's motion state.
|
float |
getSquaredSpeed()
Calculate the squared speed of this body.
|
boolean |
isDynamic()
Test whether this body is in dynamic mode.
|
boolean |
isGravityProtected()
Test whether this body's gravity can be overwritten by PhysicsSpace.
|
boolean |
isKinematic()
Test whether this body is in kinematic mode.
|
double |
kineticEnergy()
Calculate this body's kinetic energy (linear + angular).
|
double |
mechanicalEnergy()
Calculate the mechanical energy of this body (kinetic + potential)
assuming a uniform gravitational field.
|
protected void |
postRebuild()
For use by subclasses.
|
protected void |
preRebuild()
For use by subclasses.
|
void |
rebuildRigidBody()
Rebuild this rigid body with a new native object.
|
void |
setAngularDamping(float angularDamping)
Alter this body's angular damping.
|
void |
setAngularFactor(float factor)
Alter this body's angular factor.
|
void |
setAngularFactor(Vector3f factor)
Alter this body's angular factors, used to scale applied torques.
|
void |
setAngularSleepingThreshold(float threshold)
Alter this body's angular-motion sleeping threshold.
|
void |
setAngularVelocity(Vector3f omega)
Alter this body's angular velocity.
|
void |
setAngularVelocityDp(Vec3d omega)
Alter this body's angular velocity.
|
void |
setCollisionShape(CollisionShape collisionShape)
Apply the specified CollisionShape to this body.
|
void |
setContactResponse(boolean newState)
Enable/disable this body's contact response.
|
void |
setDamping(float linearDamping,
float angularDamping)
Alter this body's damping.
|
void |
setEnableSleep(boolean setting)
Alter this body's activation state to allow/disallow sleeping.
|
void |
setGravity(Vector3f acceleration)
Alter this body's gravitational acceleration.
|
void |
setGravityDp(Vec3d acceleration)
Alter this body's gravitational acceleration.
|
void |
setInverseInertiaLocal(Vector3f inverseInertia)
Alter the principal (diagonal) components of the local inertia tensor in
the body's local coordinates.
|
void |
setKinematic(boolean kinematic)
Put this body into kinematic mode or take it out of kinematic mode.
|
void |
setLinearDamping(float linearDamping)
Alter this body's linear damping.
|
void |
setLinearFactor(Vector3f factor)
Alter this body's linear factors.
|
void |
setLinearSleepingThreshold(float threshold)
Alter this body's linear-motion sleeping threshold.
|
void |
setLinearVelocity(Vector3f velocity)
Alter the linear velocity of this body's center of mass.
|
void |
setLinearVelocityDp(Vec3d velocity)
Alter the linear velocity of this body's center of mass.
|
void |
setMass(float mass)
Alter this body's mass.
|
void |
setPhysicsLocation(Vector3f location)
Directly relocate this body's center of mass.
|
void |
setPhysicsLocationDp(Vec3d location)
Directly relocate this body's center of mass.
|
void |
setPhysicsRotation(Matrix3f orientation)
Directly alter this body's orientation.
|
void |
setPhysicsRotation(Quaternion orientation)
Directly reorient this body.
|
void |
setPhysicsRotationDp(Matrix3d orientation)
Directly reorient this body.
|
void |
setPhysicsRotationDp(Quatd orientation)
Directly reorient this body.
|
void |
setPhysicsScale(Vector3f newScale)
Rescale this body.
|
void |
setPhysicsTransform(Transform transform)
Directly alter this body's transform, including the scale of its shape.
|
void |
setProtectGravity(boolean newState)
Alter whether this body's gravity should be overwritten if the body gets
added to a PhysicsSpace or the gravity of the PhysicsSpace changes.
|
void |
setSleepingThresholds(float linear,
float angular)
Alter this body's sleeping thresholds.
|
Vector3f |
totalAppliedForce(Vector3f storeResult)
Determine the total force applied to this body (excluding contact forces,
damping, and gravity).
|
Vector3f |
totalAppliedTorque(Vector3f storeResult)
Determine the total torque applied to this body (excluding contact forces
and damping).
|
addJoint, countJoints, getDeactivationDeadline, isDeactivationEnabled, listJoints, removeJoint, setDeactivationDeadline, setDeactivationEnabledactivate, addCollideWithGroup, addToIgnoreList, attachCollisionShape, boundingBox, clearIgnoreList, collisionFlags, copyPcoProperties, countIgnored, finalizeNative, findInstance, getActivationState, getAnisotropicFriction, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getCollideWithGroups, getCollisionGroup, getCollisionShape, getCollisionSpace, getContactDamping, getContactProcessingThreshold, getContactStiffness, getDeactivationTime, getFriction, getInternalType, getPhysicsLocation, getPhysicsLocationDp, getPhysicsRotation, getPhysicsRotationDp, getPhysicsRotationMatrix, getPhysicsRotationMatrixDp, getRestitution, getRollingFriction, getScale, getSpinningFriction, getTransform, getTransformDp, getUserObject, hasAnisotropicFriction, ignores, initUserPointer, isActive, isContactResponse, isInWorld, isStatic, listIgnoredPcos, proxyGroup, proxyMask, removeCollideWithGroup, removeFromIgnoreList, setActivationState, setAnisotropicFriction, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setContactDamping, setContactProcessingThreshold, setContactStiffness, setDeactivationTime, setFriction, setIgnoreList, setLocationAndBasis, setRestitution, setRollingFriction, setSpinningFriction, setUserIndex, setUserIndex2, setUserIndex3, setUserObject, spaceId, toString, userIndex, userIndex2, userIndex3compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, unassignNativeObjectpublic static final java.util.logging.Logger logger2
protected float mass
public PhysicsRigidBody(CollisionShape shape)
shape - the desired shape (not null, alias created)public PhysicsRigidBody(CollisionShape shape, float mass)
shape - the desired shape (not null, alias created)mass - if 0, a static body is created; otherwise a dynamic body is
created (≥0, default=1)public void activate()
public void applyCentralForce(Vector3f force)
To apply an impulse, use
applyCentralImpulse(com.jme3.math.Vector3f).
force - the force vector (mass times physics-space units per second
squared in physics-space coordinates, not null, unaffected)public void applyCentralImpulse(Vector3f impulse)
impulse - the impulse vector (mass times physics-space units per
second in physics-space coordinates, not null, unaffected)public void applyForce(Vector3f force, Vector3f offset)
To apply an impulse, use
applyImpulse(com.jme3.math.Vector3f, com.jme3.math.Vector3f).
force - the force vector (mass times physics-space units per second
squared in physics-space coordinates, not null, unaffected)offset - the location to apply the force (relative to the body's
center in physics-space coordinates, not null, unaffected)public void applyImpulse(Vector3f impulse, Vector3f offset)
impulse - the impulse vector (mass times physics-space units per
second in physics-space coordinates, not null, unaffected)offset - the location to apply the impulse (relative to the body's
center in physics-space coordinates, not null, unaffected)public void applyTorque(Vector3f torque)
To apply a torque impulse, use
applyTorqueImpulse(com.jme3.math.Vector3f).
torque - the torque vector (mass times physics-space units squared
per second squared in physics-space coordinates, not null, unaffected)public void applyTorqueImpulse(Vector3f torqueImpulse)
torqueImpulse - the torque impulse vector (mass times physics-space
units squared per second in physics-space coordinates, not null,
unaffected)public void clearForces()
public float getAngularDamping()
public Vector3f getAngularFactor(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public float getAngularSleepingThreshold()
public Vector3f getAngularVelocity(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Vec3d getAngularVelocityDp(Vec3d storeResult)
storeResult - storage for the result (modified if not null)public Vector3f getAngularVelocityLocal(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Vec3d getGravityDp(Vec3d storeResult)
storeResult - storage for the result (modified if not null)public Vector3f getInverseInertiaLocal(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Matrix3f getInverseInertiaWorld(Matrix3f storeResult)
storeResult - storage for the result (modified if not null)public float getLinearDamping()
public Vector3f getLinearFactor(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public float getLinearSleepingThreshold()
public Vector3f getLinearVelocity(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Vec3d getLinearVelocityDp(Vec3d storeResult)
storeResult - storage for the result (modified if not null)public RigidBodyMotionState getMotionState()
public float getSquaredSpeed()
public boolean isDynamic()
public boolean isGravityProtected()
public final boolean isKinematic()
In kinematic mode, the body is not influenced by physics but can affect other physics objects. Its kinetic force is calculated based on its movement and weight.
public double kineticEnergy()
public double mechanicalEnergy()
public void rebuildRigidBody()
public void setAngularDamping(float angularDamping)
angularDamping - the desired angular damping fraction (≥0, ≤1,
default=0)public void setAngularFactor(float factor)
factor - the desired angular factor for all axes (not null,
unaffected, default=1)public void setAngularFactor(Vector3f factor)
factor - the desired angular factor for each axis (not null,
unaffected, default=(1,1,1))public void setAngularSleepingThreshold(float threshold)
threshold - the desired threshold (in radians per second, ≥0,
default=1)public void setAngularVelocity(Vector3f omega)
omega - the desired angular velocity (in physics-space coordinates,
not null, unaffected)public void setAngularVelocityDp(Vec3d omega)
omega - the desired angular velocity (in physics-space coordinates,
not null, unaffected)public void setCollisionShape(CollisionShape collisionShape)
setCollisionShape in class PhysicsCollisionObjectcollisionShape - the shape to apply (not null, alias created)public void setContactResponse(boolean newState)
newState - true to respond to contacts, false to ignore them
(default=true)public void setDamping(float linearDamping,
float angularDamping)
linearDamping - the desired linear damping fraction (≥0, ≤1,
default=0)angularDamping - the desired angular damping fraction (≥0, ≤1,
default=0)public void setEnableSleep(boolean setting)
setting - true→enable sleeping, false→disable sleeping
(default=true)public void setGravityDp(Vec3d acceleration)
Invoke this method after adding the body to a PhysicsSpace. Unless protection is set, adding a body to a PhysicsSpace overrides its gravity.
acceleration - the desired acceleration vector (in physics-space
coordinates, not null, unaffected, default=(0,0,0))setProtectGravity(boolean)public void setInverseInertiaLocal(Vector3f inverseInertia)
inverseInertia - the desired component values (not null, unaffected)public void setKinematic(boolean kinematic)
In kinematic mode, the body is not influenced by physics but can affect other physics objects. Its kinetic force is calculated based on its mass and motion.
kinematic - true→set kinematic mode, false→set dynamic
(default=false)public void setLinearDamping(float linearDamping)
linearDamping - the desired linear damping fraction (≥0, ≤1,
default=0)public void setLinearFactor(Vector3f factor)
factor - the desired linear factor for each axis (not null,
unaffected, default=(1,1,1))public void setLinearSleepingThreshold(float threshold)
threshold - the desired threshold (in physics-space units per
second, ≥0, default=0.8)public void setLinearVelocity(Vector3f velocity)
velocity - the desired velocity (physics-space units per second in
physics-space coordinates, not null, finite, unaffected)public void setLinearVelocityDp(Vec3d velocity)
velocity - the desired velocity (physics-space units per second in
physics-space coordinates, not null, unaffected)public void setPhysicsLocationDp(Vec3d location)
location - the desired location (in physics-space coordinates, not
null, unaffected)public void setPhysicsRotation(Matrix3f orientation)
orientation - the desired orientation (rotation matrix relative to
physics-space coordinates, not null, unaffected)public void setPhysicsRotation(Quaternion orientation)
orientation - the desired orientation (relative to physics-space
coordinates, not null, not zero, unaffected)public void setPhysicsRotationDp(Matrix3d orientation)
orientation - the desired orientation (rotation matrix relative to
physics-space coordinates, not null, unaffected)public void setPhysicsRotationDp(Quatd orientation)
orientation - the desired orientation (relative to physics-space
coordinates, not null, not zero, unaffected)public void setPhysicsScale(Vector3f newScale)
newScale - the desired scale factor for each local axis (not null,
no negative component, unaffected, default=(1,1,1))public void setPhysicsTransform(Transform transform)
transform - the desired transform (relative to physics-space
coordinates, not null, unaffected)public void setProtectGravity(boolean newState)
newState - true to preserve this body's gravity, false to allow it
to be overwritten (default=false)public void setSleepingThresholds(float linear,
float angular)
These thresholds influence whether the body will be deactivated to save resources. Low values keep the body active when it barely moves.
linear - the desired linear threshold (in physics-space units per
second, ≥0, default=0.8)angular - the desired angular threshold (in radians per second,
≥0, default=1)public Vector3f totalAppliedForce(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Vector3f totalAppliedTorque(Vector3f storeResult)
storeResult - storage for the result (modified if not null)protected void postRebuild()
protected void preRebuild()
public Vector3f getGravity(Vector3f storeResult)
getGravity in class PhysicsBodystoreResult - storage for the result (modified if not null)public float getMass()
getMass in class PhysicsBodypublic void setGravity(Vector3f acceleration)
Invoke this method after adding the body to a PhysicsSpace. Unless protection is set, adding a body to a PhysicsSpace overrides its gravity.
setGravity in class PhysicsBodyacceleration - the desired acceleration vector (in physics-space
coordinates, not null, finite, unaffected, default=(0,0,0))setProtectGravity(boolean),
setGravityDp(com.simsilica.mathd.Vec3d)public void setMass(float mass)
setMass in class PhysicsBodymass - the desired mass (≥0, default=1)public void setPhysicsLocation(Vector3f location)
setPhysicsLocation in class PhysicsBodylocation - the desired location (in physics-space coordinates, not
null, finite, unaffected)