public class PhysicsRigidBody extends PhysicsCollisionObject
PhysicsRigidBody - Basic physics object
Modifier and Type | Field and Description |
---|---|
protected com.bulletphysics.dynamics.RigidBodyConstructionInfo |
constructionInfo |
protected java.util.ArrayList<PhysicsJoint> |
joints |
protected boolean |
kinematic |
protected javax.vecmath.Vector3f |
localInertia |
protected float |
mass |
protected RigidBodyMotionState |
motionState |
protected com.bulletphysics.dynamics.RigidBody |
rBody |
protected javax.vecmath.Matrix3f |
tempMatrix |
protected com.bulletphysics.linearmath.Transform |
tempTrans |
protected javax.vecmath.Vector3f |
tempVec |
protected javax.vecmath.Vector3f |
tempVec2 |
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, collisionGroup, collisionGroupsMask, collisionShape
Modifier | Constructor and Description |
---|---|
protected |
PhysicsRigidBody() |
|
PhysicsRigidBody(CollisionShape shape)
Creates a new PhysicsRigidBody with the supplied collision shape
|
|
PhysicsRigidBody(CollisionShape shape,
float mass) |
Modifier and Type | Method and Description |
---|---|
void |
activate()
reactivates this PhysicsRigidBody when it has been deactivated because it was not moving
|
void |
addJoint(PhysicsJoint joint)
do not use manually, joints are added automatically
|
void |
applyCentralForce(Vector3f force)
Apply a force to the PhysicsRigidBody, only applies force if the next physics update call
updates the physics space.
To apply an impulse, use applyImpulse. |
void |
applyForce(Vector3f force,
Vector3f location)
Apply a force to the PhysicsRigidBody, only applies force if the next physics update call
updates the physics space.
To apply an impulse, use applyImpulse, use applyContinuousForce to apply continuous force. |
void |
applyImpulse(Vector3f impulse,
Vector3f rel_pos)
Apply an impulse to the PhysicsRigidBody in the next physics update.
|
void |
applyTorque(Vector3f torque)
Apply a force to the PhysicsRigidBody, only applies force if the next physics update call
updates the physics space.
To apply an impulse, use applyImpulse. |
void |
applyTorqueImpulse(Vector3f vec)
Apply a torque impulse to the PhysicsRigidBody in the next physics update.
|
void |
clearForces()
Clear all forces from the PhysicsRigidBody
|
void |
destroy()
destroys this PhysicsRigidBody and removes it from memory
|
float |
getAngularDamping() |
float |
getAngularFactor() |
float |
getAngularSleepingThreshold() |
Vector3f |
getAngularVelocity()
Get the current angular velocity of this PhysicsRigidBody
|
void |
getAngularVelocity(Vector3f vec)
Get the current angular velocity of this PhysicsRigidBody
|
float |
getCcdMotionThreshold() |
float |
getCcdSquareMotionThreshold() |
float |
getCcdSweptSphereRadius() |
float |
getFriction() |
Vector3f |
getGravity() |
Vector3f |
getGravity(Vector3f gravity) |
Vector3f |
getInterpolatedPhysicsLocation(Vector3f location)
Gets the physics object location
|
Matrix3f |
getInterpolatedPhysicsRotation(Matrix3f rotation)
Gets the physics object rotation
|
java.util.List<PhysicsJoint> |
getJoints()
Returns a list of connected joints.
|
float |
getLinearDamping() |
float |
getLinearSleepingThreshold() |
Vector3f |
getLinearVelocity()
Get the current linear velocity of this PhysicsRigidBody
|
void |
getLinearVelocity(Vector3f vec)
Get the current linear velocity of this PhysicsRigidBody
|
float |
getMass() |
RigidBodyMotionState |
getMotionState() |
com.bulletphysics.dynamics.RigidBody |
getObjectId()
used internally
|
Vector3f |
getPhysicsLocation()
Gets the physics object location, instantiates a new Vector3f object
|
Vector3f |
getPhysicsLocation(Vector3f location)
Gets the physics object location, no object instantiation
|
Quaternion |
getPhysicsRotation()
Gets the physics object rotation as a quaternion, converts the bullet Matrix3f value,
instantiates new object
|
Quaternion |
getPhysicsRotation(Quaternion rotation)
Gets the physics object rotation as a quaternion, converts the bullet Matrix3f value
|
Matrix3f |
getPhysicsRotationMatrix()
Gets the physics object rotation
|
Matrix3f |
getPhysicsRotationMatrix(Matrix3f rotation)
Gets the physics object rotation as a matrix, no conversions and no object instantiation
|
float |
getRestitution() |
boolean |
isActive() |
boolean |
isContactResponse()
Test whether this body responds to contacts.
|
boolean |
isKinematic() |
protected void |
postRebuild() |
protected void |
preRebuild() |
void |
read(JmeImporter e)
De-serialize this body, for example when loading from a J3O file.
|
protected void |
rebuildRigidBody()
Builds/rebuilds the phyiscs body when parameters have changed
|
void |
removeJoint(PhysicsJoint joint) |
void |
setAngularDamping(float angularDamping) |
void |
setAngularFactor(float factor) |
void |
setAngularSleepingThreshold(float angularSleepingThreshold) |
void |
setAngularVelocity(Vector3f vec)
Sets the angular velocity of this PhysicsRigidBody
|
void |
setCcdMotionThreshold(float threshold)
Sets the amount of motion that has to happen in one physics tick to trigger the continuous motion detection
This avoids the problem of fast objects moving through other objects, set to zero to disable (default) |
void |
setCcdSweptSphereRadius(float radius) |
void |
setCollisionShape(CollisionShape collisionShape)
Sets a CollisionShape to this physics object, note that the object should
not be in the physics space when adding a new collision shape as it is rebuilt
on the physics side.
|
void |
setContactResponse(boolean responsive)
Enable/disable this body's contact response.
|
void |
setDamping(float linearDamping,
float angularDamping) |
void |
setFriction(float friction)
Sets the friction of this physics object
|
void |
setGravity(Vector3f gravity)
Set the local gravity of this PhysicsRigidBody
Set this after adding the node to the PhysicsSpace, the PhysicsSpace assigns its current gravity to the physics node when its added. |
void |
setKinematic(boolean kinematic)
Sets the node to kinematic mode.
|
void |
setLinearDamping(float linearDamping) |
void |
setLinearSleepingThreshold(float linearSleepingThreshold) |
void |
setLinearVelocity(Vector3f vec)
Sets the linear velocity of this PhysicsRigidBody
|
void |
setMass(float mass)
Sets the mass of this PhysicsRigidBody, objects with mass=0 are static.
|
void |
setPhysicsLocation(Vector3f location)
Sets the physics object location
|
void |
setPhysicsRotation(Matrix3f rotation)
Sets the physics object rotation
|
void |
setPhysicsRotation(Quaternion rotation)
Sets the physics object rotation
|
void |
setRestitution(float restitution)
The "bouncyness" of the PhysicsRigidBody, best performance if restitution=0
|
void |
setSleepingThresholds(float linear,
float angular)
sets the sleeping thresholds, these define when the object gets deactivated
to save ressources.
|
void |
write(JmeExporter e)
Serialize this body, for example when saving to a J3O file.
|
addCollideWithGroup, getCollideWithGroups, getCollisionGroup, getCollisionShape, getUserObject, removeCollideWithGroup, setCollideWithGroups, setCollisionGroup, setUserObject
protected com.bulletphysics.dynamics.RigidBodyConstructionInfo constructionInfo
protected com.bulletphysics.dynamics.RigidBody rBody
protected RigidBodyMotionState motionState
protected float mass
protected boolean kinematic
protected javax.vecmath.Vector3f tempVec
protected javax.vecmath.Vector3f tempVec2
protected com.bulletphysics.linearmath.Transform tempTrans
protected javax.vecmath.Matrix3f tempMatrix
protected javax.vecmath.Vector3f localInertia
protected java.util.ArrayList<PhysicsJoint> joints
protected PhysicsRigidBody()
public PhysicsRigidBody(CollisionShape shape)
shape
- the desired shape (not null, alias created)public PhysicsRigidBody(CollisionShape shape, float mass)
protected void rebuildRigidBody()
protected void preRebuild()
protected void postRebuild()
public RigidBodyMotionState getMotionState()
public void setPhysicsLocation(Vector3f location)
location
- the location of the actual physics objectpublic void setPhysicsRotation(Matrix3f rotation)
rotation
- the rotation of the actual physics objectpublic void setPhysicsRotation(Quaternion rotation)
rotation
- the rotation of the actual physics objectpublic Vector3f getPhysicsLocation()
public Matrix3f getPhysicsRotationMatrix()
public Vector3f getPhysicsLocation(Vector3f location)
location
- the location of the actual physics object is stored in this Vector3fpublic Matrix3f getPhysicsRotationMatrix(Matrix3f rotation)
rotation
- the rotation of the actual physics object is stored in this Matrix3fpublic Quaternion getPhysicsRotation()
public Quaternion getPhysicsRotation(Quaternion rotation)
rotation
- the rotation of the actual physics object is stored in this Quaternionpublic Vector3f getInterpolatedPhysicsLocation(Vector3f location)
location
- the location of the actual physics object is stored in this Vector3fpublic Matrix3f getInterpolatedPhysicsRotation(Matrix3f rotation)
rotation
- the rotation of the actual physics object is stored in this Matrix3fpublic void setKinematic(boolean kinematic)
kinematic
- true→set kinematic mode, false→set dynamic
(default=false)public boolean isKinematic()
public void setContactResponse(boolean responsive)
responsive
- true to respond to contacts, false to ignore them
(default=true)public boolean isContactResponse()
public void setCcdSweptSphereRadius(float radius)
public void setCcdMotionThreshold(float threshold)
threshold
- the desired minimum distance per timestep to trigger CCD
(in physics-space units, >0) or zero to disable CCD (default=0)public float getCcdSweptSphereRadius()
public float getCcdMotionThreshold()
public float getCcdSquareMotionThreshold()
public float getMass()
public void setMass(float mass)
mass
- the desired mass (>0) or 0 for a static body (default=1)public Vector3f getGravity()
public void setGravity(Vector3f gravity)
gravity
- the gravity vector to setpublic float getFriction()
public void setFriction(float friction)
friction
- the friction of this physics objectpublic void setDamping(float linearDamping, float angularDamping)
public void setLinearDamping(float linearDamping)
public void setAngularDamping(float angularDamping)
public float getLinearDamping()
public float getAngularDamping()
public float getRestitution()
public void setRestitution(float restitution)
restitution
- the desired value (default=0)public Vector3f getAngularVelocity()
public void getAngularVelocity(Vector3f vec)
vec
- the vector to store the velocity inpublic void setAngularVelocity(Vector3f vec)
vec
- the angular velocity of this PhysicsRigidBodypublic Vector3f getLinearVelocity()
public void getLinearVelocity(Vector3f vec)
vec
- the vector to store the velocity inpublic void setLinearVelocity(Vector3f vec)
vec
- the linear velocity of this PhysicsRigidBodypublic void applyForce(Vector3f force, Vector3f location)
force
- the forcelocation
- the location of the forcepublic void applyCentralForce(Vector3f force)
force
- the forcepublic void applyTorque(Vector3f torque)
torque
- the torquepublic void applyImpulse(Vector3f impulse, Vector3f rel_pos)
impulse
- applied impulserel_pos
- location relative to objectpublic void applyTorqueImpulse(Vector3f vec)
vec
- the torque impulse vector (in physics-space coordinates,
not null, unaffected)public void clearForces()
public void setCollisionShape(CollisionShape collisionShape)
PhysicsCollisionObject
setCollisionShape
in class PhysicsCollisionObject
collisionShape
- the CollisionShape to setpublic void activate()
public boolean isActive()
public void setSleepingThresholds(float linear, float angular)
linear
- the linear sleeping thresholdangular
- the angular sleeping thresholdpublic void setLinearSleepingThreshold(float linearSleepingThreshold)
public void setAngularSleepingThreshold(float angularSleepingThreshold)
public float getLinearSleepingThreshold()
public float getAngularSleepingThreshold()
public float getAngularFactor()
public void setAngularFactor(float factor)
public void addJoint(PhysicsJoint joint)
joint
- the joint to add (not null, alias created)public void removeJoint(PhysicsJoint joint)
joint
- the joint to remove (not null, unaffected)public java.util.List<PhysicsJoint> getJoints()
public com.bulletphysics.dynamics.RigidBody getObjectId()
public void destroy()
public void write(JmeExporter e) throws java.io.IOException
write
in interface Savable
write
in class PhysicsCollisionObject
e
- exporter (not null)java.io.IOException
- from exporterpublic void read(JmeImporter e) throws java.io.IOException
read
in interface Savable
read
in class PhysicsCollisionObject
e
- importer (not null)java.io.IOException
- from importer