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.ErrorReporterReporter instance for handing out errorsprotected InputDeviceManagerBuffer for input eventsprotected floatprotected KeyDeviceSensorManagerManager of key devicesprotected LayerSensorManager[]Managers for each layer keyed by layer numberprotected booleanFlag to say if navigation handling should be disabledprotected intNumber of currently valid sensor layer managersprotected intThe number of pointing device sensorsprotected intThe number of valid items in the render order listprotected OriginManagerOrigin manager for dynamic origin calculationprotected PickingManagerPicking manager for intersection testingprotected int[]The order that the layers are presented on screen visuallyprotected TimeSensorManagerManager of TimeSensor nodesprotected floatThe 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 TypeMethodDescriptionvoidAdd a per-layer manager to the sensor manager.voidaddSensors(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.booleanGet the currently set navigation state.Get the VRMLClock instance in use by this sensor manager.voidloadScene(BasicScene scene) Load the contents of this scene into the sensor manager.voidprocessUserInput(int layerId, long time) Process the user input to the scene now.voidRemove this layer sensor manager from the system.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.voidSet the manager responsible for handling key device sensor.voidsetNavigationEnabled(boolean state) Enable or disable navigation processing sub-section of the user input processing.voidsetOriginManager(OriginManager manager) Set the manager for handling dynamic origin calculation.voidsetPickingManager(PickingManager picker) Set the manager that is responsible for handling picking sensors.voidsetRenderOrder(int[] order, int numValid) Set the rendering order for all the layers.voidunloadScene(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:
setErrorReporterin 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:
setRenderOrderin 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:
processUserInputin 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:
addLayerSensorManagerin interfaceSensorManager- Parameters:
mgr- The layer manager instance to add
-
removeLayerSensorManager
Remove this layer sensor manager from the system.- Specified by:
removeLayerSensorManagerin 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:
setInputManagerin 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:
setKeyDeviceSensorManagerin 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:
setPickingManagerin interfaceSensorManager- Parameters:
picker- Reference to the manager instance to use or null
-
setOriginManager
Description copied from interface:SensorManagerSet the manager for handling dynamic origin calculation.- Specified by:
setOriginManagerin interfaceSensorManager- Parameters:
manager- Reference to the manager instance to use or null
-
removeSensors
Description copied from interface:SensorManagerCleanup 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 interfaceSensorManager- Parameters:
sensors- The list of sensors to process
-
addSensors
Description copied from interface:SensorManagerInitialise 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 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:
addViewDependentNodesin interfaceSensorManager- Parameters:
nodes- List of nodes that need to be processed
-
removeViewDependentNodes
Remove these view-dependent nodes from the scene.- Specified by:
removeViewDependentNodesin 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:
loadScenein 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:
unloadScenein 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:
clearin interfaceSensorManager
-
getVRMLClock
Get the VRMLClock instance in use by this sensor manager.- Specified by:
getVRMLClockin interfaceSensorManager- Returns:
- A reference to the clock
-