Class BaseLayerSensorManager
java.lang.Object
org.web3d.vrml.renderer.common.input.BaseLayerSensorManager
- All Implemented Interfaces:
LayerSensorManager
- Direct Known Subclasses:
DefaultLayerSensorManager
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.11 $
- Author:
- Justin Couch, Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set
<VRMLNodeType> The collection of all sensors currently managed by this sensor managerprotected boolean
Flag to say the background ground values changedprotected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.BackgroundListener
Listener instance for dealing with the current background nodeprotected boolean
Flag to say the background sky values changedprotected BindableNodeManager
Bindable stack for backgroundsprotected static final int
Default size of the event arraysprotected org.j3d.util.ErrorReporter
Reporter instance for handing out errorsprotected boolean
Flag to say fog color or range value changed.protected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.FogListener
Listener instance for dealing with the current fog nodeprotected BindableNodeManager
Bindable stack for fogprotected boolean
Flag to say the fog typeprotected boolean
Flag to say whether this class has completed its initializationprotected UserInputHandler
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
Buffer for input eventsprotected float
protected int
The identifier of this layer manager.protected boolean
Flag to say if navigation handling should be disabledprotected BindableNodeManager
Bindable stack for navigationInfo nodesprotected int
The number of proximity sensorsprotected int
The number of pointing device sensorsprotected int
The number of visibility sensorsprotected Set
<OriginListener> The collection of origin listenersprotected OriginManager
Origin manager for dynamic origin calculationprotected PickingManager
Picking manager for intersection testingprotected boolean
Flag indicating that the origin manager exists and is enabledprotected BindableNodeManager
Bindable stack for viewpointsprotected float
The world scale -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Clear the flags currently set because the listener has changed or been processed.boolean
See if this layer is currently pickable.int
Get the ID of the layer this sensor manager works with.boolean
Get the currently set navigation state.Get the user input handler.protected void
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
Remove these view-dependent nodes from the scene.void
setErrorReporter
(org.j3d.util.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
setOriginManager
(OriginManager manager) Set the manager for handling dynamic origin calculation.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 Details
-
DEFAULT_EVENT_SIZE
protected static final int DEFAULT_EVENT_SIZEDefault size of the event arrays- See Also:
-
initialised
protected boolean initialisedFlag to say whether this class has completed its initialization -
pickManager
Picking manager for intersection testing -
originManager
Origin manager for dynamic origin calculation -
useOriginManager
protected boolean useOriginManagerFlag indicating that the origin manager exists and is enabled -
inputManager
Buffer for input events -
errorReporter
protected org.j3d.util.ErrorReporter errorReporterReporter instance for handing out errors -
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
Bindable stack for viewpoints -
backgroundStack
Bindable stack for backgrounds -
fogStack
Bindable stack for fog -
fogTypeChanged
protected boolean fogTypeChangedFlag to say the fog type -
fogDetailsChanged
protected boolean fogDetailsChangedFlag to say fog color or range value changed. -
backgroundSkyChanged
protected boolean backgroundSkyChangedFlag to say the background sky values changed -
backgroundGroundChanged
protected boolean backgroundGroundChangedFlag to say the background ground values changed -
backgroundListener
protected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.BackgroundListener backgroundListenerListener instance for dealing with the current background node -
fogListener
protected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.FogListener fogListenerListener instance for dealing with the current fog node -
worldScale
protected float worldScaleThe world scale -
invWorldScale
protected float invWorldScale -
numVisibilityListeners
protected int numVisibilityListenersThe number of visibility sensors -
numAreaListeners
protected int numAreaListenersThe number of proximity sensors -
numPointingDeviceSensors
protected int numPointingDeviceSensorsThe number of pointing device sensors -
layerId
protected int layerIdThe identifier of this layer manager. Defaults to the invalid -1 value -
allSensorNodes
The collection of all sensors currently managed by this sensor manager -
originListeners
The collection of origin listeners
-
-
Constructor Details
-
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 Details
-
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 interfaceLayerSensorManager
- Returns:
- the ID of the layer
-
setErrorReporter
public void setErrorReporter(org.j3d.util.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 interfaceLayerSensorManager
- Parameters:
reporter
- The instance to use or null
-
getUserInputHandler
Get the user input handler. Exposed so that bindable node management can interact with the navigation system.- Specified by:
getUserInputHandler
in interfaceLayerSensorManager
- Returns:
- The user input handler instance in use
-
getIsPickable
public boolean getIsPickable()See if this layer is currently pickable.- Specified by:
getIsPickable
in interfaceLayerSensorManager
- 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 interfaceLayerSensorManager
- Parameters:
val
- if the contents of this layer can be picked
-
setInputManager
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 interfaceLayerSensorManager
- Parameters:
manager
- The input manager instance to use
-
setVRMLClock
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 interfaceLayerSensorManager
- Parameters:
clk
- The new clock to set
-
setPickingManager
Set the manager that is responsible for handling picking sensors.- Specified by:
setPickingManager
in interfaceLayerSensorManager
- Parameters:
picker
- Reference to the manager instance to use or null
-
setOriginManager
Set the manager for handling dynamic origin calculation.- Specified by:
setOriginManager
in interfaceLayerSensorManager
- Parameters:
manager
- Reference to the manager instance to use or null
-
addSensors
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 interfaceLayerSensorManager
- Parameters:
sensors
- The list of sensors to process
-
removeSensors
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 interfaceLayerSensorManager
- Parameters:
sensors
- The list of sensors to process
-
addViewDependentNodes
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 interfaceLayerSensorManager
- Parameters:
nodes
- List of nodes that need to be processed
-
removeViewDependentNodes
Remove these view-dependent nodes from the scene.- Specified by:
removeViewDependentNodes
in interfaceLayerSensorManager
- Parameters:
nodes
- List of nodes to be removed
-
loadScene
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 interfaceLayerSensorManager
- Parameters:
scene
- The scene to source data from
-
unloadScene
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 interfaceLayerSensorManager
- 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 interfaceLayerSensorManager
-
setLayerId
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:
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.
-