public abstract class SimpleAppState extends java.lang.Object implements com.jme3.app.state.AppState, IRenderQueue
Constructor and Description |
---|
SimpleAppState()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup() |
com.jme3.material.Material |
createBasicMaterial(com.jme3.math.ColorRGBA color)
Generates a new, basic
Material for use in the jME3
app . |
com.jme3.material.Material |
createLitMaterial(com.jme3.math.ColorRGBA color)
Generates a new, basic
Material for use in the jME3
app . |
void |
disableControls()
This method disables the controls for the
SimpleAppState . |
void |
enableControls()
This method enables the controls for the
SimpleAppState . |
<T> java.util.concurrent.Future<T> |
enqueue(java.util.concurrent.Callable<T> callable)
Queues a rendering task for the underlying
Application . |
com.jme3.app.Application |
getApplication()
Gets the current jME
Application to which this
AppState is attached. |
com.jme3.collision.CollisionResults |
getCollision(com.jme3.collision.Collidable collidable,
com.jme3.math.Ray ray)
Gets a
CollisionResults between a Collidable and a
Ray . |
com.jme3.math.Ray |
getCrosshairRay(com.jme3.renderer.Camera cam)
Gets a Ray from the crosshair's location to the grid.
|
com.jme3.math.Ray |
getCursorRay(com.jme3.renderer.Camera cam)
Gets a Ray from the camera to the cursor.
|
com.jme3.math.Ray |
getCursorRayFromClick(EmbeddedView view)
Gets a Ray from the camera to the cursor.
|
com.jme3.material.Material |
getMaterial(java.lang.String name)
Gets a
Material that was previously created and associated
with the specified name. |
void |
initialize(com.jme3.app.state.AppStateManager stateManager,
com.jme3.app.Application app) |
boolean |
isEnabled() |
boolean |
isInitialized() |
void |
postRender() |
void |
printCollisionResults(com.jme3.collision.CollisionResults results)
Prints out a CollisionResults Collection for debugging/diagnosis.
|
com.jme3.material.Material |
removeMaterial(java.lang.String name)
Removes a
Material from the view. |
void |
render(com.jme3.renderer.RenderManager rm) |
void |
setEnabled(boolean active) |
void |
setMaterial(java.lang.String name,
com.jme3.material.Material material)
Associates a
Material with a name or key for re-use later. |
void |
start(com.jme3.app.Application app)
Starts the
SimpleAppState by attaching it to the specified
Application . |
void |
stateAttached(com.jme3.app.state.AppStateManager arg0) |
void |
stateDetached(com.jme3.app.state.AppStateManager arg0) |
void |
stop()
Stops this
SimpleAppState if it has been initialized. |
abstract void |
update(float tpf) |
public void start(com.jme3.app.Application app)
SimpleAppState
by attaching it to the specified
Application
.app
- The jME Application
that will be hosting this
SimpleAppState
.public void stop()
SimpleAppState
if it has been initialized.public void stateAttached(com.jme3.app.state.AppStateManager arg0)
stateAttached
in interface com.jme3.app.state.AppState
public void initialize(com.jme3.app.state.AppStateManager stateManager, com.jme3.app.Application app)
initialize
in interface com.jme3.app.state.AppState
public boolean isInitialized()
isInitialized
in interface com.jme3.app.state.AppState
public void render(com.jme3.renderer.RenderManager rm)
render
in interface com.jme3.app.state.AppState
public abstract void update(float tpf)
update
in interface com.jme3.app.state.AppState
public void postRender()
postRender
in interface com.jme3.app.state.AppState
public boolean isEnabled()
isEnabled
in interface com.jme3.app.state.AppState
public final void setEnabled(boolean active)
setEnabled
in interface com.jme3.app.state.AppState
public final void cleanup()
cleanup
in interface com.jme3.app.state.AppState
public void stateDetached(com.jme3.app.state.AppStateManager arg0)
stateDetached
in interface com.jme3.app.state.AppState
public <T> java.util.concurrent.Future<T> enqueue(java.util.concurrent.Callable<T> callable)
Application
. This task
will be performed on the app's rendering thread. This should be used when
the SimpleAppState
or a related class needs to render
something.enqueue
in interface IRenderQueue
callable
- The operation to execute on the associated rendering thread.Callable
is null or otherwise cannot be executed.public com.jme3.app.Application getApplication()
Application
to which this
AppState
is attached.app
. This will be null if the
SimpleAppState
has not been started.public void enableControls()
SimpleAppState
.
This method is used to prevent controls from being registered with the
jME app
's InputManager
more than once. The code for
registering the controls should be implemented in
registerControls()
.
Note: This method should not normally be overridden. However, if
overridden, the first call in the sub-class' method should
be super.enableControls();
public void disableControls()
SimpleAppState
.
This method is used to prevent controls from being unregistered from the
jME app
's InputManager
more than once. The code for
unregistering the controls should be implemented in
unregisterControls()
.
public com.jme3.material.Material getMaterial(java.lang.String name)
Material
that was previously created and associated
with the specified name.name
- The name or key of the material.Material
, or null if none could be
found.setMaterial(String, Material)
public void setMaterial(java.lang.String name, com.jme3.material.Material material)
Material
with a name or key for re-use later.
Null keys are accepted but not recommended.name
- The name or key of the Material
material
- The Material
to store for later re-use.getMaterial(String)
,
removeMaterial(String)
public com.jme3.material.Material removeMaterial(java.lang.String name)
Material
from the view. This should be called if
the Material
will not be re-used again.name
- The name or key associated with the Material
.Material
that was removed. This is null if the
key is invalid.getMaterial(String)
,
setMaterial(String, Material)
public com.jme3.material.Material createBasicMaterial(com.jme3.math.ColorRGBA color)
Material
for use in the jME3
app
.color
- The color of the material.SimpleAppState
is not initialized.public com.jme3.material.Material createLitMaterial(com.jme3.math.ColorRGBA color)
Material
for use in the jME3
app
.color
- The color of the material.SimpleAppState
is not initialized.public com.jme3.collision.CollisionResults getCollision(com.jme3.collision.Collidable collidable, com.jme3.math.Ray ray)
CollisionResults
between a Collidable
and a
Ray
. Collidables like Spatials and Nodes can be tested for
collisions with Rays, which can be acquired via
getCrosshairRay(Camera)
and getCursorRay(Camera)
.collidable
- The object we are trying to hit.ray
- A ray that is being cast at the collidable.public com.jme3.math.Ray getCrosshairRay(com.jme3.renderer.Camera cam)
public com.jme3.math.Ray getCursorRay(com.jme3.renderer.Camera cam)
Use this method when getting the cursor's location after a mouse-move
event. For mouse-click events, use
getCursorRayFromClick(EmbeddedView)
.
public com.jme3.math.Ray getCursorRayFromClick(EmbeddedView view)
During click events, jME3 calculates the 2D cursor position as
Y-decreasing from top to bottom. Use this method when getting the
cursor's location after a mouse-click event. For mouse-move events, use
getCursorRay(Camera)
.
public void printCollisionResults(com.jme3.collision.CollisionResults results)
results
- A CollisionResults Collection to print out.