com.jme3.bullet
Class BulletAppState

java.lang.Object
  extended by com.jme3.bullet.BulletAppState
All Implemented Interfaces:
AppState, PhysicsTickListener

public class BulletAppState
extends java.lang.Object
implements AppState, PhysicsTickListener

BulletAppState allows using bullet physics in an Application.


Nested Class Summary
static class BulletAppState.ThreadingType
           
 
Field Summary
protected  boolean active
           
protected  Application app
           
protected  PhysicsSpace.BroadphaseType broadphaseType
           
protected  java.util.concurrent.ScheduledThreadPoolExecutor executor
           
protected  boolean initialized
           
protected  java.util.concurrent.Future physicsFuture
           
protected  PhysicsSpace pSpace
           
protected  AppStateManager stateManager
           
protected  BulletAppState.ThreadingType threadingType
           
protected  float tpf
           
protected  Vector3f worldMax
           
protected  Vector3f worldMin
           
 
Constructor Summary
BulletAppState()
          Creates a new BulletAppState running a PhysicsSpace for physics simulation, use getStateManager().addState(bulletAppState) to enable physics for an Application.
BulletAppState(PhysicsSpace.BroadphaseType broadphaseType)
          Creates a new BulletAppState running a PhysicsSpace for physics simulation, use getStateManager().addState(bulletAppState) to enable physics for an Application.
BulletAppState(Vector3f worldMin, Vector3f worldMax)
          Creates a new BulletAppState running a PhysicsSpace for physics simulation, use getStateManager().addState(bulletAppState) to enable physics for an Application.
BulletAppState(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType)
           
 
Method Summary
 void cleanup()
          Cleanup the game state.
 PhysicsSpace getPhysicsSpace()
           
 float getSpeed()
           
 BulletAppState.ThreadingType getThreadingType()
           
 void initialize(AppStateManager stateManager, Application app)
          Called to initialize the AppState.
 boolean isEnabled()
           
 boolean isInitialized()
           
 void physicsTick(PhysicsSpace space, float f)
          Called after the physics has been stepped, use to check for forces etc.
 void postRender()
          Called after all rendering commands are flushed.
 void prePhysicsTick(PhysicsSpace space, float f)
          Called before the physics is actually stepped, use to apply forces etc.
 void render(RenderManager rm)
          Render the state.
 void setBroadphaseType(PhysicsSpace.BroadphaseType broadphaseType)
          Use before attaching state
 void setEnabled(boolean enabled)
          Enable or disable the functionality of the AppState.
 void setSpeed(float speed)
           
 void setThreadingType(BulletAppState.ThreadingType threadingType)
          Use before attaching state
 void setWorldMax(Vector3f worldMax)
          Use before attaching state
 void setWorldMin(Vector3f worldMin)
          Use before attaching state
 void startPhysics()
          The physics system is started automatically on attaching, if you want to start it before for some reason, you can use this method.
 void stateAttached(AppStateManager stateManager)
          Called when the state was attached.
 void stateDetached(AppStateManager stateManager)
          Called when the state was detached.
 void update(float tpf)
          Called to update the state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialized

protected boolean initialized

app

protected Application app

stateManager

protected AppStateManager stateManager

executor

protected java.util.concurrent.ScheduledThreadPoolExecutor executor

pSpace

protected PhysicsSpace pSpace

threadingType

protected BulletAppState.ThreadingType threadingType

broadphaseType

protected PhysicsSpace.BroadphaseType broadphaseType

worldMin

protected Vector3f worldMin

worldMax

protected Vector3f worldMax

active

protected boolean active

tpf

protected float tpf

physicsFuture

protected java.util.concurrent.Future physicsFuture
Constructor Detail

BulletAppState

public BulletAppState()
Creates a new BulletAppState running a PhysicsSpace for physics simulation, use getStateManager().addState(bulletAppState) to enable physics for an Application.


BulletAppState

public BulletAppState(PhysicsSpace.BroadphaseType broadphaseType)
Creates a new BulletAppState running a PhysicsSpace for physics simulation, use getStateManager().addState(bulletAppState) to enable physics for an Application.

Parameters:
broadphaseType - The type of broadphase collision detection, BroadphaseType.DVBT is the default

BulletAppState

public BulletAppState(Vector3f worldMin,
                      Vector3f worldMax)
Creates a new BulletAppState running a PhysicsSpace for physics simulation, use getStateManager().addState(bulletAppState) to enable physics for an Application. An AxisSweep broadphase is used.

Parameters:
worldMin - The minimum world extent
worldMax - The maximum world extent

BulletAppState

public BulletAppState(Vector3f worldMin,
                      Vector3f worldMax,
                      PhysicsSpace.BroadphaseType broadphaseType)
Method Detail

getPhysicsSpace

public PhysicsSpace getPhysicsSpace()

startPhysics

public void startPhysics()
The physics system is started automatically on attaching, if you want to start it before for some reason, you can use this method.


initialize

public void initialize(AppStateManager stateManager,
                       Application app)
Description copied from interface: AppState
Called to initialize the AppState.

Specified by:
initialize in interface AppState
Parameters:
stateManager - The state manager

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface AppState
Returns:
True if initialize() was called on the state, false otherwise.

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: AppState
Enable or disable the functionality of the AppState. The effect of this call depends on implementation. An AppState starts as being enabled by default.

Specified by:
setEnabled in interface AppState
Parameters:
enabled - activate the AppState or not.

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface AppState
Returns:
True if the AppState is enabled, false otherwise.
See Also:
AppState.setEnabled(boolean)

stateAttached

public void stateAttached(AppStateManager stateManager)
Description copied from interface: AppState
Called when the state was attached.

Specified by:
stateAttached in interface AppState
Parameters:
stateManager - State manager to which the state was attached to.

stateDetached

public void stateDetached(AppStateManager stateManager)
Description copied from interface: AppState
Called when the state was detached.

Specified by:
stateDetached in interface AppState
Parameters:
stateManager - The state manager from which the state was detached from.

update

public void update(float tpf)
Description copied from interface: AppState
Called to update the state.

Specified by:
update in interface AppState
Parameters:
tpf - Time per frame.

render

public void render(RenderManager rm)
Description copied from interface: AppState
Render the state.

Specified by:
render in interface AppState
Parameters:
rm - RenderManager

postRender

public void postRender()
Description copied from interface: AppState
Called after all rendering commands are flushed.

Specified by:
postRender in interface AppState

cleanup

public void cleanup()
Description copied from interface: AppState
Cleanup the game state.

Specified by:
cleanup in interface AppState

getThreadingType

public BulletAppState.ThreadingType getThreadingType()
Returns:
the threadingType

setThreadingType

public void setThreadingType(BulletAppState.ThreadingType threadingType)
Use before attaching state

Parameters:
threadingType - the threadingType to set

setBroadphaseType

public void setBroadphaseType(PhysicsSpace.BroadphaseType broadphaseType)
Use before attaching state


setWorldMin

public void setWorldMin(Vector3f worldMin)
Use before attaching state


setWorldMax

public void setWorldMax(Vector3f worldMax)
Use before attaching state


getSpeed

public float getSpeed()

setSpeed

public void setSpeed(float speed)

prePhysicsTick

public void prePhysicsTick(PhysicsSpace space,
                           float f)
Description copied from interface: PhysicsTickListener
Called before the physics is actually stepped, use to apply forces etc.

Specified by:
prePhysicsTick in interface PhysicsTickListener
Parameters:
space - the physics space
f - the time per frame in seconds

physicsTick

public void physicsTick(PhysicsSpace space,
                        float f)
Description copied from interface: PhysicsTickListener
Called after the physics has been stepped, use to check for forces etc.

Specified by:
physicsTick in interface PhysicsTickListener
Parameters:
space - the physics space
f - the time per frame in seconds