public class GhostControl extends PhysicsGhostObject implements PhysicsControl, JmeCloneable
The ghost object moves with the spatial it is attached to and can be used to detect overlaps with other physics objects (e.g. aggro radius).
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 |
applyLocal
true → physics coordinates match local transform, false →
physics coordinates match world transform
|
protected boolean |
enabled
true→control is enabled, false→control is disabled
|
protected PhysicsSpace |
space
space to which the ghost object is (or would be) added
|
protected Spatial |
spatial
spatial to which this control is added, or null if none
|
gObject, locationDirty, tempRot, tempTrans, tmp_inverseWorldRotationCOLLISION_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 |
GhostControl()
No-argument constructor needed by SavableClassUtil.
|
|
GhostControl(CollisionShape shape)
Instantiate an enabled control with the specified shape.
|
| 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)
Deprecated.
|
PhysicsSpace |
getPhysicsSpace()
Access the physics space to which the ghost object 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.
|
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 |
setPhysicsSpace(PhysicsSpace newSpace)
If enabled, add this control's physics object 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.
|
buildObject, destroy, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getObjectId, getOverlapping, getOverlappingCount, getOverlappingObjects, getPhysicsLocation, getPhysicsLocation, getPhysicsRotation, getPhysicsRotation, getPhysicsRotationMatrix, getPhysicsRotationMatrix, getPhysicsTransform, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollisionShape, setPhysicsLocation, setPhysicsRotation, setPhysicsRotationaddCollideWithGroup, getCollideWithGroups, getCollisionGroup, getCollisionShape, getUserObject, removeCollideWithGroup, setCollideWithGroups, setCollisionGroup, setUserObjectprotected Spatial spatial
protected boolean enabled
protected boolean added
protected PhysicsSpace space
protected boolean applyLocal
protected GhostControl()
public GhostControl(CollisionShape shape)
shape - (not null)public boolean isApplyPhysicsLocal()
public void setApplyPhysicsLocal(boolean applyPhysicsLocal)
applyPhysicsLocal - true→match local coordinates,
false→match world coordinates (default=false)@Deprecated public Control cloneForSpatial(Spatial spatial)
cloneForSpatial in interface Controlspatial - the spatial for the clone to control (or null)public java.lang.Object jmeClone()
jmeClone in interface JmeCloneablepublic 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 JmeCloneablecloner - 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 Controlspatial - the spatial to control (or null)public Spatial getSpatial()
public void setEnabled(boolean enabled)
When the control is disabled, the ghost object is removed from physics space. When the control is enabled again, the object is moved to the current location of the spatial and then added to the physics space.
setEnabled in interface PhysicsControlenabled - true→enable the control, false→disable itpublic boolean isEnabled()
isEnabled in interface PhysicsControlpublic void update(float tpf)
public void render(RenderManager rm, ViewPort vp)
public void setPhysicsSpace(PhysicsSpace newSpace)
setPhysicsSpace in interface PhysicsControlnewSpace - where to add, or null to simply removepublic PhysicsSpace getPhysicsSpace()
getPhysicsSpace in interface PhysicsControlpublic void write(JmeExporter ex) throws java.io.IOException
write in interface Savablewrite in class PhysicsGhostObjectex - exporter (not null)java.io.IOException - from exporterpublic void read(JmeImporter im) throws java.io.IOException
read in interface Savableread in class PhysicsGhostObjectim - importer (not null)java.io.IOException - from importer