Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.renderer.ogl.browser
Class OGLBrowserCanvas

java.lang.Object
  extended by org.web3d.vrml.renderer.ogl.browser.OGLBrowserCanvas
All Implemented Interfaces:
java.lang.Runnable, BrowserCoreListener, SensorStatusListener

public class OGLBrowserCanvas
extends java.lang.Object
implements SensorStatusListener, BrowserCoreListener, java.lang.Runnable

A single canvas that can display a VRML scene graph.

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:

Note This code already makes use of the link selection listener with the universe. Callers should not register their own listener with the universe, but should register it with this class. NoteThis class starts with its enabled state as false. call setEnabled(true) when you want to start rendering. If this is parented to an AWT component then you should call this after addNotify has been called on the component.

Version:
$Revision: 1.63 $
Author:
Justin Couch

Field Summary
static java.lang.String EVENT_MODEL_PROP
          Property defining the manager implementation of the event model.
static java.lang.String FILE_LOADER_PROP
          Property defining the loader for external files to use.
static java.lang.String HANIM_MANAGER_PROP
          Property defining the manager implementation for hanim instances.
static java.lang.String NETWORK_MANAGER_PROP
          Property defining the manager implementation for network instances.
static java.lang.String PARTICLE_MANAGER_PROP
          Property defining the manager implementation for particle instances.
static java.lang.String PHYSICS_MANAGER_PROP
          Property defining the manager implementation for physics instances.
static java.lang.String PICKING_MANAGER_PROP
          Property defining the manager implementation for picking sensor interactions.
static java.lang.String ROUTER_FACTORY_PROP
          Property defining the factory implementation for providing router instances.
static java.lang.String ROUTER_MANAGER_PROP
          Property defining the manager implementation for providing router instances.
static java.lang.String SCRIPT_LOADER_PROP
          Property defining the script loader instance to use.
static java.lang.String SCRIPT_MANAGER_PROP
          Property defining the script loader instance to use.
static java.lang.String SENSOR_MANAGER_PROP
          Property defining the manager implementation for sensor instances.
static java.lang.String STATE_MANAGER_PROP
          Property defining the manager implementation for providing router instances.
 
Fields inherited from interface org.web3d.browser.SensorStatusListener
TYPE_ANCHOR, TYPE_DRAG_SENSOR, TYPE_TOUCH_SENSOR
 
Constructor Summary
OGLBrowserCanvas(org.j3d.aviatrix3d.pipeline.graphics.GraphicsOutputDevice surface, DeviceFactory deviceFactory, BrowserConfig configParams)
          Construct an empty canvase that contains a single view that is provided by the user.
 
Method Summary
 void browserDisposed()
          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 browserShutdown()
          Notification that the browser is shutting down the current content.
 void deviceActivated(int type)
          Invoked when a tracker activates the sensor.
 void deviceNotOver(int type)
          Invoked when a tracker leaves contact with a sensor.
 void deviceOver(int type, java.lang.String desc)
          Invoked when a sensor/anchor is in contact with a tracker capable of picking.
 void enableRenderPipeline(boolean enable)
          Connect or disconnect the render pipeline as requested by the argument.
 ContentLoadManager getContentLoadManager()
          Fetch the load manager in use by this class
 EventModelEvaluator getEventModelEvaluator()
          Get the current event model handler in use with this class.
 FrameStateManager getFrameStateManager()
          Get the current frame state manager in use with this class.
 LayerRenderingManager getLayerRenderingManager()
          Fetch the layer rendering manager in use by this class
 RouteManager getRouteManager()
          Get the current route manager in use with this class.
 ScriptManager getScriptManager()
          Fetch the script loader in use by this class
 SensorManager getSensorManager()
          Get the current sensor manager in use with this class.
 OGLStandardBrowserCore getUniverse()
          Get the universe used by this instant.
 ViewpointManager getViewpointManager()
          Fetch the viewpoint manager in use by this class.
 WorldLoaderManager getWorldLoaderManager()
          Get the current world loader manager in use with this class.
 void initialize()
          Make this canvas go through all its initialization process now.
 void linkActivated(java.lang.String[] url_list)
          Invoked when a tracker follows a link.
 void loadWorld(java.lang.String url)
          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(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(java.lang.String msg)
          The tried to load a URL and failed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCRIPT_LOADER_PROP

public static final java.lang.String SCRIPT_LOADER_PROP
Property defining the script loader instance to use. This should name a class that implements the ScriptLoader interface.

See Also:
Constant Field Values

SCRIPT_MANAGER_PROP

public static final java.lang.String SCRIPT_MANAGER_PROP
Property defining the script loader instance to use. This should name a class that implements the ScriptManager interface.

See Also:
Constant Field Values

FILE_LOADER_PROP

public static final java.lang.String FILE_LOADER_PROP
Property defining the loader for external files to use. This should name a class that implements the ContentLoadManager interface.

See Also:
Constant Field Values

ROUTER_FACTORY_PROP

public static final java.lang.String ROUTER_FACTORY_PROP
Property defining the factory implementation for providing router instances. This should name a class that implements the RouterFactory interface.

See Also:
Constant Field Values

ROUTER_MANAGER_PROP

public static final java.lang.String ROUTER_MANAGER_PROP
Property defining the manager implementation for providing router instances. This should name a class that implements the RouteManager interface.

See Also:
Constant Field Values

STATE_MANAGER_PROP

public static final java.lang.String STATE_MANAGER_PROP
Property defining the manager implementation for providing router instances. This should name a class that implements the FrameStateManager interface.

See Also:
Constant Field Values

SENSOR_MANAGER_PROP

public static final java.lang.String SENSOR_MANAGER_PROP
Property defining the manager implementation for sensor instances. This should name a class that implements the SensorManager interface.

See Also:
Constant Field Values

PICKING_MANAGER_PROP

public static final java.lang.String PICKING_MANAGER_PROP
Property defining the manager implementation for picking sensor interactions. This should name a class that implements the PickingManager interface.

See Also:
Constant Field Values

NETWORK_MANAGER_PROP

public static final java.lang.String NETWORK_MANAGER_PROP
Property defining the manager implementation for network instances. This should name a class that implements the NetworkManager interface.

See Also:
Constant Field Values

HANIM_MANAGER_PROP

public static final java.lang.String HANIM_MANAGER_PROP
Property defining the manager implementation for hanim instances.

See Also:
Constant Field Values

PHYSICS_MANAGER_PROP

public static final java.lang.String PHYSICS_MANAGER_PROP
Property defining the manager implementation for physics instances.

See Also:
Constant Field Values

PARTICLE_MANAGER_PROP

public static final java.lang.String PARTICLE_MANAGER_PROP
Property defining the manager implementation for particle instances.

See Also:
Constant Field Values

EVENT_MODEL_PROP

public static final java.lang.String EVENT_MODEL_PROP
Property defining the manager implementation of the event model. This should name a class that implements the EventModelEvaluator interface.

See Also:
Constant Field Values
Constructor Detail

OGLBrowserCanvas

public OGLBrowserCanvas(org.j3d.aviatrix3d.pipeline.graphics.GraphicsOutputDevice surface,
                        DeviceFactory deviceFactory,
                        BrowserConfig configParams)
Construct an empty canvase 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 use
deviceFactory - The factory for pointing and key sensor devices associated with the surface.
configParams - Browser configuration parameters
Method Detail

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

public void run()
Run method for the shutdown hook. This is to deal with someone using ctrl-C to kill the application. Makes sure that all the resources are cleaned up properly.

Specified by:
run in interface java.lang.Runnable

deviceOver

public void deviceOver(int type,
                       java.lang.String desc)
Invoked when a sensor/anchor is in contact with a tracker capable of picking.

Specified by:
deviceOver in interface SensorStatusListener
Parameters:
type - The sensor type
desc - The sensor's description string

deviceNotOver

public void deviceNotOver(int type)
Invoked when a tracker leaves contact with a sensor.

Specified by:
deviceNotOver in interface SensorStatusListener
Parameters:
type - The sensor type

deviceActivated

public void deviceActivated(int type)
Invoked when a tracker activates the sensor. Anchors will not receive this event, they get a linkActivated call.

Specified by:
deviceActivated in interface SensorStatusListener
Parameters:
type - The sensor type

linkActivated

public void linkActivated(java.lang.String[] url_list)
Invoked when a tracker follows a link.

Specified by:
linkActivated in interface SensorStatusListener
Parameters:
url_list - The url to load.

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 interface BrowserCoreListener

browserDisposed

public void browserDisposed()
The browser has been disposed, all resources may be freed.

Specified by:
browserDisposed in interface BrowserCoreListener

urlLoadFailed

public void urlLoadFailed(java.lang.String msg)
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 interface BrowserCoreListener
Parameters:
msg - An error message to go with the failure

browserInitialized

public void browserInitialized(VRMLScene scene)
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 interface BrowserCoreListener
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

public void loadWorld(java.lang.String url)
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

getLayerRenderingManager

public LayerRenderingManager getLayerRenderingManager()
Fetch the layer rendering manager in use by this class

Returns:
The current manager instance

getScriptManager

public ScriptManager getScriptManager()
Fetch the script loader in use by this class

Returns:
The current loader instance

getViewpointManager

public ViewpointManager getViewpointManager()
Fetch the viewpoint manager in use by this class.

Returns:
The current viewpoint manager.

getContentLoadManager

public ContentLoadManager getContentLoadManager()
Fetch the load manager in use by this class

Returns:
The current load manager instance

getRouteManager

public RouteManager getRouteManager()
Get the current route manager in use with this class.

Returns:
The current route manager in use

getSensorManager

public SensorManager getSensorManager()
Get the current sensor manager in use with this class.

Returns:
The current sensor manager in use

getWorldLoaderManager

public WorldLoaderManager getWorldLoaderManager()
Get the current world loader manager in use with this class.

Returns:
The current world loader manager in use

getFrameStateManager

public FrameStateManager getFrameStateManager()
Get the current frame state manager in use with this class.

Returns:
The current frame state manager in use

getEventModelEvaluator

public EventModelEvaluator getEventModelEvaluator()
Get the current event model handler in use with this class.

Returns:
The current event model in use

getUniverse

public OGLStandardBrowserCore getUniverse()
Get the universe used by this instant.


setErrorReporter

public void setErrorReporter(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

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium