com.jme3.renderer
Class RenderManager

java.lang.Object
  extended by com.jme3.renderer.RenderManager

public class RenderManager
extends java.lang.Object

RenderManager is a high-level rendering interface that is above the Renderer implementation. RenderManager takes care of rendering the scene graphs attached to each viewport and handling SceneProcessors.

See Also:
SceneProcessor, ViewPort, Spatial

Constructor Summary
RenderManager(Renderer renderer)
          Create a high-level rendering interface over the low-level rendering interface.
 
Method Summary
 void clearQueue(ViewPort vp)
          Clears the queue of the given ViewPort.
 ViewPort createMainView(java.lang.String viewName, Camera cam)
          Creates a new main ViewPort, to display the given camera's content.
 ViewPort createPostView(java.lang.String viewName, Camera cam)
          Creates a new post ViewPort, to display the given camera's content.
 ViewPort createPreView(java.lang.String viewName, Camera cam)
          Creates a new pre ViewPort, to display the given camera's content.
 void flushQueue(ViewPort vp)
          Flushes the ViewPort's render queue by rendering each of its visible buckets.
 Camera getCurrentCamera()
          Returns the camera currently used for rendering.
 RenderState getForcedRenderState()
          Returns the forced render state previously set with setForcedRenderState(com.jme3.material.RenderState).
 java.lang.String getForcedTechnique()
          Returns the forced technique name set.
 ViewPort getMainView(java.lang.String viewName)
          Returns the main ViewPort with the given name.
 java.util.List<ViewPort> getMainViews()
          Returns a read-only list of all main ViewPorts
 ViewPort getPostView(java.lang.String viewName)
          Returns the post ViewPort with the given name.
 java.util.List<ViewPort> getPostViews()
          Returns a read-only list of all post ViewPorts
 ViewPort getPreView(java.lang.String viewName)
          Returns the pre ViewPort with the given name.
 java.util.List<ViewPort> getPreViews()
          Returns a read-only list of all pre ViewPorts
 Renderer getRenderer()
          The renderer implementation used for rendering operations.
 boolean isHandleTranslucentBucket()
          True if the translucent bucket should automatically be rendered by the RenderManager.
 void notifyReshape(int w, int h)
          Internal use only.
 void preloadScene(Spatial scene)
          Preloads a scene for rendering.
 boolean removeMainView(java.lang.String viewName)
          Removes the main ViewPort with the specified name.
 boolean removeMainView(ViewPort view)
          Removes the specified main ViewPort.
 boolean removePostView(java.lang.String viewName)
          Removes the post ViewPort with the specified name.
 boolean removePostView(ViewPort view)
          Removes the specified post ViewPort.
 boolean removePreView(ViewPort view)
          Removes the specified pre ViewPort.
 void render(float tpf, boolean mainFrameBufferActive)
          Called by the application to render any ViewPorts added to this RenderManager.
 void renderGeometry(Geometry g)
          Renders the given geometry.
 void renderGeometryList(GeometryList gl)
          Renders the given GeometryList.
 void renderScene(Spatial scene, ViewPort vp)
          Flattens the given scene graph into the ViewPort's RenderQueue, checking for culling as the call goes down the graph recursively.
 void renderTranslucentQueue(ViewPort vp)
          Renders the translucent queue on the viewPort.
 void renderViewPort(ViewPort vp, float tpf)
          Renders the ViewPort.
 void renderViewPortQueues(ViewPort vp, boolean flush)
          Render the given viewport queues.
 void renderViewPortRaw(ViewPort vp)
          Draws the viewport but without notifying scene processors of any rendering events.
 void setAlphaToCoverage(boolean value)
          Enable or disable alpha-to-coverage.
 void setCamera(Camera cam, boolean ortho)
          Set the camera to use for rendering.
 void setForcedMaterial(Material mat)
          Set the material to use to render all future objects.
 void setForcedRenderState(RenderState forcedRenderState)
          Set the render state to use for all future objects.
 void setForcedTechnique(java.lang.String forcedTechnique)
          Sets the forced technique to use when rendering geometries.
 void setHandleTranslucentBucket(boolean handleTranslucentBucket)
          Enable or disable rendering of the translucent bucket by the RenderManager.
 void setTimer(Timer timer)
          Set the timer that should be used to query the time based UniformBindings for material world parameters.
 void setWorldMatrix(Matrix4f mat)
          Internal use only.
 void updateUniformBindings(java.util.List<Uniform> params)
          Internal use only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderManager

public RenderManager(Renderer renderer)
Create a high-level rendering interface over the low-level rendering interface.

Parameters:
renderer -
Method Detail

getPreView

public ViewPort getPreView(java.lang.String viewName)
Returns the pre ViewPort with the given name.

Parameters:
viewName - The name of the pre ViewPort to look up
Returns:
The ViewPort, or null if not found.
See Also:
createPreView(java.lang.String, com.jme3.renderer.Camera)

removePreView

public boolean removePreView(ViewPort view)
Removes the specified pre ViewPort.

Parameters:
view - The pre ViewPort to remove
Returns:
True if the ViewPort was removed successfully.
See Also:
createPreView(java.lang.String, com.jme3.renderer.Camera)

getMainView

public ViewPort getMainView(java.lang.String viewName)
Returns the main ViewPort with the given name.

Parameters:
viewName - The name of the main ViewPort to look up
Returns:
The ViewPort, or null if not found.
See Also:
createMainView(java.lang.String, com.jme3.renderer.Camera)

removeMainView

public boolean removeMainView(java.lang.String viewName)
Removes the main ViewPort with the specified name.

Parameters:
viewName - The main ViewPort name to remove
Returns:
True if the ViewPort was removed successfully.
See Also:
createMainView(java.lang.String, com.jme3.renderer.Camera)

removeMainView

public boolean removeMainView(ViewPort view)
Removes the specified main ViewPort.

Parameters:
view - The main ViewPort to remove
Returns:
True if the ViewPort was removed successfully.
See Also:
createMainView(java.lang.String, com.jme3.renderer.Camera)

getPostView

public ViewPort getPostView(java.lang.String viewName)
Returns the post ViewPort with the given name.

Parameters:
viewName - The name of the post ViewPort to look up
Returns:
The ViewPort, or null if not found.
See Also:
createPostView(java.lang.String, com.jme3.renderer.Camera)

removePostView

public boolean removePostView(java.lang.String viewName)
Removes the post ViewPort with the specified name.

Parameters:
viewName - The post ViewPort name to remove
Returns:
True if the ViewPort was removed successfully.
See Also:
createPostView(java.lang.String, com.jme3.renderer.Camera)

removePostView

public boolean removePostView(ViewPort view)
Removes the specified post ViewPort.

Parameters:
view - The post ViewPort to remove
Returns:
True if the ViewPort was removed successfully.
See Also:
createPostView(java.lang.String, com.jme3.renderer.Camera)

getPreViews

public java.util.List<ViewPort> getPreViews()
Returns a read-only list of all pre ViewPorts

Returns:
a read-only list of all pre ViewPorts
See Also:
createPreView(java.lang.String, com.jme3.renderer.Camera)

getMainViews

public java.util.List<ViewPort> getMainViews()
Returns a read-only list of all main ViewPorts

Returns:
a read-only list of all main ViewPorts
See Also:
createMainView(java.lang.String, com.jme3.renderer.Camera)

getPostViews

public java.util.List<ViewPort> getPostViews()
Returns a read-only list of all post ViewPorts

Returns:
a read-only list of all post ViewPorts
See Also:
createPostView(java.lang.String, com.jme3.renderer.Camera)

createPreView

public ViewPort createPreView(java.lang.String viewName,
                              Camera cam)
Creates a new pre ViewPort, to display the given camera's content.

The view will be processed before the main and post viewports.


createMainView

public ViewPort createMainView(java.lang.String viewName,
                               Camera cam)
Creates a new main ViewPort, to display the given camera's content.

The view will be processed before the post viewports but after the pre viewports.


createPostView

public ViewPort createPostView(java.lang.String viewName,
                               Camera cam)
Creates a new post ViewPort, to display the given camera's content.

The view will be processed after the pre and main viewports.


notifyReshape

public void notifyReshape(int w,
                          int h)
Internal use only. Updates the resolution of all on-screen cameras to match the given width and height.


setForcedMaterial

public void setForcedMaterial(Material mat)
Set the material to use to render all future objects. This overrides the material set on the geometry and renders with the provided material instead. Use null to clear the material and return renderer to normal functionality.

Parameters:
mat - The forced material to set, or null to return to normal

getForcedRenderState

public RenderState getForcedRenderState()
Returns the forced render state previously set with setForcedRenderState(com.jme3.material.RenderState).

Returns:
the forced render state

setForcedRenderState

public void setForcedRenderState(RenderState forcedRenderState)
Set the render state to use for all future objects. This overrides the render state set on the material and instead forces this render state to be applied for all future materials rendered. Set to null to return to normal functionality.

Parameters:
forcedRenderState - The forced render state to set, or null to return to normal

setTimer

public void setTimer(Timer timer)
Set the timer that should be used to query the time based UniformBindings for material world parameters.

Parameters:
timer - The timer to query time world parameters

getForcedTechnique

public java.lang.String getForcedTechnique()
Returns the forced technique name set.

Returns:
the forced technique name set.
See Also:
setForcedTechnique(java.lang.String)

setForcedTechnique

public void setForcedTechnique(java.lang.String forcedTechnique)
Sets the forced technique to use when rendering geometries.

If the specified technique name is available on the geometry's material, then it is used, otherwise, the forced material is used. If a forced material is not set and the forced technique name cannot be found on the material, the geometry will not be rendered.

Parameters:
forcedTechnique - The forced technique name to use, set to null to return to normal functionality.
See Also:
renderGeometry(com.jme3.scene.Geometry)

setAlphaToCoverage

public void setAlphaToCoverage(boolean value)
Enable or disable alpha-to-coverage.

When alpha to coverage is enabled and the renderer implementation supports it, then alpha blending will be replaced with alpha dissolve if multi-sampling is also set on the renderer. This feature allows avoiding of alpha blending artifacts due to lack of triangle-level back-to-front sorting.

Parameters:
value - True to enable alpha-to-coverage, false otherwise.

isHandleTranslucentBucket

public boolean isHandleTranslucentBucket()
True if the translucent bucket should automatically be rendered by the RenderManager.

Returns:
Whether or not the translucent bucket is rendered.
See Also:
setHandleTranslucentBucket(boolean)

setHandleTranslucentBucket

public void setHandleTranslucentBucket(boolean handleTranslucentBucket)
Enable or disable rendering of the translucent bucket by the RenderManager. The default is enabled.

Parameters:
handleTranslucentBucket - Whether or not the translucent bucket should be rendered.

setWorldMatrix

public void setWorldMatrix(Matrix4f mat)
Internal use only. Sets the world matrix to use for future rendering. This has no effect unless objects are rendered manually using Material.render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager). Using renderGeometry(com.jme3.scene.Geometry) will override this value.

Parameters:
mat - The world matrix to set

updateUniformBindings

public void updateUniformBindings(java.util.List<Uniform> params)
Internal use only. Updates the given list of uniforms with uniform bindings based on the current world state.


renderGeometry

public void renderGeometry(Geometry g)
Renders the given geometry.

First the proper world matrix is set, if the geometry's ignore transform feature is enabled, the identity world matrix is used, otherwise, the geometry's world transform matrix is used.

Once the world matrix is applied, the proper material is chosen for rendering. If a forced material is set on this RenderManager, then it is used for rendering the geometry, otherwise, the geometry's material is used.

If a forced technique is set on this RenderManager, then it is selected automatically on the geometry's material and is used for rendering. Otherwise, one of the default techniques is used.

If a forced render state is set on this RenderManager, then it is used for rendering the material, and the material's own render state is ignored. Otherwise, the material's render state is used as intended.

Parameters:
g - The geometry to render
See Also:
Technique, RenderState, Material.selectTechnique(java.lang.String, com.jme3.renderer.RenderManager), Material.render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager)

renderGeometryList

public void renderGeometryList(GeometryList gl)
Renders the given GeometryList.

For every geometry in the list, the renderGeometry(com.jme3.scene.Geometry) method is called.

Parameters:
gl - The geometry list to render.
See Also:
GeometryList, renderGeometry(com.jme3.scene.Geometry)

preloadScene

public void preloadScene(Spatial scene)
Preloads a scene for rendering.

After invocation of this method, the underlying renderer would have uploaded any textures, shaders and meshes used by the given scene to the video driver. Using this method is useful when wishing to avoid the initial pause when rendering a scene for the first time. Note that it is not guaranteed that the underlying renderer will actually choose to upload the data to the GPU so some pause is still to be expected.

Parameters:
scene - The scene to preload

renderScene

public void renderScene(Spatial scene,
                        ViewPort vp)
Flattens the given scene graph into the ViewPort's RenderQueue, checking for culling as the call goes down the graph recursively.

First, the scene is checked for culling based on the Spatials cull hint, if the camera frustum contains the scene, then this method is recursively called on its children.

When the scene's leaves or geometries are reached, they are each enqueued into the ViewPort's render queue.

In addition to enqueuing the visible geometries, this method also scenes which cast or receive shadows, by putting them into the RenderQueue's shadow queue. Each Spatial which has its shadow mode set to not off, will be put into the appropriate shadow queue, note that this process does not check for frustum culling on any shadow casters, as they don't have to be in the eye camera frustum to cast shadows on objects that are inside it.

Parameters:
scene - The scene to flatten into the queue
vp - The ViewPort provides the camera used for culling and the queue used to contain the flattened scene graph.

getCurrentCamera

public Camera getCurrentCamera()
Returns the camera currently used for rendering.

The camera can be set with setCamera(com.jme3.renderer.Camera, boolean).

Returns:
the camera currently used for rendering.

getRenderer

public Renderer getRenderer()
The renderer implementation used for rendering operations.

Returns:
The renderer implementation
See Also:
RenderManager(com.jme3.renderer.Renderer), Renderer

flushQueue

public void flushQueue(ViewPort vp)
Flushes the ViewPort's render queue by rendering each of its visible buckets. By default the queues will automatically be cleared after rendering, so there's no need to clear them manually.

Parameters:
vp - The ViewPort of which the queue will be flushed
See Also:
RenderQueue.renderQueue(com.jme3.renderer.queue.RenderQueue.Bucket, com.jme3.renderer.RenderManager, com.jme3.renderer.Camera), renderGeometryList(com.jme3.renderer.queue.GeometryList)

clearQueue

public void clearQueue(ViewPort vp)
Clears the queue of the given ViewPort. Simply calls RenderQueue.clear() on the ViewPort's render queue.

Parameters:
vp - The ViewPort of which the queue will be cleared.
See Also:
RenderQueue.clear(), ViewPort.getQueue()

renderViewPortQueues

public void renderViewPortQueues(ViewPort vp,
                                 boolean flush)
Render the given viewport queues.

Changes the depth range appropriately as expected by each queue and then calls RenderQueue.renderQueue(com.jme3.renderer.queue.RenderQueue.Bucket, com.jme3.renderer.RenderManager, com.jme3.renderer.Camera, boolean) on the queue. Makes sure to restore the depth range to [0, 1] at the end of the call. Note that the translucent bucket is NOT rendered by this method. Instead the user should call renderTranslucentQueue(com.jme3.renderer.ViewPort) after this call.

Parameters:
vp - the viewport of which queue should be rendered
flush - If true, the queues will be cleared after rendering.
See Also:
RenderQueue, renderTranslucentQueue(com.jme3.renderer.ViewPort)

renderTranslucentQueue

public void renderTranslucentQueue(ViewPort vp)
Renders the translucent queue on the viewPort.

This call does nothing unless setHandleTranslucentBucket(boolean) is set to true. This method clears the translucent queue after rendering it.

Parameters:
vp - The viewport of which the translucent queue should be rendered.
See Also:
renderViewPortQueues(com.jme3.renderer.ViewPort, boolean), setHandleTranslucentBucket(boolean)

setCamera

public void setCamera(Camera cam,
                      boolean ortho)
Set the camera to use for rendering.

First, the camera's view port parameters are applied. Then, the camera's view and projection matrices are set on the renderer. If ortho is true, then instead of using the camera's view and projection matrices, an ortho matrix is computed and used instead of the view projection matrix. The ortho matrix converts from the range (0 ~ Width, 0 ~ Height, -1 ~ +1) to the clip range (-1 ~ +1, -1 ~ +1, -1 ~ +1).

Parameters:
cam - The camera to set
ortho - True if to use orthographic projection (for GUI rendering), false if to use the camera's view and projection matrices.

renderViewPortRaw

public void renderViewPortRaw(ViewPort vp)
Draws the viewport but without notifying scene processors of any rendering events.

Parameters:
vp - The ViewPort to render
See Also:
renderViewPort(com.jme3.renderer.ViewPort, float)

renderViewPort

public void renderViewPort(ViewPort vp,
                           float tpf)
Renders the ViewPort.

If the ViewPort is disabled, this method returns immediately. Otherwise, the ViewPort is rendered by the following process:

Parameters:
vp -
tpf -

render

public void render(float tpf,
                   boolean mainFrameBufferActive)
Called by the application to render any ViewPorts added to this RenderManager.

Renders any viewports that were added using the following methods:

Parameters:
tpf - Time per frame value