Class OGLMinimalBrowserCore
java.lang.Object
org.web3d.vrml.renderer.ogl.browser.OGLMinimalBrowserCore
- All Implemented Interfaces:
BrowserCore,EventModelInitListener,LayerRenderingManager
public class OGLMinimalBrowserCore
extends Object
implements BrowserCore, LayerRenderingManager, EventModelInitListener
Minimalist representation of a core of a browser implemented using the OpenGL
rendering APIs.
Does not support rendering to screen captures or profiling.
- Version:
- $Revision: 1.18 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a default, empty universe that contains no scene graph. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener for browser core events.voidAdd a listener for navigation state changes.voidaddNodeObserver(int nodeType, NodeObserver obs) Add an observer for a specific node type.voidRequest notification of profiling information.voidAdd a listener for sensor state changes.voidAdd a listener for viewpoint status changes.voidStop capturing the screen on each render.voidcaptureScreenOnce(ScreenCaptureListener listener) Capture the screen on the next render.voidcaptureScreenStart(ScreenCaptureListener listener) Capture the screen on each render until told to stop.voidRequest that this viewpoint object is bound at the start of the next frame.voidNotification that its safe to clear the world.voidclear()Force clearing all currently managed layers from this manager now.voiddispose()Notify the core that it can dispose all resources.voidfitToWorld(boolean animated) Move the user's location to see the entire world.floatGet the current frame rate of the browser in frames per second.floatGet the current velocity of the bound viewpoint in meters per second.Get the mapping of DEF names to the node instances that they represent.Get the description string currently used by the world.Get the ID string for this renderer.intGet the currently set minimum frame cycle interval.intGet the type of renderer that implements the browser core.intGet the currently set rendering style.intgetRenderingStyle(int layerId) Get the currently set rendering style for a specific layer.getScene()Get the scene that this universe is currently holding.voidgetUserPosition(javax.vecmath.Vector3f pos, javax.vecmath.AxisAngle4f ori) Get the user's location and orientation.Get the currently selected viewpoint in the active navigation layer.Get the clock instance in use by the core.Convenience method to ask for the execution space that the world is currently operating in.Get the fully qualified URL of the currently loaded world.voidRemove a browser core listener.voidRemove a navigation state listener.voidremoveNodeObserver(int nodeType, NodeObserver obs) Remove the given node observer instance for the specific node type.voidRemove notification of profiling information.voidRemove a sensor state listener.voidRemove a viewpoint state listener.voidsendURLFailEvent(String msg) Send to the core listeners the error message that a URL failed to load for some reason.voidsetActiveLayers(LayerManager[] layers, int numLayers) Set the list of current layers that should be rendered.voidsetDescription(String desc) Set the description of the current world.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.voidSet the eventModelStatus listener.voidsetHardwareFOV(float fov) Override the file field of view values with a value that suits the given output device.voidsetLastRenderTime(long lastTime) Set the last frame render time used for FPS calculations.voidsetMinimumFrameInterval(int millis, boolean userSet) Set the minimum frame interval time to limit the CPU resources taken up by the 3D renderer.voidsetNavigationMode(String mode) Set the desired navigation mode.voidSet the per-frame manager instance to use with this group.voidsetRenderingStyle(int style) Change the rendering style that the browser should currently be using for all layers.voidsetRenderingStyle(int style, int layerId) Change the rendering style that the browser should currently be using for for a specific layer.voidsetRenderOrder(int[] order, int numValid) Set the rendering order for all the layers on this managervoidSet the scene to use within this universe.voidsetStereoEnabled(boolean enabled) Set whether stereo is enabled for all layers.voidshutdown()Shutdown the node manager now.voidSync UI updates with the Application thread.voidNotification from the event model evaluator that the initialization phase is now complete.
-
Constructor Details
-
OGLMinimalBrowserCore
Construct a default, empty universe that contains no scene graph.- Parameters:
eme- The class used to evaluate the event model
-
-
Method Details
-
worldInitComplete
public void worldInitComplete()Notification from the event model evaluator that the initialization phase is now complete. Use this to send off the external Browser init event.- Specified by:
worldInitCompletein interfaceEventModelInitListener
-
changeWorld
public void changeWorld()Notification that its safe to clear the world. The underlying rendering layer should now be cleared and loaded with the world.- Specified by:
changeWorldin interfaceEventModelInitListener
-
getRendererType
public int getRendererType()Get the type of renderer that implements the browser core. The only valid values returned are the constants in this interface.- Specified by:
getRendererTypein interfaceBrowserCore- Returns:
- The renderer type
-
getIDString
Get the ID string for this renderer.- Specified by:
getIDStringin interfaceBrowserCore- Returns:
- The String token for this renderer.
-
setRenderingStyle
Change the rendering style that the browser should currently be using for all layers. Various options are available based on the constants defined in this interface.- Specified by:
setRenderingStylein interfaceBrowserCore- Specified by:
setRenderingStylein interfaceLayerRenderingManager- Parameters:
style- One of the RENDER_* constants- Throws:
IllegalArgumentException- A style constant that is not recognized by the implementation was provided- See Also:
-
getRenderingStyle
public int getRenderingStyle()Get the currently set rendering style. The default style is RENDER_SHADED.- Specified by:
getRenderingStylein interfaceBrowserCore- Specified by:
getRenderingStylein interfaceLayerRenderingManager- Returns:
- one of the RENDER_ constants
- See Also:
-
getRenderingStyle
public int getRenderingStyle(int layerId) Get the currently set rendering style for a specific layer. The default style is RENDER_SHADED.- Specified by:
getRenderingStylein interfaceLayerRenderingManager- Parameters:
layerId- ID for layer of interest- Returns:
- one of the RENDER_ constants
- See Also:
-
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.- Specified by:
setMinimumFrameIntervalin interfaceBrowserCore- Parameters:
millis- The minimum time in milliseconds.userSet- true if this is an end-user set minimum
-
getMinimumFrameInterval
public int getMinimumFrameInterval()Get the currently set minimum frame cycle interval. Note that this is the minimum interval, not the actual frame rate. Heavy content loads can easily drag this down below the max frame rate that this will generate.- Specified by:
getMinimumFrameIntervalin interfaceBrowserCore- Returns:
- The cycle interval time in milliseconds
-
getVRMLClock
Get the clock instance in use by the core. We need this for when new nodes are added to the scene to make sure they are all appropriately configured.- Specified by:
getVRMLClockin interfaceBrowserCore- Returns:
- The clock used by the browser core
-
getDEFMappings
Get the mapping of DEF names to the node instances that they represent. Primarily used for the EAI functionality. The map instance changes each time a new world is loaded so will need to be re-fetched. If no mappings are available (eg scripting replaceWorld() type call) then the map will be empty.- Specified by:
getDEFMappingsin interfaceBrowserCore- Returns:
- The current mapping of DEF names to node instances
-
getWorldExecutionSpace
Convenience method to ask for the execution space that the world is currently operating in. Sometimes this is not known, particularly if the end user has called a loadURL type function that is asynchronous. This will change each time a new scene is loaded.- Specified by:
getWorldExecutionSpacein interfaceBrowserCore- Returns:
- The current world execution space.
-
getDescription
Get the description string currently used by the world. Returns null if not set or supported.- Specified by:
getDescriptionin interfaceBrowserCore- Returns:
- The current description string or null
-
setDescription
Set the description of the current world. If the world is operating as part of a web browser then it shall attempt to set the title of the window. If the browser is from a component then the result is dependent on the implementation- Specified by:
setDescriptionin interfaceBrowserCore- Parameters:
desc- The description string to set.
-
getCurrentSpeed
public float getCurrentSpeed()Get the current velocity of the bound viewpoint in meters per second. The velocity is defined in terms of the world values, not the local coordinate system of the viewpoint.- Specified by:
getCurrentSpeedin interfaceBrowserCore- Returns:
- The velocity in m/s or 0.0 if not supported
-
getCurrentFrameRate
public float getCurrentFrameRate()Get the current frame rate of the browser in frames per second.- Specified by:
getCurrentFrameRatein interfaceBrowserCore- Returns:
- The current frame rate or 0.0 if not supported
-
setLastRenderTime
public void setLastRenderTime(long lastTime) Set the last frame render time used for FPS calculations. Only the per frame manager should call this.- Specified by:
setLastRenderTimein interfaceBrowserCore- Parameters:
lastTime- The time it took to render the last frame in milliseconds.
-
setEventModelStatusListener
Set the eventModelStatus listener.- Specified by:
setEventModelStatusListenerin interfaceBrowserCore- Parameters:
l- The listener. Null will clear it.
-
addSensorStatusListener
Add a listener for sensor state changes. A listener can only be added once. Duplicate requests are ignored.- Specified by:
addSensorStatusListenerin interfaceBrowserCore- Parameters:
l- The listener to add
-
removeSensorStatusListener
Remove a sensor state listener. If the reference is null or not known, the request is silently ignored.- Specified by:
removeSensorStatusListenerin interfaceBrowserCore- Parameters:
l- The listener to remove
-
addViewpointStatusListener
Add a listener for viewpoint status changes. A listener can only be added once. Duplicate requests are ignored.- Specified by:
addViewpointStatusListenerin interfaceBrowserCore- Parameters:
l- The listener to add
-
removeViewpointStatusListener
Remove a viewpoint state listener. If the reference is null or not known, the request is silently ignored.- Specified by:
removeViewpointStatusListenerin interfaceBrowserCore- Parameters:
l- The listener to remove
-
addNodeObserver
Add an observer for a specific node type. A single instance may be registered for more than one type. Each type registered will result in a separate call per frame - one per type. If the observer is currently added for this type ID, the request is ignored.- Specified by:
addNodeObserverin interfaceBrowserCore- Parameters:
nodeType- The type identifier of the node being observedobs- The observer instance to add
-
removeNodeObserver
Remove the given node observer instance for the specific node type. It will not be removed for any other requested node types. If the instance is not registered for the given node type ID, the request will be silently ignored.- Specified by:
removeNodeObserverin interfaceBrowserCore- Parameters:
nodeType- The type identifier of the node being observedobs- The observer instance to remove
-
dispose
public void dispose()Notify the core that it can dispose all resources. The core cannot be used for rendering after that.- Specified by:
disposein interfaceBrowserCore
-
getWorldURL
Get the fully qualified URL of the currently loaded world. This returns the entire URL including any possible arguments that might be associated with a CGI call or similar mechanism. If the initial world is replaced withloadURLthen the string will reflect the new URL. IfreplaceWorldis called then the URL still represents the original world.- Specified by:
getWorldURLin interfaceBrowserCore- Returns:
- A string of the URL or null if not supported.
-
setScene
Set the scene to use within this universe. If null, this will clear this scene and de-register all listeners. The View will be detached from the ViewPlatform and therefore the canvas will go blank.- Specified by:
setScenein interfaceBrowserCore- Parameters:
scene- The new scene to load, or nullviewpoint- The viewpoint.description to bind to or null for default
-
changeViewpoint
Request that this viewpoint object is bound at the start of the next frame. This method should only be called by external users such as UI toolkits etc that need to synchronize the viewpoint change with rendering loop, but are not able to synchronize themselves because they exist on a different thread that cannot block.- Specified by:
changeViewpointin interfaceBrowserCore- Parameters:
vp- The new viewpoint instance to bind to
-
addCoreListener
Add a listener for browser core events. These events are used to notify all listeners of internal structure changes, such as the browser starting and stopping. A listener can only be added once. Duplicate requests are ignored.- Specified by:
addCoreListenerin interfaceBrowserCore- Parameters:
l- The listener to add
-
removeCoreListener
Remove a browser core listener. If the reference is null or not known, the request is silently ignored.- Specified by:
removeCoreListenerin interfaceBrowserCore- Parameters:
l- The listener to remove
-
addProfilingListener
Request notification of profiling information.- Specified by:
addProfilingListenerin interfaceBrowserCore- Parameters:
l- The listener
-
removeProfilingListener
Remove notification of profiling information.- Specified by:
removeProfilingListenerin interfaceBrowserCore- Parameters:
l- The listener
-
sendURLFailEvent
Send to the core listeners the error message that a URL failed to load for some reason. This is for the EAI/ESAI spec conformance.- Specified by:
sendURLFailEventin interfaceBrowserCore- Parameters:
msg- The message to send
-
getUserPosition
public void getUserPosition(javax.vecmath.Vector3f pos, javax.vecmath.AxisAngle4f ori) Get the user's location and orientation. This will use the viewpoint bound in the active layer.- Parameters:
pos- The current user positionori- The current user orientation
-
fitToWorld
public void fitToWorld(boolean animated) Move the user's location to see the entire world. Change the users orientation to look at the center of the world.- Specified by:
fitToWorldin interfaceBrowserCore- Parameters:
animated- Should the transistion be animated. Defaults to FALSE.
-
syncUIUpdates
public void syncUIUpdates()Sync UI updates with the Application thread. This method alls the core to push work off to the app thread.- Specified by:
syncUIUpdatesin interfaceBrowserCore
-
captureScreenOnce
Capture the screen on the next render.- Specified by:
captureScreenOncein interfaceBrowserCore- Parameters:
listener- Listener for capture results
-
captureScreenStart
Capture the screen on each render until told to stop.- Specified by:
captureScreenStartin interfaceBrowserCore- Parameters:
listener- Listener for capture results
-
captureScreenEnd
public void captureScreenEnd()Stop capturing the screen on each render.- Specified by:
captureScreenEndin interfaceBrowserCore
-
setActiveLayers
Set the list of current layers that should be rendered.- Specified by:
setActiveLayersin interfaceLayerRenderingManager- Parameters:
layers- The list of layer managers to be renderednumLayers- The number of active items in the list
-
setRenderOrder
public void setRenderOrder(int[] order, int numValid) Set the rendering order for all the layers on this manager- Specified by:
setRenderOrderin interfaceLayerRenderingManager- Parameters:
order- The index of the list of rendered layers idsnumValid- The number of valid items in the order list
-
setRenderingStyle
Change the rendering style that the browser should currently be using for for a specific layer. Various options are available based on the constants defined in this interface.- Specified by:
setRenderingStylein interfaceLayerRenderingManager- Parameters:
style- One of the RENDER_* constantslayerId- The ID of the layer that should have the style changed- Throws:
IllegalArgumentException- A style constant that is not recognized by the implementation was provided- See Also:
-
shutdown
public void shutdown()Shutdown the node manager now. If this is using any external resources it should remove those now as the entire application is about to die- Specified by:
shutdownin interfaceLayerRenderingManager
-
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 interfaceBrowserCore- Specified by:
setErrorReporterin interfaceLayerRenderingManager- Parameters:
reporter- The instance to use or null
-
clear
public void clear()Force clearing all currently managed layers 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 interfaceLayerRenderingManager
-
setPerFrameManager
Set the per-frame manager instance to use with this group.- Parameters:
mgr- The manager for dealing with the frame clocking
-
setHardwareFOV
public void setHardwareFOV(float fov) Override the file field of view values with a value that suits the given output device. A value of 0 = no, otherwise use this instead of content- Parameters:
fov- The fov in degrees.
-
setStereoEnabled
public void setStereoEnabled(boolean enabled) Set whether stereo is enabled for all layers.- Parameters:
enabled-
-
getScene
Get the scene that this universe is currently holding. If none is set then null is returned.- Returns:
- The currently set scene instance
-
getViewpoint
Get the currently selected viewpoint in the active navigation layer. If there is no scene set then this returns null.- Returns:
- The current active viewpoint
-