Class OGLBrowserCanvas
- All Implemented Interfaces:
Runnable
,BrowserCoreListener
The aim of this canvas is to work in one of two modes - a single canvas that displays the full VRML content, or part of a series of canvases that are used together to form a common view of a single VRML scene graph. The first option represents your typical VRMLbrowser situation, where the latter represents an immersive environment like a CAVE or stereo glasses. The setup of the constructor determines which of these two modes you operate in.
To operate in multicanvas mode, you first start with a single canvas. This canvas is then used as the source of information for all the other canvases. They feed from this central item of information and work from there to build their extra scene information.
Startup of the canvas is a two-phase process. In the first phase, you get
Just the canvas and a bit of view information set up. There is no live
VRML scene graph at this point, and the various getter methods will
return null. After that, there is a second stage that is achieved by
calling the initialize()
method. This creates the VRML
structures needed by this class. This second step is quite time consuming
so it allows the caller code to get a UI item on the screen as quickly as
possible and then call a separate thread to start the initialization
process in a separate thread.
As part of the startup process, a lot of loading of extra items needs to be performed. Instead of requiring the user to create their own, this class allows the information to be specified as a collection of system properties. The only part that is not loaded as part of this startup process are the scripting engines. The end user must create their own scripting engine(s) and register those with the ScriptManager, which is available from this class after initialize() has been called.
The following system properties can be defined as part of this class:
org.xj3d.script.loader.class
The name of the class that implements theScriptLoader
interface, which is used for loading scripts.org.xj3d.script.manager.class
The name of the class that implements theScriptManager
interface, which is used for managing scripts.org.xj3d.file.loader.class
The name of the class that implements theContentLoadManager
interface, which is used for loading content other than scripts.org.xj3d.router.manager.class
The name of the class that implements theRouteManager
interface, which is used for managing routes.org.xj3d.router.factory.class
The name of the class that implements theRouterFactory
interface, which is used for creating routers.org.xj3d.frame.state.class
The name of the class that implements theFrameStateManager
interface, which is used for managing per-frame state.org.xj3d.sensor.manager.class
The name of the class that implements theSensorManager
interface, which is used for managing sensors.org.xj3d.eventmodel.evaluator.class
The name of the class that implements theEventModelEvaluator
interface, which is used for running the event model.
- Version:
- $Revision: 1.68 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Property defining a network protocol handler implementation for DIS protocol instances.static final String
Property defining the manager implementation of the event model.static final String
Property defining the loader for external files to use.static final String
Property defining the manager implementation for hanim instances.static final String
Property defining the manager implementation for network instances.static final String
Property defining the manager implementation for particle instances.static final String
Property defining the manager implementation for physics instances.static final String
Property defining the manager implementation for picking sensor interactions.static final String
Property defining the factory implementation for providing router instances.static final String
Property defining the manager implementation for providing router instances.static final String
Property defining the script loader instance to use.static final String
Property defining the script loader instance to use.static final String
Property defining the manager implementation for sensor instances.static final String
Property defining the manager implementation for providing router instances. -
Constructor Summary
ConstructorsConstructorDescriptionOGLBrowserCanvas
(org.j3d.aviatrix3d.pipeline.graphics.GraphicsOutputDevice surface, DeviceFactory deviceFactory, BrowserConfig configParams) Construct an empty canvas that contains a single view that is provided by the user. -
Method Summary
Modifier and TypeMethodDescriptionvoid
The browser has been disposed, all resources may be freed.void
browserInitialized
(VRMLScene scene) Notification that a world has been loaded into the core of the browser.void
Notification that the browser is shutting down the current content.void
enableRenderPipeline
(boolean enable) Connect or disconnect the render pipeline as requested by the argument.Fetch the load manager in use by this classGet the current event model handler in use with this class.Get the current frame state manager in use with this class.Fetch the layer rendering manager in use by this classGet the current route manager in use with this class.Fetch the script loader in use by this classGet the current sensor manager in use with this class.Get the universe used by this instant.Fetch the viewpoint manager in use by this class.Get the current world loader manager in use with this class.void
Make this canvas go through all its initialization process now.void
A request to load the world given by the URL string.void
run()
Run method for the shutdown hook.void
setEnabled
(boolean state) Control the rendering state.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion.void
setMinimumFrameInterval
(int millis, boolean userSet) Set the minimum frame interval time to limit the CPU resources taken up by the 3D renderer.void
setSurface
(org.j3d.aviatrix3d.pipeline.graphics.GraphicsOutputDevice surface, DeviceFactory deviceFactory) Set a new surface to use.void
urlLoadFailed
(String msg) The tried to load a URL and failed.
-
Field Details
-
SCRIPT_LOADER_PROP
Property defining the script loader instance to use. This should name a class that implements theScriptLoader
interface.- See Also:
-
SCRIPT_MANAGER_PROP
Property defining the script loader instance to use. This should name a class that implements theScriptManager
interface.- See Also:
-
FILE_LOADER_PROP
Property defining the loader for external files to use. This should name a class that implements theContentLoadManager
interface.- See Also:
-
ROUTER_FACTORY_PROP
Property defining the factory implementation for providing router instances. This should name a class that implements theRouterFactory
interface.- See Also:
-
ROUTER_MANAGER_PROP
Property defining the manager implementation for providing router instances. This should name a class that implements theRouteManager
interface.- See Also:
-
STATE_MANAGER_PROP
Property defining the manager implementation for providing router instances. This should name a class that implements theFrameStateManager
interface.- See Also:
-
SENSOR_MANAGER_PROP
Property defining the manager implementation for sensor instances. This should name a class that implements theSensorManager
interface.- See Also:
-
PICKING_MANAGER_PROP
Property defining the manager implementation for picking sensor interactions. This should name a class that implements thePickingManager
interface.- See Also:
-
NETWORK_MANAGER_PROP
Property defining the manager implementation for network instances. This should name a class that implements theNetworkManager
interface.- See Also:
-
DIS_PROTOCOL_HANDLER_PROP
Property defining a network protocol handler implementation for DIS protocol instances. This should name a class that implements theNetworkProtocolHandler
interface.- See Also:
-
HANIM_MANAGER_PROP
Property defining the manager implementation for hanim instances.- See Also:
-
PHYSICS_MANAGER_PROP
Property defining the manager implementation for physics instances.- See Also:
-
PARTICLE_MANAGER_PROP
Property defining the manager implementation for particle instances.- See Also:
-
EVENT_MODEL_PROP
Property defining the manager implementation of the event model. This should name a class that implements theEventModelEvaluator
interface.- See Also:
-
-
Constructor Details
-
OGLBrowserCanvas
public OGLBrowserCanvas(org.j3d.aviatrix3d.pipeline.graphics.GraphicsOutputDevice surface, DeviceFactory deviceFactory, BrowserConfig configParams) Construct an empty canvas that contains a single view that is provided by the user. This constructor would be used when you want to create the initial eye of a stereo pair. If the view is null then a default view is created.- Parameters:
surface
- The drawing component to usedeviceFactory
- The factory for pointing and key sensor devices associated with the surface.configParams
- Browser configuration parameters
-
-
Method Details
-
setSurface
public void setSurface(org.j3d.aviatrix3d.pipeline.graphics.GraphicsOutputDevice surface, DeviceFactory deviceFactory) Set a new surface to use. NULL will clear the surface.- Parameters:
surface
- - The new surface.deviceFactory
- - The factory for pointing and key sensor devices associated with the surface.
-
run
-
browserShutdown
public void browserShutdown()Notification that the browser is shutting down the current content. Use it to clear out any current items that only last for this world.- Specified by:
browserShutdown
in interfaceBrowserCoreListener
-
browserDisposed
public void browserDisposed()The browser has been disposed, all resources may be freed.- Specified by:
browserDisposed
in interfaceBrowserCoreListener
-
urlLoadFailed
The tried to load a URL and failed. It is typically because none of the URLs resolved to anything valid or there were network failures.- Specified by:
urlLoadFailed
in interfaceBrowserCoreListener
- Parameters:
msg
- An error message to go with the failure
-
browserInitialized
Notification that a world has been loaded into the core of the browser. Use this information to rebuild the viewpoint def map.- Specified by:
browserInitialized
in interfaceBrowserCoreListener
- Parameters:
scene
- The new scene that has been loaded
-
initialize
public void initialize()Make this canvas go through all its initialization process now. This will make sure that all dependent canvases are ready to go with the same information as well. The system properties for the various loaders must be set before calling this method. Setting them after this pint will result in the information being ignored. -
setEnabled
public void setEnabled(boolean state) Control the rendering state. Allows the system to be shutdown temporarily at the lowest level, effectively pausing the entire system.- Parameters:
state
- true if this should be set to the running state
-
setMinimumFrameInterval
public void setMinimumFrameInterval(int millis, boolean userSet) Set the minimum frame interval time to limit the CPU resources taken up by the 3D renderer. By default it will use all of them. The second parameter is used to control whether this is a user-set hard minimum or something set by the browser internals. User set values are always treated as the minimum unless the browser internals set a value that is a slower framerate than the user set. If the browser then sets a faster framerate than the user set value, the user value is used instead.- Parameters:
millis
- The minimum time in milleseconds.userSet
- true if this is an end-user set minimum
-
enableRenderPipeline
public void enableRenderPipeline(boolean enable) Connect or disconnect the render pipeline as requested by the argument. This essentially enables or disables rendering, without stopping the event model from running and is used free CPU resources while rendering is not required.- Parameters:
enable
- - true to connect the pipeline, false to disconnect.
-
loadWorld
A request to load the world given by the URL string. This string must point to a proper, valid URL string because this code will not check or correct the given value and will cause a crash of the parsing process otherwise.- Parameters:
url
- The URL to attempt to load in preference order
-
getLayerRenderingManager
Fetch the layer rendering manager in use by this class- Returns:
- The current manager instance
-
getScriptManager
Fetch the script loader in use by this class- Returns:
- The current loader instance
-
getViewpointManager
Fetch the viewpoint manager in use by this class.- Returns:
- The current viewpoint manager.
-
getContentLoadManager
Fetch the load manager in use by this class- Returns:
- The current load manager instance
-
getRouteManager
Get the current route manager in use with this class.- Returns:
- The current route manager in use
-
getSensorManager
Get the current sensor manager in use with this class.- Returns:
- The current sensor manager in use
-
getWorldLoaderManager
Get the current world loader manager in use with this class.- Returns:
- The current world loader manager in use
-
getFrameStateManager
Get the current frame state manager in use with this class.- Returns:
- The current frame state manager in use
-
getEventModelEvaluator
Get the current event model handler in use with this class.- Returns:
- The current event model in use
-
getUniverse
Get the universe used by this instant.- Returns:
- universe
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the 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.- Parameters:
reporter
- The instance to use or null
-