public abstract class AbstractPhysicsControl extends java.lang.Object 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 |
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 physics object is (or would be) added
|
protected Spatial |
spatial
spatial to which this control is added, or null if none
|
Constructor and Description |
---|
AbstractPhysicsControl() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addPhysics(PhysicsSpace space)
Add all managed physics objects to the specified space.
|
protected void |
applyPhysicsTransform(Vector3f worldLocation,
Quaternion worldRotation)
Apply a physics transform to the spatial.
|
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.
|
protected abstract void |
createSpatialData(Spatial spat)
Create spatial-dependent data.
|
PhysicsSpace |
getPhysicsSpace()
Access the physics space to which the object is (or would be) added.
|
Spatial |
getSpatial() |
protected Quaternion |
getSpatialRotation()
Access whichever spatial rotation corresponds to the physics rotation.
|
protected Vector3f |
getSpatialTranslation()
Access whichever spatial translation corresponds to the physics location.
|
boolean |
isApplyPhysicsLocal()
Test whether physics-space coordinates should match the spatial's local
coordinates.
|
boolean |
isEnabled()
Test whether this control is enabled.
|
void |
read(JmeImporter im)
De-serialize this control from the specified importer, for example when
loading from a J3O file.
|
protected abstract void |
removePhysics(PhysicsSpace space)
Remove all managed physics objects from the specified space.
|
protected abstract void |
removeSpatialData(Spatial spat)
Destroy spatial-dependent data.
|
void |
render(RenderManager rm,
ViewPort vp)
Should be called prior to queuing the spatial by the RenderManager.
|
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.
|
protected abstract void |
setPhysicsLocation(Vector3f vec)
Translate the physics object to the specified location.
|
protected abstract void |
setPhysicsRotation(Quaternion quat)
Rotate the physics object to the specified orientation.
|
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)
Updates the control.
|
void |
write(JmeExporter ex)
Serialize this object, for example when saving to a J3O file.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
jmeClone
protected Spatial spatial
protected boolean enabled
protected boolean added
protected PhysicsSpace space
protected boolean applyLocal
protected abstract void createSpatialData(Spatial spat)
spat
- the controlled spatial (not null)protected abstract void removeSpatialData(Spatial spat)
spat
- the previously controlled spatial (not null)protected abstract void setPhysicsLocation(Vector3f vec)
vec
- desired location (not null, unaffected)protected abstract void setPhysicsRotation(Quaternion quat)
quat
- desired orientation (not null, unaffected)protected abstract void addPhysics(PhysicsSpace space)
space
- which physics space to add to (not null)protected abstract void removePhysics(PhysicsSpace space)
space
- which physics space to remove from (not null)public boolean isApplyPhysicsLocal()
public void setApplyPhysicsLocal(boolean applyPhysicsLocal)
applyPhysicsLocal
- true→match local coordinates,
false→match world coordinates (default=false)protected Vector3f getSpatialTranslation()
protected Quaternion getSpatialRotation()
protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation)
worldLocation
- location vector (in physics-space coordinates, not
null, unaffected)worldRotation
- orientation (in physics-space coordinates, not null,
unaffected)@Deprecated public Control cloneForSpatial(Spatial spatial)
Control
cloneForSpatial
in interface Control
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()
public void setEnabled(boolean enabled)
When the control is disabled, the physics object is removed from physics space. When the control is enabled again, the physics object is moved to the spatial's location 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 void update(float tpf)
Control
public void render(RenderManager rm, ViewPort vp)
Control
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
public void read(JmeImporter im) throws java.io.IOException