Class DefaultSensorManager
java.lang.Object
org.web3d.vrml.renderer.common.input.DefaultSensorManager
- All Implemented Interfaces:
SensorManager
Common implementation of the SensorManager 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.12 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.j3d.util.ErrorReporter
Reporter instance for handing out errorsprotected InputDeviceManager
Buffer for input eventsprotected float
protected KeyDeviceSensorManager
Manager of key devicesprotected LayerSensorManager[]
Managers for each layer keyed by layer numberprotected boolean
Flag to say if navigation handling should be disabledprotected int
Number of currently valid sensor layer managersprotected int
The number of pointing device sensorsprotected int
The number of valid items in the render order listprotected OriginManager
Origin manager for dynamic origin calculationprotected PickingManager
Picking manager for intersection testingprotected int[]
The order that the layers are presented on screen visuallyprotected TimeSensorManager
Manager of TimeSensor nodesprotected float
The world scale -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new default instance of the manager.DefaultSensorManager
(TimeSensorManager manager) Create a new default instance of the manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a per-layer manager to the sensor manager.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.boolean
Get the currently set navigation state.Get the VRMLClock instance in use by this sensor manager.void
loadScene
(BasicScene scene) Load the contents of this scene into the sensor manager.void
processUserInput
(int layerId, long time) Process the user input to the scene now.void
Remove this layer sensor manager from the system.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
Set the manager responsible for handling key device sensor.void
setNavigationEnabled
(boolean state) Enable or disable navigation processing sub-section of the user input processing.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
setRenderOrder
(int[] order, int numValid) Set the rendering order for all the layers.void
unloadScene
(BasicScene scene) UnLoad the contents of this scene into the sensor manager.
-
Field Details
-
timeSensors
Manager of TimeSensor nodes -
keySensors
Manager of key devices -
pickManager
Picking manager for intersection testing -
originManager
Origin manager for dynamic origin calculation -
layerManagers
Managers for each layer keyed by layer number -
numLayerManagers
protected int numLayerManagersNumber of currently valid sensor layer managers -
inputManager
Buffer for input events -
errorReporter
protected org.j3d.util.ErrorReporter errorReporterReporter instance for handing out errors -
worldScale
protected float worldScaleThe world scale -
invWorldScale
protected float invWorldScale -
numPointingDeviceSensors
protected int numPointingDeviceSensorsThe number of pointing device sensors -
renderOrder
protected int[] renderOrderThe order that the layers are presented on screen visually -
numRenderOrder
protected int numRenderOrderThe number of valid items in the render order list
-
-
Constructor Details
-
DefaultSensorManager
public DefaultSensorManager()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. -
DefaultSensorManager
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.- Parameters:
manager
-
-
-
Method Details
-
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 interfaceSensorManager
- Parameters:
reporter
- The instance to use or null
-
setRenderOrder
public void setRenderOrder(int[] order, int numValid) Set the rendering order for all the layers. This is so that input handling, such as drag sensors are evaluated in the correct order, from front to back.- Specified by:
setRenderOrder
in interfaceSensorManager
- Parameters:
order
- The index of the list of rendered layers idsnumValid
- The number of valid items in the order list
-
processUserInput
public void processUserInput(int layerId, long time) Process the user input to the scene now. User input is the mouse and keyboard processing that would be used to send events to Key/StringSensors and perform navigation and picking duties as well as adjust items like billboards and LODs.The base class version calls the individual layer sensor managers and the picking manager and time sensor manager to set the appropriate clock tick time. If you need to override for renderer-specific capabilities, make sure you call this too.
- Specified by:
processUserInput
in interfaceSensorManager
- Parameters:
layerId
- The ID of the layer that is active for navigationtime
- The clock time, in Java coordinates, not VRML
-
addLayerSensorManager
Add a per-layer manager to the sensor manager. Managers are added once, and calling a manager for a layer ID will replace any manager at that current ID.- Specified by:
addLayerSensorManager
in interfaceSensorManager
- Parameters:
mgr
- The layer manager instance to add
-
removeLayerSensorManager
Remove this layer sensor manager from the system.- Specified by:
removeLayerSensorManager
in interfaceSensorManager
- Parameters:
mgr
- The layer manager instance to remove
-
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 interfaceSensorManager
- Parameters:
manager
- The input manager instance to use
-
setKeyDeviceSensorManager
Set the manager responsible for handling key device sensor. A value of null may be used to clear the currently set manager and make the handler not process user input.- Specified by:
setKeyDeviceSensorManager
in interfaceSensorManager
- Parameters:
manager
- Reference to the manager instance to use or null
-
setPickingManager
Set the manager that is responsible for handling picking sensors.- Specified by:
setPickingManager
in interfaceSensorManager
- Parameters:
picker
- Reference to the manager instance to use or null
-
setOriginManager
Description copied from interface:SensorManager
Set the manager for handling dynamic origin calculation.- Specified by:
setOriginManager
in interfaceSensorManager
- Parameters:
manager
- Reference to the manager instance to use or null
-
removeSensors
Description copied from interface:SensorManager
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 interfaceSensorManager
- Parameters:
sensors
- The list of sensors to process
-
addSensors
Description copied from interface:SensorManager
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 interfaceSensorManager
- 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 interfaceSensorManager
- Parameters:
nodes
- List of nodes that need to be processed
-
removeViewDependentNodes
Remove these view-dependent nodes from the scene.- Specified by:
removeViewDependentNodes
in interfaceSensorManager
- 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 interfaceSensorManager
- 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 interfaceSensorManager
- 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 interfaceSensorManager
-
getVRMLClock
Get the VRMLClock instance in use by this sensor manager.- Specified by:
getVRMLClock
in interfaceSensorManager
- Returns:
- A reference to the clock
-