public class RenderManager
extends java.lang.Object
SceneProcessor
,
ViewPort
,
Spatial
Constructor and Description |
---|
RenderManager(Renderer renderer)
Creates a high-level rendering interface over the
low-level rendering interface.
|
Modifier and Type | Method and Description |
---|---|
void |
addForcedMatParam(MatParamOverride override)
Adds a forced material parameter to use when rendering geometries.
|
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.
|
SafeArrayList<MatParamOverride> |
getForcedMatParams()
Gets the forced material parameters applied to rendered geometries.
|
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.
|
LightFilter |
getLightFilter()
Returns the current LightFilter.
|
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.
|
TechniqueDef.LightMode |
getPreferredLightMode()
Returns the preferred light mode.
|
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.
|
int |
getSinglePassLightBatchSize()
Returns the number of lights used for each pass when the light mode is single pass.
|
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.
|
void |
removeForcedMatParam(MatParamOverride override)
Removes a forced material parameter previously added.
|
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(java.lang.String viewName)
Removes the pre ViewPort with the specified name.
|
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 geom)
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)
Renders the given viewport queues.
|
void |
renderViewPortRaw(ViewPort vp)
Draws the viewport but without notifying
scene
processors of any rendering events. |
void |
setAlphaToCoverage(boolean value)
Enables or disables alpha-to-coverage.
|
void |
setAppProfiler(AppProfiler prof)
Sets an AppProfiler hook that will be called back for
specific steps within a single update frame.
|
void |
setCamera(Camera cam,
boolean ortho)
Sets the camera to use for rendering.
|
void |
setForcedMaterial(Material mat)
Sets the material to use to render all future objects.
|
void |
setForcedRenderState(RenderState forcedRenderState)
Sets 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)
Enables or disables rendering of the
translucent bucket
by the RenderManager. |
void |
setLightFilter(LightFilter lightFilter)
Sets the light filter to use when rendering lit Geometries.
|
void |
setPreferredLightMode(TechniqueDef.LightMode preferredLightMode)
Defines what light mode will be selected when a technique offers several light modes.
|
void |
setSinglePassLightBatchSize(int singlePassLightBatchSize)
Sets the number of lights to use for each pass when the light mode is single pass.
|
void |
setTimer(Timer timer)
Sets the timer that should be used to query the time based
UniformBinding s for material world parameters. |
void |
setWorldMatrix(Matrix4f mat)
Internal use only.
|
void |
updateUniformBindings(Shader shader)
Internal use only.
|
public RenderManager(Renderer renderer)
renderer
- (alias created)public ViewPort getPreView(java.lang.String viewName)
viewName
- The name of the pre ViewPort to look upcreatePreView(java.lang.String, com.jme3.renderer.Camera)
public boolean removePreView(java.lang.String viewName)
viewName
- The name of the pre ViewPort to removecreatePreView(java.lang.String, com.jme3.renderer.Camera)
public boolean removePreView(ViewPort view)
view
- The pre ViewPort to removecreatePreView(java.lang.String, com.jme3.renderer.Camera)
public ViewPort getMainView(java.lang.String viewName)
viewName
- The name of the main ViewPort to look upcreateMainView(java.lang.String, com.jme3.renderer.Camera)
public boolean removeMainView(java.lang.String viewName)
viewName
- The main ViewPort name to removecreateMainView(java.lang.String, com.jme3.renderer.Camera)
public boolean removeMainView(ViewPort view)
view
- The main ViewPort to removecreateMainView(java.lang.String, com.jme3.renderer.Camera)
public ViewPort getPostView(java.lang.String viewName)
viewName
- The name of the post ViewPort to look upcreatePostView(java.lang.String, com.jme3.renderer.Camera)
public boolean removePostView(java.lang.String viewName)
viewName
- The post ViewPort name to removecreatePostView(java.lang.String, com.jme3.renderer.Camera)
public boolean removePostView(ViewPort view)
view
- The post ViewPort to removecreatePostView(java.lang.String, com.jme3.renderer.Camera)
public java.util.List<ViewPort> getPreViews()
createPreView(java.lang.String, com.jme3.renderer.Camera)
public java.util.List<ViewPort> getMainViews()
createMainView(java.lang.String, com.jme3.renderer.Camera)
public java.util.List<ViewPort> getPostViews()
createPostView(java.lang.String, com.jme3.renderer.Camera)
public ViewPort createPreView(java.lang.String viewName, Camera cam)
The view will be processed before the main and post viewports.
viewName
- the desired viewport namecam
- the Camera to use for rendering (alias created)public ViewPort createMainView(java.lang.String viewName, Camera cam)
The view will be processed before the post viewports but after the pre viewports.
viewName
- the desired viewport namecam
- the Camera to use for rendering (alias created)public ViewPort createPostView(java.lang.String viewName, Camera cam)
The view will be processed after the pre and main viewports.
viewName
- the desired viewport namecam
- the Camera to use for rendering (alias created)public void notifyReshape(int w, int h)
w
- the new width (in pixels)h
- the new height (in pixels)public void setForcedMaterial(Material mat)
mat
- The forced material to set, or null to return to normalpublic RenderState getForcedRenderState()
setForcedRenderState(com.jme3.material.RenderState)
.public void setForcedRenderState(RenderState forcedRenderState)
forcedRenderState
- The forced render state to set, or null
to return to normalpublic void setTimer(Timer timer)
UniformBinding
s for material world parameters.timer
- The timer to query time world parameterspublic void setAppProfiler(AppProfiler prof)
prof
- the AppProfiler to use (alias created, default=null)public java.lang.String getForcedTechnique()
setForcedTechnique(java.lang.String)
public void setForcedTechnique(java.lang.String forcedTechnique)
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.
forcedTechnique
- The forced technique name to use, set to null
to return to normal functionality.renderGeometry(com.jme3.scene.Geometry)
public void addForcedMatParam(MatParamOverride override)
The provided parameter takes precedence over parameters set on the material or any overrides that exist in the scene graph that have the same name.
override
- The override to addMatParamOverride
,
removeForcedMatParam(com.jme3.material.MatParamOverride)
public void removeForcedMatParam(MatParamOverride override)
override
- The override to remove.addForcedMatParam(com.jme3.material.MatParamOverride)
public SafeArrayList<MatParamOverride> getForcedMatParams()
Forced parameters can be added via
addForcedMatParam(com.jme3.material.MatParamOverride)
or removed
via removeForcedMatParam(com.jme3.material.MatParamOverride)
.
public void setAlphaToCoverage(boolean value)
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.
value
- True to enable alpha-to-coverage, false otherwise.public boolean isHandleTranslucentBucket()
setHandleTranslucentBucket(boolean)
public void setHandleTranslucentBucket(boolean handleTranslucentBucket)
translucent bucket
by the RenderManager. The default is enabled.handleTranslucentBucket
- Whether or not the translucent bucket should
be rendered.public void setWorldMatrix(Matrix4f mat)
Material.render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager)
.
Using renderGeometry(com.jme3.scene.Geometry)
will
override this value.mat
- The world matrix to setpublic void updateUniformBindings(Shader shader)
uniform bindings
based on the current world state.shader
- (not null)public void renderGeometry(Geometry geom)
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.
geom
- The geometry to renderTechnique
,
RenderState
,
Material.selectTechnique(java.lang.String, com.jme3.renderer.RenderManager)
,
Material.render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager)
public void renderGeometryList(GeometryList gl)
For every geometry in the list, the
renderGeometry(com.jme3.scene.Geometry)
method is called.
gl
- The geometry list to render.GeometryList
,
renderGeometry(com.jme3.scene.Geometry)
public void preloadScene(Spatial scene)
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.
scene
- The scene to preloadpublic void renderScene(Spatial scene, ViewPort vp)
First, the scene is checked for culling based on the Spatial
s
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.
public Camera getCurrentCamera()
The camera can be set with setCamera(com.jme3.renderer.Camera, boolean)
.
public Renderer getRenderer()
RenderManager(com.jme3.renderer.Renderer)
,
Renderer
public void flushQueue(ViewPort vp)
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.vp
- The ViewPort of which the queue will be flushedRenderQueue.renderQueue(com.jme3.renderer.queue.RenderQueue.Bucket,
com.jme3.renderer.RenderManager, com.jme3.renderer.Camera)
,
renderGeometryList(com.jme3.renderer.queue.GeometryList)
public void clearQueue(ViewPort vp)
RenderQueue.clear()
on the ViewPort's
render queue
.vp
- The ViewPort of which the queue will be cleared.RenderQueue.clear()
,
ViewPort.getQueue()
public void setLightFilter(LightFilter lightFilter)
lightFilter
- The light filter. Set it to null if you want all lights to be rendered.LightFilter
public LightFilter getLightFilter()
public void setPreferredLightMode(TechniqueDef.LightMode preferredLightMode)
preferredLightMode
- The light mode to use.public TechniqueDef.LightMode getPreferredLightMode()
public int getSinglePassLightBatchSize()
public void setSinglePassLightBatchSize(int singlePassLightBatchSize)
singlePassLightBatchSize
- the number of lights.public void renderViewPortQueues(ViewPort vp, boolean flush)
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.
vp
- the viewport of which queue should be renderedflush
- If true, the queues will be cleared after
rendering.RenderQueue
,
renderTranslucentQueue(com.jme3.renderer.ViewPort)
public void renderTranslucentQueue(ViewPort vp)
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.
vp
- The viewport of which the translucent queue should be rendered.renderViewPortQueues(com.jme3.renderer.ViewPort, boolean)
,
setHandleTranslucentBucket(boolean)
public void setCamera(Camera cam, boolean ortho)
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).
cam
- The camera to setortho
- True if to use orthographic projection (for GUI rendering),
false if to use the camera's view and projection matrices.public void renderViewPortRaw(ViewPort vp)
scene
processors
of any rendering events.vp
- The ViewPort to renderrenderViewPort(com.jme3.renderer.ViewPort, float)
public void renderViewPort(ViewPort vp, float tpf)
ViewPort
.
If the ViewPort is disabled
, this method
returns immediately. Otherwise, the ViewPort is rendered by
the following process:
scene processors
that are attached
to the ViewPort are initialized
.
SceneProcessor.preFrame(float)
method
is called.output framebuffer
is set on the RenderersetCamera(com.jme3.renderer.Camera, boolean)
)background color
is setrenderViewPortQueues(com.jme3.renderer.ViewPort, boolean)
)
SceneProcessor.postQueue(com.jme3.renderer.queue.RenderQueue)
method is called.flushQueue(com.jme3.renderer.ViewPort)
)SceneProcessor.postFrame(com.jme3.texture.FrameBuffer)
method is called.renderTranslucentQueue(com.jme3.renderer.ViewPort)
)shadow queue
which were not rendered because of a missing shadow renderer.vp
- View port to rendertpf
- Time per frame valuepublic void render(float tpf, boolean mainFrameBufferActive)
Renders any viewports that were added using the following methods:
tpf
- Time per frame valuemainFrameBufferActive
- true to render viewports with no output
FrameBuffer, false to skip them