Class PhysicsRigidBody
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
- Direct Known Subclasses:
PhysicsVehicle
,RigidBodyControl
btRigidBody
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final Logger
message logger for this classprotected float
JVM copy of the mass (>0) of a dynamic body, or 0 for a static bodyFields inherited from class com.jme3.bullet.objects.PhysicsBody
massForStatic
Fields inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
COLLISION_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, logger
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Reactivate the body if it has been deactivated due to lack of motion.void
applyCentralForce
(com.jme3.math.Vector3f force) Apply a force to the body's center of mass.void
applyCentralImpulse
(com.jme3.math.Vector3f impulse) Apply an impulse to the body's center of mass.void
applyForce
(com.jme3.math.Vector3f force, com.jme3.math.Vector3f offset) Apply a force to the body.void
applyImpulse
(com.jme3.math.Vector3f impulse, com.jme3.math.Vector3f offset) Apply an off-center impulse to the body.void
applyTorque
(com.jme3.math.Vector3f torque) Apply a torque to the body.void
applyTorqueImpulse
(com.jme3.math.Vector3f torqueImpulse) Apply a torque impulse to the body.void
Clear all forces and torques acting on the body, including gravity.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned body into a deep-cloned one, using the specified Cloner and original to resolve copied fields.float
Return the body's angular damping.float
For compatibility with the jme3-jbullet library.com.jme3.math.Vector3f
getAngularFactor
(com.jme3.math.Vector3f storeResult) Copy the body's angular factors.float
Return the body's angular-motion sleeping threshold.com.jme3.math.Vector3f
For compatibility with the jme3-jbullet library.com.jme3.math.Vector3f
getAngularVelocity
(com.jme3.math.Vector3f storeResult) Copy the body's angular velocity.com.simsilica.mathd.Vec3d
getAngularVelocityDp
(com.simsilica.mathd.Vec3d storeResult) Copy the body's angular velocity.com.jme3.math.Vector3f
getAngularVelocityLocal
(com.jme3.math.Vector3f storeResult) Calculate the body's angular velocity in its local coordinates.com.jme3.math.Vector3f
getGravity
(com.jme3.math.Vector3f storeResult) Copy the body's gravitational acceleration.com.simsilica.mathd.Vec3d
getGravityDp
(com.simsilica.mathd.Vec3d storeResult) Copy the body's gravitational acceleration.com.jme3.math.Vector3f
getInverseInertiaLocal
(com.jme3.math.Vector3f storeResult) Copy the principal (diagonal) elements of the inverse inertia tensor in the body's local coordinates.com.jme3.math.Matrix3f
getInverseInertiaWorld
(com.jme3.math.Matrix3f storeResult) Compute the inverse inertia tensor in physics-space coordinates.float
Return the body's linear damping.com.jme3.math.Vector3f
getLinearFactor
(com.jme3.math.Vector3f storeResult) Copy the body's linear factors.float
Return the body's linear-motion sleeping threshold.com.jme3.math.Vector3f
For compatibility with the jme3-jbullet library.com.jme3.math.Vector3f
getLinearVelocity
(com.jme3.math.Vector3f storeResult) Copy the linear velocity of the body's center of mass.com.simsilica.mathd.Vec3d
getLinearVelocityDp
(com.simsilica.mathd.Vec3d storeResult) Copy the linear velocity of the body's center of mass.float
getMass()
Return the body's mass.Access the body's motion state.com.jme3.math.Quaternion
For compatibility with the jme3-jbullet library.float
Calculate the squared speed of the body.boolean
Test whether the body is in dynamic mode.boolean
Test whether the body's gravity can be overwritten by PhysicsSpace.final boolean
Test whether the body is in kinematic mode.double
Calculate the body's kinetic energy (linear + angular).double
Calculate the mechanical energy of the body (kinetic + potential) assuming a uniform gravitational field.protected void
For use by subclasses.protected void
For use by subclasses.void
read
(com.jme3.export.JmeImporter importer) De-serialize this body from the specified importer, for example when loading from a J3O file.void
Rebuild the rigid body with a new native object.void
setAngularDamping
(float angularDamping) Alter the body's angular damping.void
setAngularFactor
(float factor) Alter the body's angular factor.void
setAngularFactor
(com.jme3.math.Vector3f factor) Alter the body's angular factors, used to scale applied torques.void
setAngularSleepingThreshold
(float threshold) Alter the body's angular-motion sleeping threshold.void
setAngularVelocity
(com.jme3.math.Vector3f omega) Alter the body's angular velocity.void
setAngularVelocityDp
(com.simsilica.mathd.Vec3d omega) Alter the body's angular velocity.void
setCollisionShape
(CollisionShape desiredShape) Apply the specified CollisionShape to the body.void
setContactResponse
(boolean newState) Enable/disable the body's contact response.void
setDamping
(float linearDamping, float angularDamping) Alter the body's damping.void
setEnableSleep
(boolean setting) Alter the body's activation state to allow/disallow sleeping.void
setGravity
(com.jme3.math.Vector3f acceleration) Alter the body's gravitational acceleration.void
setGravityDp
(com.simsilica.mathd.Vec3d acceleration) Alter the body's gravitational acceleration.void
setInverseInertiaLocal
(com.jme3.math.Vector3f inverseInertia) Alter the principal (diagonal) components of the local inertia tensor in the body's local coordinates.void
setKinematic
(boolean kinematic) Put the body into kinematic mode or take it out of kinematic mode.void
setLinearDamping
(float linearDamping) Alter the body's linear damping.void
setLinearFactor
(com.jme3.math.Vector3f factor) Alter the body's linear factors.void
setLinearSleepingThreshold
(float threshold) Alter the body's linear-motion sleeping threshold.void
setLinearVelocity
(com.jme3.math.Vector3f velocity) Alter the linear velocity of the body's center of mass.void
setLinearVelocityDp
(com.simsilica.mathd.Vec3d velocity) Alter the linear velocity of the body's center of mass.void
setMass
(float mass) Alter the body's mass.void
setPhysicsLocation
(com.jme3.math.Vector3f location) Directly relocate the body's center of mass.void
setPhysicsLocationDp
(com.simsilica.mathd.Vec3d location) Directly relocate the body's center of mass.void
setPhysicsRotation
(com.jme3.math.Matrix3f orientation) Directly alter the body's orientation.void
setPhysicsRotation
(com.jme3.math.Quaternion orientation) Directly reorient the body.void
setPhysicsRotationDp
(com.simsilica.mathd.Matrix3d orientation) Directly reorient the body.void
setPhysicsRotationDp
(com.simsilica.mathd.Quatd orientation) Directly reorient the body.void
setPhysicsScale
(com.jme3.math.Vector3f newScale) Rescale the body.void
setPhysicsTransform
(com.jme3.math.Transform transform) Directly alter the body's transform, including the scale of its shape.void
setProtectGravity
(boolean newState) Alter whether the 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 the body's sleeping thresholds.com.jme3.math.Vector3f
totalAppliedForce
(com.jme3.math.Vector3f storeResult) Determine the total force applied to the body (excluding contact forces, damping, and gravity).com.jme3.math.Vector3f
totalAppliedTorque
(com.jme3.math.Vector3f storeResult) Determine the total torque applied to the body (excluding contact forces and damping).void
write
(com.jme3.export.JmeExporter exporter) Serialize the body to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.objects.PhysicsBody
addJoint, cloneJoints, countJoints, getDeactivationDeadline, isDeactivationEnabled, listJoints, readJoints, removeJoint, setDeactivationDeadline, setDeactivationEnabled, writeJoints
Methods inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
activate, addCollideWithGroup, addToIgnoreList, attachCollisionShape, boundingBox, clearIgnoreList, cloneIgnoreList, collisionFlags, copyPcoProperties, countIgnored, debugMeshInitListener, debugMeshNormals, debugMeshResolution, debugNumSides, finalizeNative, findInstance, getActivationState, getAnisotropicFriction, getApplicationData, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getCollideWithGroups, getCollisionGroup, getCollisionShape, getCollisionSpace, getContactDamping, getContactProcessingThreshold, getContactStiffness, getDeactivationTime, getDebugMaterial, getFriction, getInternalType, getPhysicsLocation, getPhysicsLocation, getPhysicsLocationDp, getPhysicsRotation, getPhysicsRotationDp, getPhysicsRotationMatrix, getPhysicsRotationMatrixDp, getRestitution, getRollingFriction, getScale, getSpinningFriction, getTransform, getUserObject, hasAnisotropicFriction, ignores, initUserPointer, isActive, isContactResponse, isInWorld, isStatic, jmeClone, listIgnoredPcos, proxyGroup, proxyMask, readPcoProperties, removeCollideWithGroup, removeFromIgnoreList, setActivationState, setAnisotropicFriction, setApplicationData, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setContactDamping, setContactProcessingThreshold, setContactStiffness, setDeactivationTime, setDebugMaterial, setDebugMeshInitListener, setDebugMeshNormals, setDebugMeshResolution, setDebugNumSides, setFriction, setIgnoreList, setLocationAndBasis, setRestitution, setRollingFriction, setSpinningFriction, setUserIndex, setUserIndex2, setUserIndex3, setUserObject, spaceId, toString, userIndex, userIndex2, userIndex3
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger2
message logger for this class -
mass
protected float massJVM copy of the mass (>0) of a dynamic body, or 0 for a static body
-
-
Constructor Details
-
PhysicsRigidBody
protected PhysicsRigidBody()No-argument constructor needed by SavableClassUtil. -
PhysicsRigidBody
Instantiate a responsive, dynamic body with mass=1 and the specified CollisionShape. The new body is not added to any PhysicsSpace.- Parameters:
shape
- the desired shape (not null, alias created)
-
PhysicsRigidBody
Instantiate a responsive dynamic or static body with the specified CollisionShape and mass. The new body is not added to any PhysicsSpace.- Parameters:
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)
-
-
Method Details
-
activate
public void activate()Reactivate the body if it has been deactivated due to lack of motion. -
applyCentralForce
public void applyCentralForce(com.jme3.math.Vector3f force) Apply a force to the body's center of mass. Effective on the next simulation step, then cleared.To apply an impulse, use
applyCentralImpulse(com.jme3.math.Vector3f)
.- Parameters:
force
- the force vector (mass times distance per second squared in physics-space coordinates, not null, finite, unaffected)
-
applyCentralImpulse
public void applyCentralImpulse(com.jme3.math.Vector3f impulse) Apply an impulse to the body's center of mass.- Parameters:
impulse
- the impulse vector (mass times distance per second in physics-space coordinates, not null, unaffected)
-
applyForce
public void applyForce(com.jme3.math.Vector3f force, com.jme3.math.Vector3f offset) Apply a force to the body. Effective on the next simulation step, then cleared.To apply an impulse, use
applyImpulse(com.jme3.math.Vector3f, com.jme3.math.Vector3f)
.- Parameters:
force
- the force vector (mass times distance per second squared in physics-space coordinates, not null, finite, unaffected)offset
- the location to apply the force (relative to the body's center in physics-space coordinates, not null, finite, unaffected)
-
applyImpulse
public void applyImpulse(com.jme3.math.Vector3f impulse, com.jme3.math.Vector3f offset) Apply an off-center impulse to the body.- Parameters:
impulse
- the impulse vector (mass times distance per second in physics-space coordinates, not null, unaffected)offset
- where to apply the impulse (relative to the body's center of mass in physics-space coordinates, not null, unaffected)
-
applyTorque
public void applyTorque(com.jme3.math.Vector3f torque) Apply a torque to the body. Effective on the next simulation step, then cleared.To apply a torque impulse, use
applyTorqueImpulse(com.jme3.math.Vector3f)
.- Parameters:
torque
- the torque vector (mass times distance squared per second squared in physics-space coordinates, not null, finite, unaffected)
-
applyTorqueImpulse
public void applyTorqueImpulse(com.jme3.math.Vector3f torqueImpulse) Apply a torque impulse to the body.- Parameters:
torqueImpulse
- the torque impulse vector (mass times physics-space units squared per second in physics-space coordinates, not null, unaffected)
-
clearForces
public void clearForces()Clear all forces and torques acting on the body, including gravity. -
getAngularDamping
public float getAngularDamping()Return the body's angular damping.- Returns:
- the damping fraction (≥0, ≤1)
-
getAngularFactor
public float getAngularFactor()For compatibility with the jme3-jbullet library.- Returns:
- the angular factor
-
getAngularFactor
public com.jme3.math.Vector3f getAngularFactor(com.jme3.math.Vector3f storeResult) Copy the body's angular factors.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the angular factor for each axis (either storeResult or a new vector, not null)
-
getAngularSleepingThreshold
public float getAngularSleepingThreshold()Return the body's angular-motion sleeping threshold. Note that "sleeping" is synonym for "deactivation".- Returns:
- the angular-motion threshold (in radians per second, ≥0)
-
getAngularVelocity
public com.jme3.math.Vector3f getAngularVelocity()For compatibility with the jme3-jbullet library.- Returns:
- a new velocity vector (radians per second in physics-space coordinates, not null)
-
getAngularVelocity
public com.jme3.math.Vector3f getAngularVelocity(com.jme3.math.Vector3f storeResult) Copy the body's angular velocity. The body must be in dynamic mode.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an angular-velocity vector (radians per second in physics-space coordinates, either storeResult or a new vector, not null)
-
getAngularVelocityDp
public com.simsilica.mathd.Vec3d getAngularVelocityDp(com.simsilica.mathd.Vec3d storeResult) Copy the body's angular velocity. The body must be in dynamic mode.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an angular-velocity vector (radians per second in physics-space coordinates, either storeResult or a new vector, not null)
-
getAngularVelocityLocal
public com.jme3.math.Vector3f getAngularVelocityLocal(com.jme3.math.Vector3f storeResult) Calculate the body's angular velocity in its local coordinates. The body must be in dynamic mode.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a velocity vector (radians per second in local coordinates, either storeResult or a new vector, not null)
-
getGravityDp
public com.simsilica.mathd.Vec3d getGravityDp(com.simsilica.mathd.Vec3d storeResult) Copy the body's gravitational acceleration.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an acceleration vector in physics-space coordinates (either storeResult or a new vector, not null)
-
getInverseInertiaLocal
public com.jme3.math.Vector3f getInverseInertiaLocal(com.jme3.math.Vector3f storeResult) Copy the principal (diagonal) elements of the inverse inertia tensor in the body's local coordinates.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a vector (either storeResult or a new vector, not null)
-
getInverseInertiaWorld
public com.jme3.math.Matrix3f getInverseInertiaWorld(com.jme3.math.Matrix3f storeResult) Compute the inverse inertia tensor in physics-space coordinates.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a matrix (either storeResult or a new matrix, not null)
-
getLinearDamping
public float getLinearDamping()Return the body's linear damping.- Returns:
- the damping fraction (≥0, ≤1)
-
getLinearFactor
public com.jme3.math.Vector3f getLinearFactor(com.jme3.math.Vector3f storeResult) Copy the body's linear factors.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the linear factor for each axis (either storeResult or a new vector, not null)
-
getLinearSleepingThreshold
public float getLinearSleepingThreshold()Return the body's linear-motion sleeping threshold. Note that "sleeping" is synonym for "deactivation".- Returns:
- the linear-motion threshold (in physics-space units per second, ≥0)
-
getLinearVelocity
public com.jme3.math.Vector3f getLinearVelocity()For compatibility with the jme3-jbullet library.- Returns:
- a new velocity vector (physics-space units per second in physics-space coordinates, not null)
-
getLinearVelocity
public com.jme3.math.Vector3f getLinearVelocity(com.jme3.math.Vector3f storeResult) Copy the linear velocity of the body's center of mass. The body must be in dynamic mode.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a velocity vector (physics-space units per second in physics-space coordinates, either storeResult or a new vector, not null)
-
getLinearVelocityDp
public com.simsilica.mathd.Vec3d getLinearVelocityDp(com.simsilica.mathd.Vec3d storeResult) Copy the linear velocity of the body's center of mass. The body must be in dynamic mode.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- a velocity vector (physics-space units per second in physics-space coordinates, either storeResult or a new vector, not null)
-
getMotionState
Access the body's motion state.- Returns:
- the pre-existing instance (not null)
-
getPhysicsRotation
public com.jme3.math.Quaternion getPhysicsRotation()For compatibility with the jme3-jbullet library.- Returns:
- a new Quaternion (relative to physics-space coordinates, not null)
-
getSquaredSpeed
public float getSquaredSpeed()Calculate the squared speed of the body. The body must be in dynamic mode.- Returns:
- the squared speed (in physics-space units squared per second squared, ≥0)
-
isDynamic
public boolean isDynamic()Test whether the body is in dynamic mode.- Returns:
- true if in dynamic mode, otherwise false (static/kinematic mode)
-
isGravityProtected
public boolean isGravityProtected()Test whether the body's gravity can be overwritten by PhysicsSpace.- Returns:
- false if the body's gravity can be overwritten, otherwise true
-
isKinematic
public final boolean isKinematic()Test whether the body is in kinematic mode.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.
- Returns:
- true if in kinematic mode, otherwise false (dynamic/static mode)
-
kineticEnergy
public double kineticEnergy()Calculate the body's kinetic energy (linear + angular). The body must be in dynamic mode.- Returns:
- the total kinetic energy (≥0)
-
mechanicalEnergy
public double mechanicalEnergy()Calculate the mechanical energy of the body (kinetic + potential) assuming a uniform gravitational field. The body must be in dynamic mode.- Returns:
- the total mechanical energy
-
rebuildRigidBody
public void rebuildRigidBody()Rebuild the rigid body with a new native object. -
setAngularDamping
public void setAngularDamping(float angularDamping) Alter the body's angular damping.- Parameters:
angularDamping
- the desired angular damping fraction (≥0, ≤1, default=0)
-
setAngularFactor
public void setAngularFactor(float factor) Alter the body's angular factor.- Parameters:
factor
- the desired angular factor for all axes (not null, unaffected, default=1)
-
setAngularFactor
public void setAngularFactor(com.jme3.math.Vector3f factor) Alter the body's angular factors, used to scale applied torques.- Parameters:
factor
- the desired angular factor for each axis (not null, unaffected, default=(1,1,1))
-
setAngularSleepingThreshold
public void setAngularSleepingThreshold(float threshold) Alter the body's angular-motion sleeping threshold. Note that "sleeping" is synonym for "deactivation".- Parameters:
threshold
- the desired threshold (in radians per second, ≥0, default=1)
-
setAngularVelocity
public void setAngularVelocity(com.jme3.math.Vector3f omega) Alter the body's angular velocity.- Parameters:
omega
- the desired angular velocity (radians per second in physics-space coordinates, not null, finite, unaffected)
-
setAngularVelocityDp
public void setAngularVelocityDp(com.simsilica.mathd.Vec3d omega) Alter the body's angular velocity.- Parameters:
omega
- the desired angular velocity (radians per second in physics-space coordinates, not null, unaffected)
-
setCollisionShape
Apply the specified CollisionShape to the body. The body gets rebuilt on the native side.- Overrides:
setCollisionShape
in classPhysicsCollisionObject
- Parameters:
desiredShape
- the shape to apply (not null, alias created)
-
setContactResponse
public void setContactResponse(boolean newState) Enable/disable the body's contact response.- Parameters:
newState
- true to respond to contacts, false to ignore them (default=true)
-
setDamping
public void setDamping(float linearDamping, float angularDamping) Alter the body's damping.- Parameters:
linearDamping
- the desired linear damping fraction (≥0, ≤1, default=0)angularDamping
- the desired angular damping fraction (≥0, ≤1, default=0)
-
setEnableSleep
public void setEnableSleep(boolean setting) Alter the body's activation state to allow/disallow sleeping. Note that "sleeping" is synonym for "deactivation".- Parameters:
setting
- true→enable sleeping, false→disable sleeping (default=true)
-
setGravityDp
public void setGravityDp(com.simsilica.mathd.Vec3d acceleration) Alter the body's gravitational acceleration.Invoke this method after adding the body to a PhysicsSpace. Unless protection is set, adding a body to a PhysicsSpace overrides its gravity.
- Parameters:
acceleration
- the desired acceleration vector (in physics-space coordinates, not null, unaffected, default=(0,0,0))- See Also:
-
setInverseInertiaLocal
public void setInverseInertiaLocal(com.jme3.math.Vector3f inverseInertia) Alter the principal (diagonal) components of the local inertia tensor in the body's local coordinates.- Parameters:
inverseInertia
- the desired component values (not null, unaffected)
-
setKinematic
public void setKinematic(boolean kinematic) Put the body into kinematic mode or take it out of kinematic mode.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.
- Parameters:
kinematic
- true→set kinematic mode, false→set dynamic (default=false)
-
setLinearDamping
public void setLinearDamping(float linearDamping) Alter the body's linear damping.- Parameters:
linearDamping
- the desired linear damping fraction (≥0, ≤1, default=0)
-
setLinearFactor
public void setLinearFactor(com.jme3.math.Vector3f factor) Alter the body's linear factors.- Parameters:
factor
- the desired linear factor for each axis (not null, unaffected, default=(1,1,1))
-
setLinearSleepingThreshold
public void setLinearSleepingThreshold(float threshold) Alter the body's linear-motion sleeping threshold. Note that "sleeping" is synonym for "deactivation".- Parameters:
threshold
- the desired threshold (in physics-space units per second, ≥0, default=0.8)
-
setLinearVelocity
public void setLinearVelocity(com.jme3.math.Vector3f velocity) Alter the linear velocity of the body's center of mass.- Parameters:
velocity
- the desired velocity (physics-space units per second in physics-space coordinates, not null, finite, unaffected)
-
setLinearVelocityDp
public void setLinearVelocityDp(com.simsilica.mathd.Vec3d velocity) Alter the linear velocity of the body's center of mass.- Parameters:
velocity
- the desired velocity (physics-space units per second in physics-space coordinates, not null, unaffected)
-
setPhysicsLocationDp
public void setPhysicsLocationDp(com.simsilica.mathd.Vec3d location) Directly relocate the body's center of mass.- Parameters:
location
- the desired location (in physics-space coordinates, not null, unaffected)
-
setPhysicsRotation
public void setPhysicsRotation(com.jme3.math.Matrix3f orientation) Directly alter the body's orientation.- Parameters:
orientation
- the desired orientation (rotation matrix relative to physics-space coordinates, not null, unaffected)
-
setPhysicsRotation
public void setPhysicsRotation(com.jme3.math.Quaternion orientation) Directly reorient the body.- Parameters:
orientation
- the desired orientation (relative to physics-space coordinates, not null, not zero, unaffected)
-
setPhysicsRotationDp
public void setPhysicsRotationDp(com.simsilica.mathd.Matrix3d orientation) Directly reorient the body.- Parameters:
orientation
- the desired orientation (rotation matrix relative to physics-space coordinates, not null, unaffected)
-
setPhysicsRotationDp
public void setPhysicsRotationDp(com.simsilica.mathd.Quatd orientation) Directly reorient the body.- Parameters:
orientation
- the desired orientation (relative to physics-space coordinates, not null, unaffected)
-
setPhysicsScale
public void setPhysicsScale(com.jme3.math.Vector3f newScale) Rescale the body. Note that if it has joints, their pivot locations will not be adjusted.- Parameters:
newScale
- the desired scale factor for each local axis (not null, no negative component, unaffected, default=(1,1,1))
-
setPhysicsTransform
public void setPhysicsTransform(com.jme3.math.Transform transform) Directly alter the body's transform, including the scale of its shape. If the body has joints, their pivot points will not be adjusted for scale changes.- Parameters:
transform
- the desired transform (relative to physics-space coordinates, not null, unaffected)
-
setProtectGravity
public void setProtectGravity(boolean newState) Alter whether the body's gravity should be overwritten if the body gets added to a PhysicsSpace or the gravity of the PhysicsSpace changes.- Parameters:
newState
- true to preserve the body's gravity, false to allow it to be overwritten (default=false)
-
setSleepingThresholds
public void setSleepingThresholds(float linear, float angular) Alter the body's sleeping thresholds. Note that "sleeping" is synonym for "deactivation".These thresholds influence whether the body will be deactivated to save resources. Low values keep the body active when it barely moves.
- Parameters:
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)
-
totalAppliedForce
public com.jme3.math.Vector3f totalAppliedForce(com.jme3.math.Vector3f storeResult) Determine the total force applied to the body (excluding contact forces, damping, and gravity).- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the total force (either storeResult or a new vector, mass times physics-space units per second squared in physics-space coordinates)
-
totalAppliedTorque
public com.jme3.math.Vector3f totalAppliedTorque(com.jme3.math.Vector3f storeResult) Determine the total torque applied to the body (excluding contact forces and damping).- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the total torque (either storeResult or a new vector, mass times physics-space units squared per second squared in physics-space coordinates)
-
postRebuild
protected void postRebuild()For use by subclasses. -
preRebuild
protected void preRebuild()For use by subclasses. -
cloneFields
Callback fromCloner
to convert this shallow-cloned body into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Overrides:
cloneFields
in classPhysicsBody
- Parameters:
cloner
- the Cloner that's cloning this body (not null)original
- the instance from which this body was shallow-cloned (not null, unaffected)
-
getGravity
public com.jme3.math.Vector3f getGravity(com.jme3.math.Vector3f storeResult) Copy the body's gravitational acceleration.- Specified by:
getGravity
in classPhysicsBody
- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- an acceleration vector in physics-space coordinates (either storeResult or a new vector, not null)
-
getMass
public float getMass()Return the body's mass.- Specified by:
getMass
in classPhysicsBody
- Returns:
- the mass (>0) or zero for a static body
-
read
De-serialize this body from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classPhysicsCollisionObject
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
setGravity
public void setGravity(com.jme3.math.Vector3f acceleration) Alter the body's gravitational acceleration.Invoke this method after adding the body to a PhysicsSpace. Unless protection is set, adding a body to a PhysicsSpace overrides its gravity.
- Specified by:
setGravity
in classPhysicsBody
- Parameters:
acceleration
- the desired acceleration vector (in physics-space coordinates, not null, finite, unaffected, default=(0,0,0))- See Also:
-
setMass
public void setMass(float mass) Alter the body's mass. Static bodies have mass=0. For dynamic bodies, it is best to keep the mass on the order of 1.- Specified by:
setMass
in classPhysicsBody
- Parameters:
mass
- the desired mass (≥0, default=1)
-
setPhysicsLocation
public void setPhysicsLocation(com.jme3.math.Vector3f location) Directly relocate the body's center of mass.- Specified by:
setPhysicsLocation
in classPhysicsBody
- Parameters:
location
- the desired location (in physics-space coordinates, not null, finite, unaffected)
-
write
Serialize the body to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classPhysicsCollisionObject
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-