public class RigidBodyControl extends PhysicsRigidBody implements PhysicsControl, JmeCloneable
This class is shared between JBullet and Native Bullet.
Modifier and Type | Field and Description |
---|---|
protected boolean |
added
true→body is added to the physics space, false→not added
|
protected boolean |
enabled
true→control is enabled, false→control is disabled
|
protected boolean |
kinematicSpatial
true→body is kinematic, false→body is static or dynamic
|
protected PhysicsSpace |
space
space to which the body is (or would be) added
|
protected Spatial |
spatial
spatial to which this control is added, or null if none
|
constructionInfo, joints, kinematic, localInertia, mass, motionState, rBody, tempMatrix, tempTrans, tempVec, 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 |
RigidBodyControl()
No-argument constructor needed by SavableClassUtil.
|
|
RigidBodyControl(CollisionShape shape)
Instantiate an enabled control with mass=1 and the specified collision
shape.
|
|
RigidBodyControl(CollisionShape shape,
float mass)
Instantiate an enabled control with the specified collision shape and
mass.
|
|
RigidBodyControl(float mass)
When using this constructor, the CollisionShape for the RigidBody is
generated automatically when the control is added to a spatial.
|
Modifier and Type | Method and Description |
---|---|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Callback from
Cloner to convert this
shallow-cloned control into a deep-cloned one, using the specified cloner
and original to resolve copied fields. |
Control |
cloneForSpatial(Spatial spatial)
Clone this control for a different spatial.
|
protected void |
createCollisionShape()
Set the collision shape based on the controlled spatial and its
descendents.
|
PhysicsSpace |
getPhysicsSpace()
Access the physics space to which the body is (or would be) added.
|
Spatial |
getSpatial() |
boolean |
isApplyPhysicsLocal()
Test whether physics-space coordinates should match the spatial's local
coordinates.
|
boolean |
isEnabled()
Test whether this control is enabled.
|
boolean |
isKinematicSpatial()
Test whether this control is in kinematic mode.
|
java.lang.Object |
jmeClone()
Create a shallow clone for the JME cloner.
|
void |
read(JmeImporter im)
De-serialize this control, for example when loading from a J3O file.
|
void |
render(RenderManager rm,
ViewPort vp)
Render this control.
|
void |
setApplyPhysicsLocal(boolean applyPhysicsLocal)
Alter whether physics-space coordinates should match the spatial's local
coordinates.
|
void |
setEnabled(boolean enabled)
Enable or disable this control.
|
void |
setKinematicSpatial(boolean kinematicSpatial)
Enable or disable kinematic mode.
|
void |
setPhysicsSpace(PhysicsSpace newSpace)
If enabled, add this control's body to the specified physics space.
|
void |
setSpatial(Spatial spatial)
Alter which spatial is controlled.
|
void |
update(float tpf)
Update this control.
|
void |
write(JmeExporter ex)
Serialize this control, for example when saving to a J3O file.
|
activate, addJoint, applyCentralForce, applyForce, applyImpulse, applyTorque, applyTorqueImpulse, clearForces, destroy, getAngularDamping, getAngularFactor, getAngularSleepingThreshold, getAngularVelocity, getAngularVelocity, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getFriction, getGravity, getGravity, getInterpolatedPhysicsLocation, getInterpolatedPhysicsRotation, getJoints, getLinearDamping, getLinearSleepingThreshold, getLinearVelocity, getLinearVelocity, getMass, getMotionState, getObjectId, getPhysicsLocation, getPhysicsLocation, getPhysicsRotation, getPhysicsRotation, getPhysicsRotationMatrix, getPhysicsRotationMatrix, getRestitution, isActive, isContactResponse, isKinematic, postRebuild, preRebuild, rebuildRigidBody, removeJoint, setAngularDamping, setAngularFactor, setAngularSleepingThreshold, setAngularVelocity, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollisionShape, setContactResponse, setDamping, setFriction, setGravity, setKinematic, setLinearDamping, setLinearSleepingThreshold, setLinearVelocity, setMass, setPhysicsLocation, setPhysicsRotation, setPhysicsRotation, setRestitution, setSleepingThresholds
addCollideWithGroup, getCollideWithGroups, getCollisionGroup, getCollisionShape, getUserObject, removeCollideWithGroup, setCollideWithGroups, setCollisionGroup, setUserObject
protected Spatial spatial
protected boolean enabled
protected boolean added
protected PhysicsSpace space
protected boolean kinematicSpatial
protected RigidBodyControl()
public RigidBodyControl(float mass)
mass
- When not 0, a HullCollisionShape is generated, otherwise a
MeshCollisionShape is used. For geometries with box or sphere meshes the
proper box or sphere collision shape is used.public RigidBodyControl(CollisionShape shape)
shape
- the desired shape (not null, alias created)public RigidBodyControl(CollisionShape shape, float mass)
shape
- the desired shape (not null, alias created)mass
- the desired mass (≥0)public Control cloneForSpatial(Spatial spatial)
cloneForSpatial
in interface Control
spatial
- the spatial for the clone to control (or null)public java.lang.Object jmeClone()
jmeClone
in interface JmeCloneable
public void cloneFields(Cloner cloner, java.lang.Object original)
Cloner
to convert this
shallow-cloned control into a deep-cloned one, using the specified cloner
and original to resolve copied fields.cloneFields
in interface JmeCloneable
cloner
- the cloner that's cloning this control (not null)original
- the control from which this control was shallow-cloned
(unused)public void setSpatial(Spatial spatial)
setSpatial
in interface Control
spatial
- the spatial to control (or null)public Spatial getSpatial()
protected void createCollisionShape()
public void setEnabled(boolean enabled)
When the control is disabled, the body is removed from physics space. When the control is enabled again, the body is moved to the current location of the spatial and then added to the physics space.
setEnabled
in interface PhysicsControl
enabled
- true→enable the control, false→disable itpublic boolean isEnabled()
isEnabled
in interface PhysicsControl
public boolean isKinematicSpatial()
public void setKinematicSpatial(boolean kinematicSpatial)
kinematicSpatial
- true→kinematic, false→dynamic or staticpublic boolean isApplyPhysicsLocal()
public void setApplyPhysicsLocal(boolean applyPhysicsLocal)
applyPhysicsLocal
- true→match local coordinates,
false→match world coordinates (default=false)public void update(float tpf)
public void render(RenderManager rm, ViewPort vp)
public void setPhysicsSpace(PhysicsSpace newSpace)
setPhysicsSpace
in interface PhysicsControl
newSpace
- where to add, or null to simply removepublic PhysicsSpace getPhysicsSpace()
getPhysicsSpace
in interface PhysicsControl
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
write
in class PhysicsRigidBody
ex
- exporter (not null)java.io.IOException
- from exporterpublic void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
read
in class PhysicsRigidBody
im
- importer (not null)java.io.IOException
- from importer