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 booleanFlag to say the background ground values changedprotected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.BackgroundListenerListener instance for dealing with the current background nodeprotected booleanFlag to say the background sky values changedprotected BindableNodeManagerBindable stack for backgroundsprotected static final intDefault size of the event arraysprotected org.j3d.util.ErrorReporterReporter instance for handing out errorsprotected booleanFlag to say fog color or range value changed.protected org.web3d.vrml.renderer.common.input.BaseLayerSensorManager.FogListenerListener instance for dealing with the current fog nodeprotected BindableNodeManagerBindable stack for fogprotected booleanFlag to say the fog typeprotected booleanFlag to say whether this class has completed its initializationprotected UserInputHandlerInput manager for doing the user interaction from the input devices This can be used for navigation and various pointing device sensor implementations.protected InputDeviceManagerBuffer for input eventsprotected floatprotected intThe identifier of this layer manager.protected booleanFlag to say if navigation handling should be disabledprotected BindableNodeManagerBindable stack for navigationInfo nodesprotected intThe number of proximity sensorsprotected intThe number of pointing device sensorsprotected intThe number of visibility sensorsprotected Set<OriginListener> The collection of origin listenersprotected OriginManagerOrigin manager for dynamic origin calculationprotected PickingManagerPicking manager for intersection testingprotected booleanFlag indicating that the origin manager exists and is enabledprotected BindableNodeManagerBindable stack for viewpointsprotected floatThe world scale -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSensors(NodeArray sensors) Initialise new sensors that are just about to be added to the scene.voidaddViewDependentNodes(NodeArray nodes) Add view-dependent nodes that need to be updated each frame based on the user's position for rendering.voidclear()Force clearing all state from this manager now.protected voidClear the flags currently set because the listener has changed or been processed.booleanSee if this layer is currently pickable.intGet the ID of the layer this sensor manager works with.booleanGet the currently set navigation state.Get the user input handler.protected voidOne-shot to initialise the internals structures once the event model has started to kick in.voidloadScene(BasicScene scene) Load the contents of this scene into the sensor manager.voidremoveSensors(NodeArray sensors) Cleanup the given sensors and remove them from the list of processing to be done each frame.voidRemove these view-dependent nodes from the scene.voidsetErrorReporter(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.voidsetInputManager(InputDeviceManager manager) Set the user input manager to be used by this implementation.voidsetIsPickable(boolean val) Set if this layer is currently pickable.voidsetLayerId(int id) Set the layer Id to a new value.voidsetNavigationEnabled(boolean state) Enable or disable navigation processing sub-section of the user input processing.voidsetNavigationStacks(BindableNodeManager vp, BindableNodeManager nav, BindableNodeManager back, BindableNodeManager fog) Set the bindable stacks used for viewpoint and navigation nodes.voidsetOriginManager(OriginManager manager) Set the manager for handling dynamic origin calculation.voidsetPickingManager(PickingManager picker) Set the manager that is responsible for handling picking sensors.voidsetVRMLClock(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.voidunloadScene(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, waitMethods 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:
getLayerIdin 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:
setErrorReporterin 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:
getUserInputHandlerin interfaceLayerSensorManager- Returns:
- The user input handler instance in use
-
getIsPickable
public boolean getIsPickable()See if this layer is currently pickable.- Specified by:
getIsPickablein 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:
setIsPickablein 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:
setInputManagerin 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:
setVRMLClockin interfaceLayerSensorManager- Parameters:
clk- The new clock to set
-
setPickingManager
Set the manager that is responsible for handling picking sensors.- Specified by:
setPickingManagerin interfaceLayerSensorManager- Parameters:
picker- Reference to the manager instance to use or null
-
setOriginManager
Set the manager for handling dynamic origin calculation.- Specified by:
setOriginManagerin 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:
addSensorsin 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:
removeSensorsin 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:
addViewDependentNodesin interfaceLayerSensorManager- Parameters:
nodes- List of nodes that need to be processed
-
removeViewDependentNodes
Remove these view-dependent nodes from the scene.- Specified by:
removeViewDependentNodesin 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:
loadScenein 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:
unloadScenein 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:
clearin 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.
-