public class VehicleControl extends PhysicsVehicle implements PhysicsControl, JmeCloneable
This class is shared between JBullet and Native Bullet.
Modifier and Type | Field and Description |
---|---|
protected boolean |
added
true→vehicle is added to the physics space, false→not added
|
protected boolean |
enabled
true→control is enabled, false→control is disabled
|
protected PhysicsSpace |
space
space to which the vehicle is (or would be) added
|
protected Spatial |
spatial
spatial to which this control is added, or null if none
|
physicsSpace, rayCaster, tuning, vehicle, wheels
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 |
VehicleControl()
No-argument constructor needed by SavableClassUtil.
|
|
VehicleControl(CollisionShape shape)
Instantiate an enabled control with mass=1 and the specified collision
shape.
|
|
VehicleControl(CollisionShape shape,
float mass)
Instantiate an enabled with the specified collision shape and mass.
|
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.
|
PhysicsSpace |
getPhysicsSpace()
Access the physics space to which the vehicle is (or would be) added.
|
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.
|
accelerate, accelerate, addWheel, addWheel, applyWheelTransforms, brake, brake, createVehicle, destroy, getCurrentVehicleSpeedKmHour, getForwardVector, getFrictionSlip, getMaxSuspensionForce, getMaxSuspensionTravelCm, getNumWheels, getSuspensionCompression, getSuspensionDamping, getSuspensionStiffness, getVehicleId, getWheel, postRebuild, removeWheel, resetSuspension, setFrictionSlip, setFrictionSlip, setMaxSuspensionForce, setMaxSuspensionForce, setMaxSuspensionTravelCm, setMaxSuspensionTravelCm, setRollInfluence, setSuspensionCompression, setSuspensionCompression, setSuspensionDamping, setSuspensionDamping, setSuspensionStiffness, setSuspensionStiffness, steer, steer, updateWheels
activate, addJoint, applyCentralForce, applyForce, applyImpulse, applyTorque, applyTorqueImpulse, clearForces, 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, 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 PhysicsSpace space
protected boolean added
protected VehicleControl()
public VehicleControl(CollisionShape shape)
shape
- the desired shape (not null, alias created)public VehicleControl(CollisionShape shape, float mass)
shape
- the desired shape (not null, alias created)mass
- (>0)public boolean isApplyPhysicsLocal()
public void setApplyPhysicsLocal(boolean applyPhysicsLocal)
applyPhysicsLocal
- true→match local coordinates,
false→match world coordinates (default=false)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
- spatial to control (or null)public void setEnabled(boolean enabled)
When the control is disabled, the vehicle 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)
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 PhysicsVehicle
ex
- exporter (not null)java.io.IOException
- from exporterpublic void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
read
in class PhysicsVehicle
im
- importer (not null)java.io.IOException
- from importer