Aviatrix3D 1.0

org.j3d.aviatrix3d.pipeline
Class SingleThreadRenderManager

java.lang.Object
  extended byorg.j3d.aviatrix3d.pipeline.SingleThreadRenderManager
All Implemented Interfaces:
NodeUpdateHandler, RenderPipelineManager, java.lang.Runnable

public class SingleThreadRenderManager
extends java.lang.Object
implements java.lang.Runnable, NodeUpdateHandler, RenderPipelineManager

Implementation of the RenderPipelineManager that uses a single thread for all of the processing steps.

By default the manager does not start of enabled. An explicit enable call will be needed to kick the rendering process off.

Change List processing will process bounds changed items before data changed.

Note:

Layers are not implemented yet.

Version:
$Revision: 1.44 $
Author:
Justin Couch

Constructor Summary
SingleThreadRenderManager()
          Construct a new render manager with no pipelines or renderers registered.
SingleThreadRenderManager(RenderPipeline pipe, AudioPipeline audioPipe, DrawableSurface surface, AudioDevice device)
          Constructs a new DefaultRenderManager for a single channel
SingleThreadRenderManager(RenderPipeline pipe, DrawableSurface surface)
          Constructs a new DefaultRenderManager for a single channel
 
Method Summary
 void addAudioPipeline(AudioPipeline pipe)
          Add an audio pipeline to be rendered to the manager.
 void addPipeline(RenderPipeline pipe)
          Add a pipeline to be rendered to the manager.
 boolean boundsChanged(NodeUpdateListener l, java.lang.Object src, InternalNodeUpdateListener intL)
          Notify the handler that you have updates to the SG that might alter a node's bounds.
 void dataChanged(NodeUpdateListener l, java.lang.Object src)
          Notify the handler that you have updates to the SG that will not alter a node's bounds.
 void disableInternalShutdown()
          Disable the internal shutdown hook system.
 void getLayers(Layer[] layers)
          Fetch the current layers that are set.
 int getMinimumFrameInterval()
          Fetch the currently set duty cycle value.
 PickingHandler getPickHandler()
          Get the picking handler so that we can do some picking operations.
 Scene getScene()
          Fetch the currently set scene.
 boolean isBoundsWritePermitted(java.lang.Object src)
          Check to see if writing to the node is permitted currently.
 boolean isDataWritePermitted(java.lang.Object src)
          Check to see if writing to the node is permitted currently.
 boolean isEnabled()
          Get the current render state of the manager.
 boolean isPickingPermitted()
          Check to see if picking is permitted currently.
 int numLayers()
          Get the number of layers that are currently set.
 void objectRemoved(DeletableSceneGraphObject obj)
          The object provided is no longer needed by its parent.
 void removeAudioPipeline(AudioPipeline pipe)
          Remove an already registered pipeline from the manager.
 void removePipeline(RenderPipeline pipe)
          Remove an already registered pipeline from the manager.
 void renderOnce()
          Force a single render of all pipelines now.
 void requestFullSceneRender()
          Request that the manager perform a full scene render pass and update, ignoring any usual optimisations that it may take.
 void run()
          Run method used to synchronise the internal rendering state and the external state of the canvas.
 void setApplicationObserver(ApplicationUpdateObserver obs)
          Register an observer that can be used to know when the application is safe to update the scene graph.
 void setAudioDevice(AudioDevice device)
          Set the Audio Device that is the output for this render manager.
 void setDrawableSurface(DrawableSurface surface)
          Set the drawable surface that is the output for this render manager.
 void setEnabled(boolean state)
          Tell render to start or stop rendering.
 void setLayers(Layer[] layers, int numLayers)
          Set the set of layers for this manager.
 void setMinimumFrameInterval(int cycleTime)
          Set the minimum duty cycle of the render manager.
 void setScene(Scene scene)
          Set the scene for this manager.
 void shaderRequiresInit(ShaderSceneGraphObject shader, boolean updateResponse)
          The shader object passed requires an initialisation be performed.
 void shaderRequiresLogInfo(ShaderSceneGraphObject shader, boolean updateResponse)
          The shader object passed requires updating the log info.
 void shutdown()
          Notification to shutdown the internals of the renderer because the application is about to exit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleThreadRenderManager

public SingleThreadRenderManager()
Construct a new render manager with no pipelines or renderers registered.


SingleThreadRenderManager

public SingleThreadRenderManager(RenderPipeline pipe,
                                 DrawableSurface surface)
Constructs a new DefaultRenderManager for a single channel

Parameters:
pipe - The new pipe instance to be used
surface - The surface to draw to

SingleThreadRenderManager

public SingleThreadRenderManager(RenderPipeline pipe,
                                 AudioPipeline audioPipe,
                                 DrawableSurface surface,
                                 AudioDevice device)
Constructs a new DefaultRenderManager for a single channel

Parameters:
pipe - The new pipe instance to be used
surface - The surface to draw to
device - The audio device to render to
Method Detail

setEnabled

public void setEnabled(boolean state)
Tell render to start or stop rendering. If currently running, it will wait until all the pipelines have completed their current cycle and will then halt.

Specified by:
setEnabled in interface RenderPipelineManager
Parameters:
state - True if to enable rendering

isEnabled

public boolean isEnabled()
Get the current render state of the manager.

Specified by:
isEnabled in interface RenderPipelineManager
Returns:
true if the manager is currently running

renderOnce

public void renderOnce()
                throws java.lang.IllegalStateException
Force a single render of all pipelines now. Ignores the enabled and cycle time settings to cause a single render at this point in time. If a render is currently in progress, an exception is generated

Specified by:
renderOnce in interface RenderPipelineManager
Throws:
java.lang.IllegalStateException - The system is currently rendering and should be disabled first.

requestFullSceneRender

public void requestFullSceneRender()
Request that the manager perform a full scene render pass and update, ignoring any usual optimisations that it may take. For performance reasons, a render manager may elect to not run or update some portions of the scene graph. This method requests that the next frame only should ignore those optimisations and process the full scene graph.

This method will work both in automated rendering and with the renderOnce() method.

Specified by:
requestFullSceneRender in interface RenderPipelineManager

setScene

public void setScene(Scene scene)
Set the scene for this manager. null will remove the set scene.

Specified by:
setScene in interface RenderPipelineManager
Parameters:
scene - The new scene

getScene

public Scene getScene()
Fetch the currently set scene. If layers are set, then this will return null.

Specified by:
getScene in interface RenderPipelineManager
Returns:
The current scene, or null

setLayers

public void setLayers(Layer[] layers,
                      int numLayers)
Set the set of layers for this manager. Setting a value of null will remove the currently set of layers. If this is set while a current scene is set, then the scene will be cleared. Layers are presented in depth order - layers[0] is rendered before layers[1] etc.

Specified by:
setLayers in interface RenderPipelineManager
Parameters:
layers - The collection of layers, in order, to render
numLayers - The number of valid layers to use

numLayers

public int numLayers()
Get the number of layers that are currently set. If no layers are set, or a scene is set, this will return zero.

Specified by:
numLayers in interface RenderPipelineManager
Returns:
a value greater than or equal to zero

getLayers

public void getLayers(Layer[] layers)
Fetch the current layers that are set. The values will be copied into the user-provided array. That array must be at least numLayers() in length. If not, this method does nothing (the provided array will be unchanged).

Specified by:
getLayers in interface RenderPipelineManager
Parameters:
layers - An array to copy the values into

setMinimumFrameInterval

public void setMinimumFrameInterval(int cycleTime)
Set the minimum duty cycle of the render manager. This is the type in milliseconds that should be the minimum between frames and can be used to throttle the rendering loop to a maximum frame rate should other systems require CPU time.

Specified by:
setMinimumFrameInterval in interface RenderPipelineManager
Parameters:
cycleTime - The minimum time in milliseconds between frames

getMinimumFrameInterval

public int getMinimumFrameInterval()
Fetch the currently set duty cycle value.

Specified by:
getMinimumFrameInterval in interface RenderPipelineManager
Returns:
The duty cycle time, in milliseconds

addPipeline

public void addPipeline(RenderPipeline pipe)
                 throws java.lang.IllegalStateException
Add a pipeline to be rendered to the manager. A duplicate registration or null value is ignored. For this implementation, a call to this method will replace the existing pipeline rather than add an additional one.

Specified by:
addPipeline in interface RenderPipelineManager
Parameters:
pipe - The new pipe instance to be added
Throws:
java.lang.IllegalStateException - The system is currently rendering and should be disabled first.

addAudioPipeline

public void addAudioPipeline(AudioPipeline pipe)
                      throws java.lang.IllegalStateException
Add an audio pipeline to be rendered to the manager. A duplicate registration or null value is ignored. For this implementation, a call to this method will replace the existing pipeline rather than add an additional one.

Specified by:
addAudioPipeline in interface RenderPipelineManager
Parameters:
pipe - The new pipe instance to be added
Throws:
java.lang.IllegalStateException - The system is currently rendering and should be disabled first.

removePipeline

public void removePipeline(RenderPipeline pipe)
                    throws java.lang.IllegalStateException
Remove an already registered pipeline from the manager. A or null value or one that is not currently registered is ignored. For this implementation, a call to this method will remove the existing pipeline if it is the same instance rather than remove an additional one.

Specified by:
removePipeline in interface RenderPipelineManager
Parameters:
pipe - The pipe instance to be removed
Throws:
java.lang.IllegalStateException - The system is currently rendering and should be disabled first.

removeAudioPipeline

public void removeAudioPipeline(AudioPipeline pipe)
                         throws java.lang.IllegalStateException
Remove an already registered pipeline from the manager. A or null value or one that is not currently registered is ignored. For this implementation, a call to this method will remove the existing pipeline if it is the same instance rather than remove an additional one.

Specified by:
removeAudioPipeline in interface RenderPipelineManager
Parameters:
pipe - The pipe instance to be removed
Throws:
java.lang.IllegalStateException - The system is currently rendering and should be disabled first.

setApplicationObserver

public void setApplicationObserver(ApplicationUpdateObserver obs)
Register an observer that can be used to know when the application is safe to update the scene graph. A value of null will remove the currently set value.

Specified by:
setApplicationObserver in interface RenderPipelineManager
Parameters:
obs - The observer instance to use

disableInternalShutdown

public void disableInternalShutdown()
Disable the internal shutdown hook system. It will be up to the calling application to make sure the shutdown() method is called to turn off the OpenGL rendering system. If it does not, there is a good possibility of a crash of the system.

If the internal shutdown is disabled, then the shutdown callback of the ApplicationUpdateObserver will not be called.

Specified by:
disableInternalShutdown in interface RenderPipelineManager

shutdown

public void shutdown()
Notification to shutdown the internals of the renderer because the application is about to exit.

Specified by:
shutdown in interface RenderPipelineManager

run

public void run()
Run method used to synchronise the internal rendering state and the external state of the canvas. Should never be called directly.

Specified by:
run in interface java.lang.Runnable

isDataWritePermitted

public boolean isDataWritePermitted(java.lang.Object src)
Check to see if writing to the node is permitted currently.

Specified by:
isDataWritePermitted in interface NodeUpdateHandler
Parameters:
src - The object that is requesting the check
Returns:
true if the end user can write, false if not

isBoundsWritePermitted

public boolean isBoundsWritePermitted(java.lang.Object src)
Check to see if writing to the node is permitted currently.

Specified by:
isBoundsWritePermitted in interface NodeUpdateHandler
Parameters:
src - The object that is requesting the check
Returns:
true if the end user can write, false if not

isPickingPermitted

public boolean isPickingPermitted()
Check to see if picking is permitted currently.

Specified by:
isPickingPermitted in interface NodeUpdateHandler
Returns:
true if the end user can pick, false if not

boundsChanged

public boolean boundsChanged(NodeUpdateListener l,
                             java.lang.Object src,
                             InternalNodeUpdateListener intL)
                      throws InvalidListenerSetTimingException
Notify the handler that you have updates to the SG that might alter a node's bounds.

Specified by:
boundsChanged in interface NodeUpdateHandler
Parameters:
l - The change requestor
src - The object that is passing this listener through.
intL - Internal listener for making callbacks at a later time to propogate the bounds changes.
Returns:
Was the notification accepted. Duplicates will return false.
Throws:
InvalidListenerSetTimingException - If called when the node called during one of the bounds/data changed callbacks

dataChanged

public void dataChanged(NodeUpdateListener l,
                        java.lang.Object src)
                 throws InvalidListenerSetTimingException
Notify the handler that you have updates to the SG that will not alter a node's bounds.

Specified by:
dataChanged in interface NodeUpdateHandler
Parameters:
l - The change requestor
src - The object that is passing this listener through.
Throws:
InvalidListenerSetTimingException - If called when the node called during one of the bounds/data changed callbacks

objectRemoved

public void objectRemoved(DeletableSceneGraphObject obj)
The object provided is no longer needed by its parent. Put this on a queue for objects that could potentially be deleted next frame. Used for any scene graph object type that must be explicitly cleaned up during the OpenGL render cycle, such as textures and pBuffers.

Specified by:
objectRemoved in interface NodeUpdateHandler
Parameters:
obj - The object that is registering itself for deletion

getPickHandler

public PickingHandler getPickHandler()
Get the picking handler so that we can do some picking operations.

Specified by:
getPickHandler in interface NodeUpdateHandler
Returns:
the current instance of the picking system

shaderRequiresInit

public void shaderRequiresInit(ShaderSceneGraphObject shader,
                               boolean updateResponse)
The shader object passed requires an initialisation be performed. Queue the shader up for processing now.

Specified by:
shaderRequiresInit in interface NodeUpdateHandler
Parameters:
shader - The shader instance to queue
updateResponse - true if this is being made as a response to a node's setUpdateHandler() method

shaderRequiresLogInfo

public void shaderRequiresLogInfo(ShaderSceneGraphObject shader,
                                  boolean updateResponse)
The shader object passed requires updating the log info. Queue the shader up for processing now so that at the next oppourtunity it can call glGetLogInfoARB.

Specified by:
shaderRequiresLogInfo in interface NodeUpdateHandler
Parameters:
shader - The shader instance to queue
updateResponse - true if this is being made as a response to a node's setUpdateHandler() method

setDrawableSurface

public void setDrawableSurface(DrawableSurface surface)
Set the drawable surface that is the output for this render manager.

Parameters:
surface - The surface to use

setAudioDevice

public void setAudioDevice(AudioDevice device)
Set the Audio Device that is the output for this render manager.

Parameters:
device - The device to use

Aviatrix3D 1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2005 j3d.org