Aviatrix3D
2.1.0

org.j3d.aviatrix3d.pipeline.graphics
Class BaseSortStage

java.lang.Object
  extended by org.j3d.aviatrix3d.pipeline.graphics.BaseSortStage
All Implemented Interfaces:
GraphicsSortStage
Direct Known Subclasses:
BaseStateSortStage, NullSortStage, SimpleTransparencySortStage, TransparencyDepthSortStage

public abstract class BaseSortStage
extends java.lang.Object
implements GraphicsSortStage

Implementation of the common code needed by all sort stage implementations.

Version:
$Revision: 3.19 $
Author:
Justin Couch

Field Summary
protected  GraphicsInstructions[] commandList
          Output array for passing on to the receiver
protected  org.j3d.util.ErrorReporter errorReporter
          Local reporter to put errors in
protected  java.util.HashMap<OffscreenBufferRenderable,GraphicsInstructions> instructionMap
          Map of the first occurance of a scene parent to it's render instruction
protected  int lastGlobalId
          A semi-unique ID counter used for assigning light IDs.
protected static int LIST_START_SIZE
          The initial size of the instruction list
protected  boolean terminate
          Flag indicating a shutdown of the current processing is requested
 
Constructor Summary
protected BaseSortStage(int numSurfaces)
          Create an empty sorting stage that initialises the internal structures to assume that there is a minumum number of surfaces, both on and offscreen.
 
Method Summary
protected abstract  int estimateInstructionSize(MultipassRenderBucket scene)
          Estimate the required size of the instruction list needed for this scene to be processed.
protected abstract  int estimateInstructionSize(SceneRenderBucket scene)
          Estimate the required size of the instruction list needed for this scene to be processed.
 void halt()
          Force a halt of the current processing.
protected  void realloc(GraphicsInstructions instr, int reqdSize)
          Reallocate the renderList and renderOps arrays.
 void setErrorReporter(org.j3d.util.ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the node's internals can be reported in a nice, pretty fashion.
 void setSortedGeometryReceiver(SortedGeometryReceiver sgr)
          Register a reciever for the output of the sorter.
 void sort(GraphicsRequestData otherData, GraphicsProfilingData profilingData, ViewportCollection[][] layers, int[] numLayers, int numScenes, OffscreenBufferRenderable[][] sceneParents)
          Sort the listing of layers and nodes.
protected abstract  int sort2DNodes(GraphicsCullOutputDetails[] nodes, int numNodes, GraphicsEnvironmentData data, GraphicsInstructions instr, int instrCount)
          Sort a single set of 2D nodes into the output details of a single layer of a single viewport and place in the provided GraphicsInstructions instance.
protected abstract  int sortNodes(GraphicsCullOutputDetails[] nodes, int numNodes, GraphicsEnvironmentData data, GraphicsInstructions instr, int instrCount)
          Sort a single set of nodes into the output details of a single layer of a single viewport and place in the provided GraphicsInstructions instance.
 
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 instruction list

See Also:
Constant Field Values

commandList

protected GraphicsInstructions[] commandList
Output array for passing on to the receiver


lastGlobalId

protected int lastGlobalId
A semi-unique ID counter used for assigning light IDs. May wrap


instructionMap

protected java.util.HashMap<OffscreenBufferRenderable,GraphicsInstructions> instructionMap
Map of the first occurance of a scene parent to it's render instruction


terminate

protected boolean terminate
Flag indicating a shutdown of the current processing is requested


errorReporter

protected org.j3d.util.ErrorReporter errorReporter
Local reporter to put errors in

Constructor Detail

BaseSortStage

protected BaseSortStage(int numSurfaces)
Create an empty sorting stage that initialises the internal structures to assume that there is a minumum number of surfaces, both on and offscreen.

Parameters:
numSurfaces - The number of surfaces that we're likely to encounter
Method Detail

sort

public void sort(GraphicsRequestData otherData,
                 GraphicsProfilingData profilingData,
                 ViewportCollection[][] layers,
                 int[] numLayers,
                 int numScenes,
                 OffscreenBufferRenderable[][] sceneParents)
Sort the listing of layers and nodes. Do not return until the sort has been completed.

For the 2D array of layers, it contains the list of final subscenes to send to the final stage, with the second dimension describing the layers, in rendering order. The first item will always be the main scene that gets rendered to the canvas.

For the 2D array sceneParent, it allows for mapping the output of internal scenes to the holding texture node. Index 0 is the direct owner of the scene contents. Index 1 is the scene parent of the scene included (needed for pBuffer GL context handling at render time). If this second one is null, then the parent is the main canvas that is being rendered to.

Specified by:
sort in interface GraphicsSortStage
Parameters:
otherData - data to be passed along unprocessed
profilingData - The timing and load data
layers - The list of layers that need to be further processed
numLayers - The number of valid layers in each scene to process
numScenes - The number of valid scenes to process
sceneParents - Parent node that holds the subscene in the main scene graph

setSortedGeometryReceiver

public void setSortedGeometryReceiver(SortedGeometryReceiver sgr)
Register a reciever for the output of the sorter. If the value is null, it will clear the currently set receiver.

Specified by:
setSortedGeometryReceiver in interface GraphicsSortStage
Parameters:
sgr - The receiver instance to add or null

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 or complete scene replacement.

Specified by:
halt in interface GraphicsSortStage

setErrorReporter

public void setErrorReporter(org.j3d.util.ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the node's internals 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:
setErrorReporter in interface GraphicsSortStage
Parameters:
reporter - The instance to use or null

sortNodes

protected abstract int sortNodes(GraphicsCullOutputDetails[] nodes,
                                 int numNodes,
                                 GraphicsEnvironmentData data,
                                 GraphicsInstructions instr,
                                 int instrCount)
Sort a single set of nodes into the output details of a single layer of a single viewport and place in the provided GraphicsInstructions instance. The implementation of this method should only concern itself with this set of nodes and not worry about dealing with nested scenes or other viewports.

Parameters:
nodes - The list of nodes to perform sorting on
numNodes - The number of valid items in the nodes array
data - The environment data used during sorting
instr - Instruction instant to put the details into
instrCount - Offset of current number of valid instructions
Returns:
The current instruction count after sorting

sort2DNodes

protected abstract int sort2DNodes(GraphicsCullOutputDetails[] nodes,
                                   int numNodes,
                                   GraphicsEnvironmentData data,
                                   GraphicsInstructions instr,
                                   int instrCount)
Sort a single set of 2D nodes into the output details of a single layer of a single viewport and place in the provided GraphicsInstructions instance. The implementation of this method should only concern itself with this set of nodes and not worry about dealing with nested scenes or other viewports.

Parameters:
nodes - The list of nodes to perform sorting on
numNodes - The number of valid items in the nodes array
data - The environment data used during sorting
instr - Instruction instant to put the details into
instrCount - Offset of current number of valid instructions
Returns:
The current instruction count after sorting

estimateInstructionSize

protected abstract int estimateInstructionSize(SceneRenderBucket scene)
Estimate the required size of the instruction list needed for this scene to be processed. This is an initial rough estimate that will be used to make sure the arrays are at least big enough to start with. There is no issue if this underestimates, as most sorting will continually check and resize as needed. However, each resize is costly, so the closer this can be to estimating the real size, the better for performance.

Parameters:
scene - The scene bucket to use for the source
Returns:
A greater than zero value

estimateInstructionSize

protected abstract int estimateInstructionSize(MultipassRenderBucket scene)
Estimate the required size of the instruction list needed for this scene to be processed. This is an initial rough estimate that will be used to make sure the arrays are at least big enough to start with. There is no issue if this underestimates, as most sorting will continually check and resize as needed. However, each resize is costly, so the closer this can be to estimating the real size, the better for performance.

Parameters:
scene - The scene bucket to use for the source
Returns:
A greater than zero value

realloc

protected void realloc(GraphicsInstructions instr,
                       int reqdSize)
Reallocate the renderList and renderOps arrays. Grows by a minimum of REALLOC_SIZE.

Parameters:
instr - The instructions to resize.
reqdSize - The minimum required size

Aviatrix3D
2.1.0

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