Aviatrix3D 1.0

org.j3d.aviatrix3d.surface
Class BaseRenderingProcessor

java.lang.Object
  extended byorg.j3d.aviatrix3d.surface.BaseRenderingProcessor
All Implemented Interfaces:
java.util.EventListener, net.java.games.jogl.GLEventListener, org.j3d.aviatrix3d.surface.Renderer

public class BaseRenderingProcessor
extends java.lang.Object
implements net.java.games.jogl.GLEventListener, org.j3d.aviatrix3d.surface.Renderer

Base handling to render for a single output device - be it on-screen or off.

Version:
$Revision: 1.3.2.2 $
Author:
Alan Hudson

Field Summary
protected  double aspectRatio
          The current aspect ratio.
protected  java.lang.Integer[] availableClips
          Stack of the available OGL clip IDs that could be assigned to clips
protected  java.lang.Integer[] availableLights
          Stack of the available OGL light IDs that could be assigned to lights
protected  float[] backgroundMatrix
          Matrix for the background rendering
protected  javax.vecmath.Matrix4f cameraMatrix
          World to local matrix (the camera) matrix
protected  float[] clearColor
          The current clear colour
protected  IntHashMap clipIdMap
          Mapping of the object ID to it's used clip ID
protected  Background currentBackground
          The current background instance
protected  TransformGroup[] currentBackgroundPath
          Path to the current background
protected  Fog currentFog
          The current fog instance
protected  TransformGroup[] currentFogPath
          Path to the current fog
protected  double[] currentFrustum
          The current frustum paramaters
protected  java.lang.Integer currentShaderProgramId
          The current program ID for GLSLang shaders.
protected  Viewpoint currentViewpoint
          The current viewpoint instance
protected  java.awt.Rectangle currentViewport
          Data describing the current viewport if explicit values used
protected  ViewEnvironment defaultEnvironment
          The default view environment if none set
protected  DeletableSceneGraphObject[] deleteQueue
          Queue for holding deleted textures
protected  RenderEffectsProcessor effectsProcessor
          Pre and Post-render effects processor, if set
protected  boolean explicitViewport
          Flag indicating whether an explicit viewport is provided or not
protected  float[] eyePoint
          The eye offset from the normal position
protected static int INITIAL_DELETE_SIZE
          Initial size of the deletion queue array
protected static int INITIAL_PATH_DEPTH
          Initial depth for the number of transforms above a view,fog or bg
protected static java.lang.Integer INVALID_SHADER
          The invalid shader ID
protected  int lastClipIdx
          index in the availableClips list of the last available
protected  int lastLightIdx
          index in the availableLights list of the last available
protected  int lastShaderInitIdx
          The current place to add shader init requestors
protected  int lastShaderLogIdx
          The current place to add shader log requestors
protected  IntHashMap lightIdMap
          Mapping of the object ID to it's used light ID
protected static int LIST_START_SIZE
          The initial size of the children list
protected  MatrixUtils matrixUtils
          Matrix utility code for doing inversions
protected static java.lang.String NOT_LIVE_BG_MSG
          Message if the node is not live
protected static java.lang.String NOT_LIVE_FOG_MSG
          Message if the node is not live
protected static java.lang.String NOT_LIVE_VP_MSG
          Message if the node is not live
protected  int numDeletions
          The number of deletable objects to handle next frame
protected  int numRenderables
          Number of items in the renderable list
protected  int[] operationList
          Local storage of the nodes that need to be rendered
protected  boolean recalcAspect
          Recalculate aspect ratio on resize.
protected  RenderDetails[] renderableList
          Local storage of the nodes that need to be rendered
protected  boolean resetColor
          Flag to say that colour needs to be reset this frame
protected  ShaderSceneGraphObject[] shaderInitList
          The change requestors for data changed sets
protected static int SHADERLIST_START_SIZE
          The initial size of the shader init/log lists
protected  ShaderSceneGraphObject[] shaderLogList
          The change requestors for bounds changed sets
protected static java.lang.String SHARED_BG_MSG
          Message when we discover the background is under a shared group/node
protected static java.lang.String SHARED_FOG_MSG
          Message when we discover the fog is under a shared group/node
protected static java.lang.String SHARED_VP_MSG
          Message when we discover the VP is under a shared group/node
protected  javax.vecmath.Matrix4f surfaceMatrix
          Combined view and projection matrix
protected  boolean terminate
          Request that the current drawing terminate immediately.
protected  java.lang.Object userData
          Generic user data that is assigned to this scene
protected  ViewEnvironment viewEnvironment
          Current view environment
protected  boolean viewEnvironmentChanged
          If the view environment or one of it's parameters have changed
protected  float[] viewMatrix
          Array version of the view matrix in use - direct to OpenGL
protected  boolean viewportChanged
          If the viewport has changed, update
protected  int windowHeight
          Current surface height
protected  int windowWidth
          Current surface width
 
Method Summary
 void display(net.java.games.jogl.GLDrawable drawable)
          Called by the drawable to perform rendering by the client.
 void displayChanged(net.java.games.jogl.GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
          Called by the drawable when the display mode or the display device associated with the GLDrawable has changed.
 void getCenterEyeInSurface(javax.vecmath.Point3f position)
          Get the Center Eye position in surface coordinates.
 void getPixelLocationInSurface(float x, float y, javax.vecmath.Point3f position)
          Convert a pixel location to surface coordinates.
 void getSurfaceToVWorld(javax.vecmath.Matrix4f matrix)
          Get the surface to VWorld transformation matrix.
 void halt()
          Force a halt of the current processing.
 void init(net.java.games.jogl.GLDrawable drawable)
          Called by the drawable immediately after the OpenGL context is initialized; the GLContext has already been made current when this method is called.
 void queueDeletedObject(DeletableSceneGraphObject obj)
          An object has been detected as being deleted (no internal or external references to it left) and it needs to be cleaned up.
 void queueShaderRequests(ShaderSceneGraphObject[] initList, int numInit, ShaderSceneGraphObject[] logList, int numLog)
          Queue up a collection of shader objects for processing on the next frame.
protected  void renderViewpoint(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Render the viewpoint setup.
 void reshape(net.java.games.jogl.GLDrawable drawable, int x, int y, int width, int height)
          Called by the drawable when the surface resizes itself.
 void setActiveBackground(Background bg)
          Set the background path that should be applied to the current surface.
 void setActiveFog(Fog fog)
          Set the fog that should be applied to the current surface.
 void setActiveView(Viewpoint vp)
          Set the viewpoint path that should be applied to the current surface.
 void setClearColor(float r, float g, float b, float a)
          Set the background colour that this surface should be cleared to before the drawing step.
 void setDrawableObjects(RenderDetails[] nodes, int[] renderOps, int numValid)
          Update the list of items to be rendered to the current list.
 void setEnvironmentData(RenderEnvironmentData data)
          Convenience method to assign up all the environment data.
 void setRenderEffects(RenderEffectsProcessor effects, java.lang.Object data)
          Set the rendering effects processor and the associated user data.
protected  void setupBackgroundFrustum(net.java.games.jogl.GL gl, double nearClip, double farClip, double fov)
          From the current view setup of FoV, near and far clipping distances and the aspectRatio ratio, generate the 6 parameters that describe a view frustum.
 void setViewEnvironment(ViewEnvironment env)
          Set the view environment that is used to render this surface.
protected  void updateProjectionMatrix(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Update the projection matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_START_SIZE

protected static final int LIST_START_SIZE
The initial size of the children list

See Also:
Constant Field Values

INITIAL_PATH_DEPTH

protected static final int INITIAL_PATH_DEPTH
Initial depth for the number of transforms above a view,fog or bg

See Also:
Constant Field Values

INITIAL_DELETE_SIZE

protected static final int INITIAL_DELETE_SIZE
Initial size of the deletion queue array

See Also:
Constant Field Values

SHADERLIST_START_SIZE

protected static final int SHADERLIST_START_SIZE
The initial size of the shader init/log lists

See Also:
Constant Field Values

INVALID_SHADER

protected static final java.lang.Integer INVALID_SHADER
The invalid shader ID


NOT_LIVE_VP_MSG

protected static final java.lang.String NOT_LIVE_VP_MSG
Message if the node is not live

See Also:
Constant Field Values

SHARED_VP_MSG

protected static final java.lang.String SHARED_VP_MSG
Message when we discover the VP is under a shared group/node

See Also:
Constant Field Values

NOT_LIVE_FOG_MSG

protected static final java.lang.String NOT_LIVE_FOG_MSG
Message if the node is not live

See Also:
Constant Field Values

SHARED_FOG_MSG

protected static final java.lang.String SHARED_FOG_MSG
Message when we discover the fog is under a shared group/node

See Also:
Constant Field Values

NOT_LIVE_BG_MSG

protected static final java.lang.String NOT_LIVE_BG_MSG
Message if the node is not live

See Also:
Constant Field Values

SHARED_BG_MSG

protected static final java.lang.String SHARED_BG_MSG
Message when we discover the background is under a shared group/node

See Also:
Constant Field Values

userData

protected java.lang.Object userData
Generic user data that is assigned to this scene


effectsProcessor

protected RenderEffectsProcessor effectsProcessor
Pre and Post-render effects processor, if set


currentViewpoint

protected Viewpoint currentViewpoint
The current viewpoint instance


currentFog

protected Fog currentFog
The current fog instance


currentFogPath

protected TransformGroup[] currentFogPath
Path to the current fog


currentBackground

protected Background currentBackground
The current background instance


currentBackgroundPath

protected TransformGroup[] currentBackgroundPath
Path to the current background


clearColor

protected float[] clearColor
The current clear colour


viewEnvironment

protected ViewEnvironment viewEnvironment
Current view environment


defaultEnvironment

protected ViewEnvironment defaultEnvironment
The default view environment if none set


currentFrustum

protected double[] currentFrustum
The current frustum paramaters


resetColor

protected boolean resetColor
Flag to say that colour needs to be reset this frame


renderableList

protected RenderDetails[] renderableList
Local storage of the nodes that need to be rendered


operationList

protected int[] operationList
Local storage of the nodes that need to be rendered


numRenderables

protected int numRenderables
Number of items in the renderable list


aspectRatio

protected double aspectRatio
The current aspect ratio. Reset each time reshape() is called


windowWidth

protected int windowWidth
Current surface width


windowHeight

protected int windowHeight
Current surface height


viewEnvironmentChanged

protected boolean viewEnvironmentChanged
If the view environment or one of it's parameters have changed


viewportChanged

protected boolean viewportChanged
If the viewport has changed, update


deleteQueue

protected DeletableSceneGraphObject[] deleteQueue
Queue for holding deleted textures


numDeletions

protected int numDeletions
The number of deletable objects to handle next frame


shaderInitList

protected ShaderSceneGraphObject[] shaderInitList
The change requestors for data changed sets


shaderLogList

protected ShaderSceneGraphObject[] shaderLogList
The change requestors for bounds changed sets


lastShaderInitIdx

protected int lastShaderInitIdx
The current place to add shader init requestors


lastShaderLogIdx

protected int lastShaderLogIdx
The current place to add shader log requestors


currentShaderProgramId

protected java.lang.Integer currentShaderProgramId
The current program ID for GLSLang shaders.


availableLights

protected java.lang.Integer[] availableLights
Stack of the available OGL light IDs that could be assigned to lights


lastLightIdx

protected int lastLightIdx
index in the availableLights list of the last available


lightIdMap

protected IntHashMap lightIdMap
Mapping of the object ID to it's used light ID


availableClips

protected java.lang.Integer[] availableClips
Stack of the available OGL clip IDs that could be assigned to clips


lastClipIdx

protected int lastClipIdx
index in the availableClips list of the last available


clipIdMap

protected IntHashMap clipIdMap
Mapping of the object ID to it's used clip ID


viewMatrix

protected float[] viewMatrix
Array version of the view matrix in use - direct to OpenGL


backgroundMatrix

protected float[] backgroundMatrix
Matrix for the background rendering


cameraMatrix

protected javax.vecmath.Matrix4f cameraMatrix
World to local matrix (the camera) matrix


surfaceMatrix

protected javax.vecmath.Matrix4f surfaceMatrix
Combined view and projection matrix


eyePoint

protected float[] eyePoint
The eye offset from the normal position


recalcAspect

protected boolean recalcAspect
Recalculate aspect ratio on resize.


matrixUtils

protected MatrixUtils matrixUtils
Matrix utility code for doing inversions


explicitViewport

protected boolean explicitViewport
Flag indicating whether an explicit viewport is provided or not


currentViewport

protected java.awt.Rectangle currentViewport
Data describing the current viewport if explicit values used


terminate

protected boolean terminate
Request that the current drawing terminate immediately. App closing

Method Detail

init

public void init(net.java.games.jogl.GLDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized; the GLContext has already been made current when this method is called.

Specified by:
init in interface net.java.games.jogl.GLEventListener
Parameters:
drawable - The display context to render to

reshape

public void reshape(net.java.games.jogl.GLDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)
Called by the drawable when the surface resizes itself. Used to reset the viewport dimensions.

Specified by:
reshape in interface net.java.games.jogl.GLEventListener
Parameters:
drawable - The display context to render to

displayChanged

public void displayChanged(net.java.games.jogl.GLDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Called by the drawable when the display mode or the display device associated with the GLDrawable has changed.

Specified by:
displayChanged in interface net.java.games.jogl.GLEventListener
Parameters:
drawable - The display context to render to

display

public void display(net.java.games.jogl.GLDrawable drawable)
Called by the drawable to perform rendering by the client.

Specified by:
display in interface net.java.games.jogl.GLEventListener
Parameters:
drawable - The display context to render to

halt

public void halt()
Force a halt of the current processing. Any processing in progress should exit immediately. Used to abort the current scene processing due to application shutdown.

Specified by:
halt in interface org.j3d.aviatrix3d.surface.Renderer

queueDeletedObject

public void queueDeletedObject(DeletableSceneGraphObject obj)
An object has been detected as being deleted (no internal or external references to it left) and it needs to be cleaned up. The next oppourtunity this drawable and any sub-drawables get, this object should have it's cleanup() method called and then the reference to it should be discarded.

Specified by:
queueDeletedObject in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
obj - The instance to be queued up as no longer being used

queueShaderRequests

public void queueShaderRequests(ShaderSceneGraphObject[] initList,
                                int numInit,
                                ShaderSceneGraphObject[] logList,
                                int numLog)
Queue up a collection of shader objects for processing on the next frame. These processing requests are for either initialisation or log handling, not for rendering.

Specified by:
queueShaderRequests in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
initList - The shaders needing initialisation
numInit - The number of shaders needing initialisation
logList - The shaders needing log fetching
numLog - The number of shaders needing log fetching

setEnvironmentData

public void setEnvironmentData(RenderEnvironmentData data)
                        throws java.lang.IllegalArgumentException
Convenience method to assign up all the environment data. Calls the setActiveX() methods in this class.

Specified by:
setEnvironmentData in interface org.j3d.aviatrix3d.surface.Renderer
Throws:
java.lang.IllegalArgumentException - The path contains a SharedGroup or the node is not live

setActiveView

public void setActiveView(Viewpoint vp)
                   throws java.lang.IllegalArgumentException
Set the viewpoint path that should be applied to the current surface. The output drawn will be a combination of this information and that of the view environment.

Specified by:
setActiveView in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
vp - The instance of the active viewpoint to use
Throws:
java.lang.IllegalArgumentException - The path contains a SharedGroup or the node is not live

setActiveFog

public void setActiveFog(Fog fog)
                  throws java.lang.IllegalArgumentException
Set the fog that should be applied to the current surface. The output drawn will be a combination of this information and that of the view environment.

Specified by:
setActiveFog in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
fog - The instance of the active fog node
Throws:
java.lang.IllegalArgumentException - The path contains a SharedGroup or the node is not live

setActiveBackground

public void setActiveBackground(Background bg)
                         throws java.lang.IllegalArgumentException
Set the background path that should be applied to the current surface. The output drawn will be a combination of this information and that of the view environment.

Specified by:
setActiveBackground in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
bg - The instance of the active background
Throws:
java.lang.IllegalArgumentException - The path contains a SharedGroup or the node is not live

setViewEnvironment

public void setViewEnvironment(ViewEnvironment env)
Set the view environment that is used to render this surface.

Specified by:
setViewEnvironment in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
env - The environment instance to use for the render setup

setRenderEffects

public void setRenderEffects(RenderEffectsProcessor effects,
                             java.lang.Object data)
Set the rendering effects processor and the associated user data. The data object will be passed back to the client code through the callback method when the pre/post render calls are done.

Specified by:
setRenderEffects in interface org.j3d.aviatrix3d.surface.Renderer

setClearColor

public void setClearColor(float r,
                          float g,
                          float b,
                          float a)
Set the background colour that this surface should be cleared to before the drawing step. Colours range from 0 to 1 in the normal manner.

Specified by:
setClearColor in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
r - The red component of the background clear colour
g - The green component of the background clear colour
b - The blue component of the background clear colour
a - The alpha component of the background clear colour

setDrawableObjects

public void setDrawableObjects(RenderDetails[] nodes,
                               int[] renderOps,
                               int numValid)
Update the list of items to be rendered to the current list. Draw them at the next oppourtunity.

Specified by:
setDrawableObjects in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
nodes - The list of nodes in sorted order
renderOps - Operation to perform on each node
numValid - The number of valid items in the array

getSurfaceToVWorld

public void getSurfaceToVWorld(javax.vecmath.Matrix4f matrix)
Get the surface to VWorld transformation matrix.

Specified by:
getSurfaceToVWorld in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
matrix - The matrix to copy into It must be preallocated.

getPixelLocationInSurface

public void getPixelLocationInSurface(float x,
                                      float y,
                                      javax.vecmath.Point3f position)
Convert a pixel location to surface coordinates.

Specified by:
getPixelLocationInSurface in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
x - The X coordinate
y - The Y coordinate
position - The converted position. It must be preallocated.

getCenterEyeInSurface

public void getCenterEyeInSurface(javax.vecmath.Point3f position)
Get the Center Eye position in surface coordinates.

Specified by:
getCenterEyeInSurface in interface org.j3d.aviatrix3d.surface.Renderer
Parameters:
position - The current eye position. It must be preallocated.

renderViewpoint

protected void renderViewpoint(net.java.games.jogl.GL gl,
                               net.java.games.jogl.GLU glu)
Render the viewpoint setup.

Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

updateProjectionMatrix

protected void updateProjectionMatrix(net.java.games.jogl.GL gl,
                                      net.java.games.jogl.GLU glu)
Update the projection matrix.

Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

setupBackgroundFrustum

protected void setupBackgroundFrustum(net.java.games.jogl.GL gl,
                                      double nearClip,
                                      double farClip,
                                      double fov)
From the current view setup of FoV, near and far clipping distances and the aspectRatio ratio, generate the 6 parameters that describe a view frustum. These parameters are what could be used as arguments to the glFrustum call. The parameter order is: [x min, x max, y min, y max, z near, z far]

Parameters:
gl - The OpenGL graphics context to use
nearClip - The distance to the near clip plane
farClip - The distance to the far clip plane
fov - The field of view to use

Aviatrix3D 1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2005 j3d.org