Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.renderer.common.input
Class BaseLayerSensorManager

java.lang.Object
  extended by org.web3d.vrml.renderer.common.input.BaseLayerSensorManager
All Implemented Interfaces:
LayerSensorManager
Direct Known Subclasses:
DefaultLayerSensorManager

public abstract class BaseLayerSensorManager
extends java.lang.Object
implements LayerSensorManager

Common implementation of the LayerSensorManager interface for all renderers.

This base class handles the basic management needs of the sensor manager, such as sorting and processing the various sensor types. Renderer-specific extensions then process the sensors according to their specific needs.

Version:
$Revision: 1.9 $
Author:
Justin Couch, Alan Hudson

Field Summary
protected  java.util.HashSet allSensorNodes
          The collection of all sensors currently managed by this sensor manager
protected  boolean backgroundGroundChanged
          Flag to say the background ground values changed
protected  org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.BackgroundListener backgroundListener
          Listener instance for dealing with the current background node
protected  boolean backgroundSkyChanged
          Flag to say the background sky values changed
protected  BindableNodeManager backgroundStack
          Bindable stack for backgrounds
protected static int DEFAULT_EVENT_SIZE
          Default size of the event arrays
protected  ErrorReporter errorReporter
          Reporter instance for handing out errors
protected  boolean fogDetailsChanged
          Flag to say fog color or range value changed.
protected  org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.FogListener fogListener
          Listener instance for dealing with the current fog node
protected  BindableNodeManager fogStack
          Bindable stack for fog
protected  boolean fogTypeChanged
          Flag to say the fog type
protected  boolean initialised
          Flag to say whether this class has completed its initialisation
protected  UserInputHandler inputHandler
          Input manager for doing the user interaction from the input devices This can be used for navigation and various pointing device sensor implementations.
protected  InputDeviceManager inputManager
          Buffer for input events
protected  float invWorldScale
           
protected  int layerId
          The identifier of this layer manager.
protected  boolean navigationEnabled
          Flag to say if navigation handling should be disabled
protected  BindableNodeManager navInfoStack
          Bindable stack for navigationInfo nodes
protected  int numAreaListeners
          The number of proximity sensors
protected  int numPointingDeviceSensors
          The number of pointing device sensors
protected  int numVisibilityListeners
          The number of visibility sensors
protected  PickingManager pickManager
          Picking manager for intersection testing
protected  BindableNodeManager viewStack
          Bindable stack for viewpoints
protected  float worldScale
          The world scale
 
Constructor Summary
BaseLayerSensorManager()
          Create a new default instance of the manager.
 
Method Summary
 void addSensors(NodeArray sensors)
          Initialise new sensors that are just about to be added to the scene.
 void addViewDependentNodes(NodeArray nodes)
          Add view-dependent nodes that need to be updated each frame based on the user's position for rendering.
 void clear()
          Force clearing all state from this manager now.
protected  void clearChangeFlags()
          Clear the flags currently set because the listener has changed or been processed.
 boolean getIsPickable()
          See if this layer is currently pickable.
 int getLayerId()
          Get the ID of the layer this sensor manager works with.
 boolean getNavigationEnabled()
          Get the currently set navigation state.
 UserInputHandler getUserInputHandler()
          Get the user input handler.
protected  void initialise()
          One-shot to initialise the internals structures once the event model has started to kick in.
 void loadScene(BasicScene scene)
          Load the contents of this scene into the sensor manager.
 void removeSensors(NodeArray sensors)
          Cleanup the given sensors and remove them from the list of processing to be done each frame.
 void removeViewDependentNodes(NodeArray nodes)
          Remove these view-dependent nodes from the scene.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.
 void setInputManager(InputDeviceManager manager)
          Set the user input manager to be used by this implementation.
 void setIsPickable(boolean val)
          Set if this layer is currently pickable.
 void setLayerId(int id)
          Set the layer Id to a new value.
 void setNavigationEnabled(boolean state)
          Enable or disable navigation processing sub-section of the user input processing.
 void setNavigationStacks(BindableNodeManager vp, BindableNodeManager nav, BindableNodeManager back, BindableNodeManager fog)
          Set the bindable stacks used for viewpoint and navigation nodes.
 void setPickingManager(PickingManager picker)
          Set the manager that is responsible for handling picking sensors.
 void setVRMLClock(VRMLClock clk)
          Set the VRML clock instance that we are using so that we can set the bind time information for nodes that require it.
 void unloadScene(BasicScene scene)
          UnLoad the contents of this scene into the sensor manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xj3d.core.eventmodel.LayerSensorManager
processUserInput, updateViewMatrix
 

Field Detail

DEFAULT_EVENT_SIZE

protected static final int DEFAULT_EVENT_SIZE
Default size of the event arrays

See Also:
Constant Field Values

initialised

protected boolean initialised
Flag to say whether this class has completed its initialisation


pickManager

protected PickingManager pickManager
Picking manager for intersection testing


inputManager

protected InputDeviceManager inputManager
Buffer for input events


errorReporter

protected ErrorReporter errorReporter
Reporter instance for handing out errors


inputHandler

protected UserInputHandler inputHandler
Input manager for doing the user interaction from the input devices This can be used for navigation and various pointing device sensor implementations.


viewStack

protected BindableNodeManager viewStack
Bindable stack for viewpoints


navInfoStack

protected BindableNodeManager navInfoStack
Bindable stack for navigationInfo nodes


backgroundStack

protected BindableNodeManager backgroundStack
Bindable stack for backgrounds


fogStack

protected BindableNodeManager fogStack
Bindable stack for fog


navigationEnabled

protected boolean navigationEnabled
Flag to say if navigation handling should be disabled


fogTypeChanged

protected boolean fogTypeChanged
Flag to say the fog type


fogDetailsChanged

protected boolean fogDetailsChanged
Flag to say fog color or range value changed.


backgroundSkyChanged

protected boolean backgroundSkyChanged
Flag to say the background sky values changed


backgroundGroundChanged

protected boolean backgroundGroundChanged
Flag to say the background ground values changed


backgroundListener

protected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.BackgroundListener backgroundListener
Listener instance for dealing with the current background node


fogListener

protected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.FogListener fogListener
Listener instance for dealing with the current fog node


worldScale

protected float worldScale
The world scale


invWorldScale

protected float invWorldScale

numVisibilityListeners

protected int numVisibilityListeners
The number of visibility sensors


numAreaListeners

protected int numAreaListeners
The number of proximity sensors


numPointingDeviceSensors

protected int numPointingDeviceSensors
The number of pointing device sensors


layerId

protected int layerId
The identifier of this layer manager. Defaults to the invalid -1 value


allSensorNodes

protected java.util.HashSet allSensorNodes
The collection of all sensors currently managed by this sensor manager

Constructor Detail

BaseLayerSensorManager

public BaseLayerSensorManager()
Create a new default instance of the manager. It will only register a handler for TimeSensors. Anything other than that will require the end user code to register an appropriate manager.

Method Detail

getLayerId

public int getLayerId()
Get the ID of the layer this sensor manager works with. The ID is the rendering order, starting from 0. Once set, this shouldn't change.

Specified by:
getLayerId in interface LayerSensorManager

getNavigationEnabled

public boolean getNavigationEnabled()
Get the currently set navigation state.

Specified by:
getNavigationEnabled in interface LayerSensorManager
Returns:
true for the current state

setNavigationEnabled

public void setNavigationEnabled(boolean state)
Enable or disable navigation processing sub-section of the user input processing. By default the navigation processing is enabled.

Specified by:
setNavigationEnabled in interface LayerSensorManager
Parameters:
state - true to enable navigation

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.

Specified by:
setErrorReporter in interface LayerSensorManager
Parameters:
reporter - The instance to use or null

getUserInputHandler

public UserInputHandler getUserInputHandler()
Get the user input handler. Exposed so that bindable node management can interact with the navigation system.

Specified by:
getUserInputHandler in interface LayerSensorManager
Returns:
The user input handler instance in use

getIsPickable

public boolean getIsPickable()
See if this layer is currently pickable.

Specified by:
getIsPickable in interface LayerSensorManager
Returns:
true if the contents of this layer can be picked

setIsPickable

public void setIsPickable(boolean val)
Set if this layer is currently pickable.

Specified by:
setIsPickable in interface LayerSensorManager
Parameters:
val - if the contents of this layer can be picked

setInputManager

public void setInputManager(InputDeviceManager manager)
Set the user input manager to be used by this implementation. User input is generally independent of the main render loop. A value of null may be used to clear the currently set manager and make the handler not process user input.

Specified by:
setInputManager in interface LayerSensorManager
Parameters:
manager - The input manager instance to use

setVRMLClock

public void setVRMLClock(VRMLClock clk)
Set the VRML clock instance that we are using so that we can set the bind time information for nodes that require it. A value of null can be used to clear the current clock instance.

Specified by:
setVRMLClock in interface LayerSensorManager
Parameters:
clk - The new clock to set

setPickingManager

public void setPickingManager(PickingManager picker)
Set the manager that is responsible for handling picking sensors.

Specified by:
setPickingManager in interface LayerSensorManager
Parameters:
picker - Reference to the manager instance to use or null

setNavigationStacks

public void setNavigationStacks(BindableNodeManager vp,
                                BindableNodeManager nav,
                                BindableNodeManager back,
                                BindableNodeManager fog)
Set the bindable stacks used for viewpoint and navigation nodes. Used by the sensor for computing navigation and sensor information.

Specified by:
setNavigationStacks in interface LayerSensorManager
Parameters:
vp - The stack for viewpoints
nav - The stack for navigationInfo nodes
back - The stack for background nodes
fog - The stack for fog nodes

addSensors

public void addSensors(NodeArray sensors)
Initialise new sensors that are just about to be added to the scene. These sensors should also be added to the processing list for dealing with user input. Note that the adding process should only send the initial events, but should not do any processing for environmental effects like collisions or proximity sensing. It is assumed these will be first processed in the next render pass.

Specified by:
addSensors in interface LayerSensorManager
Parameters:
sensors - The list of sensors to process

removeSensors

public void removeSensors(NodeArray sensors)
Cleanup the given sensors and remove them from the list of processing to be done each frame. The list will be created elsewhere (typically the per-frame behaviour as a result of the event model processing) and passed to this manager. The given list will contain instances of VRMLSensorNodeType. There will be no protos as this is just the raw sensor nodes internally.

Specified by:
removeSensors in interface LayerSensorManager
Parameters:
sensors - The list of sensors to process

addViewDependentNodes

public void addViewDependentNodes(NodeArray nodes)
Add view-dependent nodes that need to be updated each frame based on the user's position for rendering. These are not sensors nodes, but others like Billboard, LOD etc.

Specified by:
addViewDependentNodes in interface LayerSensorManager
Parameters:
nodes - List of nodes that need to be processed

removeViewDependentNodes

public void removeViewDependentNodes(NodeArray nodes)
Remove these view-dependent nodes from the scene.

Specified by:
removeViewDependentNodes in interface LayerSensorManager
Parameters:
nodes - List of nodes to be removed

loadScene

public void loadScene(BasicScene scene)
Load the contents of this scene into the sensor manager. The call does not need to be recursive as it is expected the external caller will work with this.

Specified by:
loadScene in interface LayerSensorManager
Parameters:
scene - The scene to source data from

unloadScene

public void unloadScene(BasicScene scene)
UnLoad the contents of this scene into the sensor manager. The call does not need to be recursive as it is expected the external caller will work with this.

Specified by:
unloadScene in interface LayerSensorManager
Parameters:
scene - The scene to source data from

clear

public void clear()
Force clearing all state from this manager now. This is used to indicate that a new world is about to be loaded and everything should be cleaned out now.

Specified by:
clear in interface LayerSensorManager

setLayerId

public void setLayerId(int id)
                throws java.lang.IllegalStateException
Set the layer Id to a new value. This should only be called once as reseting the ID to something else when nobody is expecting it, may cause problems.

Parameters:
id - The ID to set
Throws:
java.lang.IllegalStateException - The id has already been set once

initialise

protected void initialise()
One-shot to initialise the internals structures once the event model has started to kick in.


clearChangeFlags

protected void clearChangeFlags()
Clear the flags currently set because the listener has changed or been processed.


Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium