org.xith3d.render
Class DefaultRenderer

java.lang.Object
  extended by org.xith3d.render.Renderer
      extended by org.xith3d.render.DefaultRenderer

public class DefaultRenderer
extends Renderer

The Renderer is the main class for managing the transformation from the scene graph to the 3D card. The Renderer is in charge of atom shader sorting, transparency passes, etc.

The actual OpenGL calls are made by the rendering peer which is supplied when the renderer is created. The renderer supports several different modes of operation including offscreen, render to texture, render to image and rendering to screen.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.xith3d.render.Renderer
Renderer.OpaqueSortingPolicy, Renderer.TransparentSortingPolicy
 
Field Summary
 
Fields inherited from class org.xith3d.render.Renderer
renderersWorking
 
Constructor Summary
DefaultRenderer()
          Creates a new Renderer.
 
Method Summary
protected  void addCanvas3D(Canvas3D canvas)
          Adds a Canvas3D to the Renderer.
protected  void addPickRequest(PickRequest pickRequest)
          Adds a PickRequest to the Renderer.
protected  RenderPass addRenderPass(int index, RenderPass renderPass)
          Adds a new RenderPass to this Renderer at the given position.
protected  RenderPass addRenderPass(RenderPass renderPass)
          Adds a new RenderPass to this Renderer at the end of the list.
 void addRenderTarget(RenderTarget renderTarget, RenderPass renderPass)
          Adds a RenderTarget to the Renderer.
 RenderPass addRenderTarget(RenderTarget renderTarget, RenderPassConfig passConfig)
          Adds a RenderTarget to the Renderer.
 void addScenegraphModificationListener(ScenegraphModificationsListener modListener)
          Adds a new ScenegraphModificationListener to the List.
protected  java.lang.Object doRender(java.util.List<RenderPass> renderPasses, Canvas3D canvas, long frameId, long nanoTime, long nanoStep, PickRequest pickRequest)
           
 Canvas3D getCanvas3D(int index)
          
 long getLastFrameId()
          
 int getNumberOfCanvas3Ds()
          
 long getNumRenderedShapes()
          
 long getNumRenderedTriangles()
          
 RenderBinSorter getOpaqueSorter()
          
 Renderer.OpaqueSortingPolicy getOpaqueSortingPolicy()
          
 RenderPass getRenderPass(int index)
          
 java.util.List<RenderPass> getRenderPasses()
          
 java.util.List<RenderPass> getRenderPasses(BranchGroup branchGroup)
          
 int getRenderPassesCount()
          
 java.util.List<RenderTarget> getRenderTargets()
          
 java.util.List<ScenegraphModificationsListener> getScenegraphModificationListeners()
          
 org.xith3d.render.ScenegraphModificationsManager getScenegraphModificationsManager()
           
 SoundProcessor getSoundProcessor()
          
 RenderBinSorter getTransparentSorter()
          
 Renderer.TransparentSortingPolicy getTransparentSortingPolicy()
          
 boolean isLayeredMode()
          
 boolean isRendering()
          
protected  void removeAllRenderPasses()
          Removes all RenderPasses from this Renderer.
protected  void removeCanvas3D(Canvas3D canvas)
          Removes a Canvas3D from the Renderer.
protected  Canvas3D removeCanvas3D(int i)
          Removes a Canvas3D from the Renderer.
protected  boolean removeRenderPass(int index)
          Removes the RenderPass from this Renderer.
protected  boolean removeRenderPass(RenderPass renderPass)
          Removes the RenderPass from this Renderer.
protected  boolean removeRenderPasses(BranchGroup branchGroup)
          Removes the RenderPass from this Renderer, which is assotiated to the given BranchGroup.
 void removeRenderTarget(RenderTarget renderTarget)
          Removes a RenderTarget from the Renderer.
 void removeScenegraphModificationListener(ScenegraphModificationsListener modListener)
          Removes a ScenegraphModificationListener from the List.
 long renderOnce(Canvas3D canvas, long nanoTime, long nanoStep)
          Renders the next frame to the given Canvas3D.
 long renderOnce(java.util.List<RenderPass> renderPasses, java.util.List<? extends java.util.List<GroupNode>> groupsLists, Canvas3D canvas, long nanoTime, long nanoStep)
          Renders one frame on a specified universe and canvas.
 long renderOnce(long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
 long renderOnce(RenderPass renderPass, Canvas3D canvas, long nanoTime, long nanoStep)
          Renders one frame on a specified universe and canvas.
 long renderOnce(RenderPass renderPass, GroupNode group, Canvas3D canvas, long nanoTime, long nanoStep)
          Renders one frame on a specified universe and canvas.
 long renderOnce(RenderPass renderPass, GroupNode group, long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
 long renderOnce(RenderPass renderPass, long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
 long renderOnce(View view, long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
 void setLayeredMode(boolean layeredMode)
          Sets if the rendering is done in layered mode or not.
 void setOpaqueSorter(RenderBinSorter sorter)
          Sets the opaque RenderBinSorter for this Renderer.
 void setOpaqueSortingPolicy(Renderer.OpaqueSortingPolicy policy)
          Sets the opaque sorting policy for this Renderer.
 void setTransparentSorter(RenderBinSorter sorter)
          Sets the transparent RenderBinSorter for this Renderer.
 void setTransparentSortingPolicy(Renderer.TransparentSortingPolicy policy)
          Sets the transparency sorting policy for this Renderer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRenderer

public DefaultRenderer()
Creates a new Renderer.

Method Detail

getSoundProcessor

public final SoundProcessor getSoundProcessor()

Specified by:
getSoundProcessor in class Renderer

getScenegraphModificationsManager

public org.xith3d.render.ScenegraphModificationsManager getScenegraphModificationsManager()

addScenegraphModificationListener

public void addScenegraphModificationListener(ScenegraphModificationsListener modListener)
Adds a new ScenegraphModificationListener to the List. It will be notified of any scenegraph change at runtime.

Specified by:
addScenegraphModificationListener in class Renderer
Parameters:
modListener - the new ScenegraphModificationsListener to add

removeScenegraphModificationListener

public void removeScenegraphModificationListener(ScenegraphModificationsListener modListener)
Removes a ScenegraphModificationListener from the List.

Specified by:
removeScenegraphModificationListener in class Renderer
Parameters:
modListener - the ScenegraphModificationsListener to be removed

getScenegraphModificationListeners

public java.util.List<ScenegraphModificationsListener> getScenegraphModificationListeners()

Specified by:
getScenegraphModificationListeners in class Renderer
Returns:
a List of all registered ScenegraphModificationListeners

addCanvas3D

protected final void addCanvas3D(Canvas3D canvas)
Adds a Canvas3D to the Renderer.

Specified by:
addCanvas3D in class Renderer

removeCanvas3D

protected final void removeCanvas3D(Canvas3D canvas)
Removes a Canvas3D from the Renderer.

Specified by:
removeCanvas3D in class Renderer

removeCanvas3D

protected final Canvas3D removeCanvas3D(int i)
Removes a Canvas3D from the Renderer.

Specified by:
removeCanvas3D in class Renderer
Returns:
the removed Canvas3D

getNumberOfCanvas3Ds

public final int getNumberOfCanvas3Ds()

Specified by:
getNumberOfCanvas3Ds in class Renderer
Returns:
the number of Canvas3Ds in this Renderer.

getCanvas3D

public final Canvas3D getCanvas3D(int index)

Specified by:
getCanvas3D in class Renderer
Returns:
the n-th Canvas3D from the Renderer.

addRenderTarget

public final void addRenderTarget(RenderTarget renderTarget,
                                  RenderPass renderPass)
Adds a RenderTarget to the Renderer.

Specified by:
addRenderTarget in class Renderer

addRenderTarget

public final RenderPass addRenderTarget(RenderTarget renderTarget,
                                        RenderPassConfig passConfig)
Adds a RenderTarget to the Renderer.

Specified by:
addRenderTarget in class Renderer

removeRenderTarget

public final void removeRenderTarget(RenderTarget renderTarget)
Removes a RenderTarget from the Renderer.

Specified by:
removeRenderTarget in class Renderer

getRenderTargets

public java.util.List<RenderTarget> getRenderTargets()

Specified by:
getRenderTargets in class Renderer
Returns:
a list of all registered RenderTargets.

addRenderPass

protected final RenderPass addRenderPass(RenderPass renderPass)
Adds a new RenderPass to this Renderer at the end of the list. In layered rendering mode it is important, that the first added pass will be rendered first and the last added rendered last.

Specified by:
addRenderPass in class Renderer
Parameters:
renderPass - the RenderPass to add
Returns:
the given RenderPass object

addRenderPass

protected final RenderPass addRenderPass(int index,
                                         RenderPass renderPass)
Adds a new RenderPass to this Renderer at the given position. In layered rendering mode it is important, that the first pass in the list will be rendered first and the last rendered last.

Specified by:
addRenderPass in class Renderer
Parameters:
index - the position the RenderPass is to be placed at in the list
renderPass - the RenderPass to add
Returns:
the given RenderPass object

removeRenderPasses

protected final boolean removeRenderPasses(BranchGroup branchGroup)
Removes the RenderPass from this Renderer, which is assotiated to the given BranchGroup.

Specified by:
removeRenderPasses in class Renderer
Parameters:
branchGroup - the BranchGroup, which's RenderPass is to be removed
Returns:
true, if the RenderPass existed in the Renderer

removeRenderPass

protected final boolean removeRenderPass(RenderPass renderPass)
Removes the RenderPass from this Renderer.

Specified by:
removeRenderPass in class Renderer
Parameters:
renderPass - the RenderPass to be removed
Returns:
true, if the RenderPass existed in the Renderer

removeRenderPass

protected final boolean removeRenderPass(int index)
Removes the RenderPass from this Renderer.

Specified by:
removeRenderPass in class Renderer
Parameters:
index - the index of the RenderPass to be removed
Returns:
true, if the RenderPass existed in the Renderer

removeAllRenderPasses

protected void removeAllRenderPasses()
Removes all RenderPasses from this Renderer.

Specified by:
removeAllRenderPasses in class Renderer

getRenderPassesCount

public final int getRenderPassesCount()

Specified by:
getRenderPassesCount in class Renderer
Returns:
the number of RenderPasses registered in this Renderer.

getRenderPasses

public final java.util.List<RenderPass> getRenderPasses(BranchGroup branchGroup)

Specified by:
getRenderPasses in class Renderer
Parameters:
branchGroup - the BranchGroup the RenderPasses are linked with
Returns:
the List of RenderPasses registered here with this BranchGroup.

getRenderPass

public final RenderPass getRenderPass(int index)

Specified by:
getRenderPass in class Renderer
Parameters:
index - the index of the desired RenderPass
Returns:
the RenderPass registered here with this index.

getRenderPasses

public final java.util.List<RenderPass> getRenderPasses()

Specified by:
getRenderPasses in class Renderer
Returns:
the list of RenderPasses registered with this Renderer.

setLayeredMode

public final void setLayeredMode(boolean layeredMode)
Sets if the rendering is done in layered mode or not.

Specified by:
setLayeredMode in class Renderer
Parameters:
layeredMode - if true, rendering will be done in layered mode

isLayeredMode

public final boolean isLayeredMode()

Specified by:
isLayeredMode in class Renderer
Returns:
if the rendering is done in layered mode.

setOpaqueSorter

public final void setOpaqueSorter(RenderBinSorter sorter)
Sets the opaque RenderBinSorter for this Renderer.
This automatically sets the sorting policy to CUSTOM.

Specified by:
setOpaqueSorter in class Renderer
Parameters:
sorter - the RenderBinSorter to use for opaque shapes
See Also:
Renderer.setOpaqueSortingPolicy(org.xith3d.render.Renderer.OpaqueSortingPolicy)

getOpaqueSorter

public final RenderBinSorter getOpaqueSorter()

Specified by:
getOpaqueSorter in class Renderer
Returns:
sorter the RenderBinSorter to use for opaque shapes
See Also:
Renderer.getOpaqueSortingPolicy()

setTransparentSorter

public final void setTransparentSorter(RenderBinSorter sorter)
Sets the transparent RenderBinSorter for this Renderer.
This automatically sets the sorting policy to CUSTOM.

Specified by:
setTransparentSorter in class Renderer
Parameters:
sorter - the RenderBinSorter to use for transparent shapes

getTransparentSorter

public final RenderBinSorter getTransparentSorter()

Specified by:
getTransparentSorter in class Renderer
Returns:
sorter the RenderBinSorter to use for transparent shapes
See Also:
Renderer.getTransparentSortingPolicy()

setOpaqueSortingPolicy

public final void setOpaqueSortingPolicy(Renderer.OpaqueSortingPolicy policy)
Sets the opaque sorting policy for this Renderer.

Specified by:
setOpaqueSortingPolicy in class Renderer
Parameters:
policy - the new policy

getOpaqueSortingPolicy

public final Renderer.OpaqueSortingPolicy getOpaqueSortingPolicy()

Specified by:
getOpaqueSortingPolicy in class Renderer
Returns:
the current opaque sorting policy for this Renderer

setTransparentSortingPolicy

public final void setTransparentSortingPolicy(Renderer.TransparentSortingPolicy policy)
Sets the transparency sorting policy for this Renderer.

Specified by:
setTransparentSortingPolicy in class Renderer
Parameters:
policy - the new policy

getTransparentSortingPolicy

public final Renderer.TransparentSortingPolicy getTransparentSortingPolicy()

Specified by:
getTransparentSortingPolicy in class Renderer
Returns:
the current transparency sorting policy for this Renderer.

addPickRequest

protected void addPickRequest(PickRequest pickRequest)
Adds a PickRequest to the Renderer.
It is handled with the next rendered frame.

Specified by:
addPickRequest in class Renderer

doRender

protected java.lang.Object doRender(java.util.List<RenderPass> renderPasses,
                                    Canvas3D canvas,
                                    long frameId,
                                    long nanoTime,
                                    long nanoStep,
                                    PickRequest pickRequest)

renderOnce

public final long renderOnce(java.util.List<RenderPass> renderPasses,
                             java.util.List<? extends java.util.List<GroupNode>> groupsLists,
                             Canvas3D canvas,
                             long nanoTime,
                             long nanoStep)
Renders one frame on a specified universe and canvas.

Specified by:
renderOnce in class Renderer

renderOnce

public final long renderOnce(RenderPass renderPass,
                             GroupNode group,
                             Canvas3D canvas,
                             long nanoTime,
                             long nanoStep)
Renders one frame on a specified universe and canvas.

Specified by:
renderOnce in class Renderer

renderOnce

public final long renderOnce(RenderPass renderPass,
                             Canvas3D canvas,
                             long nanoTime,
                             long nanoStep)
Renders one frame on a specified universe and canvas.

Specified by:
renderOnce in class Renderer

renderOnce

public final long renderOnce(Canvas3D canvas,
                             long nanoTime,
                             long nanoStep)
Renders the next frame to the given Canvas3D.

Specified by:
renderOnce in class Renderer
Parameters:
canvas - the canvas to be rendered

renderOnce

public final long renderOnce(View view,
                             long nanoTime,
                             long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.

Specified by:
renderOnce in class Renderer

renderOnce

public final long renderOnce(RenderPass renderPass,
                             GroupNode group,
                             long nanoTime,
                             long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.

Specified by:
renderOnce in class Renderer

renderOnce

public final long renderOnce(RenderPass renderPass,
                             long nanoTime,
                             long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.

Specified by:
renderOnce in class Renderer

renderOnce

public final long renderOnce(long nanoTime,
                             long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.

Specified by:
renderOnce in class Renderer

getLastFrameId

public long getLastFrameId()

Specified by:
getLastFrameId in class Renderer
Returns:
the last used frame-id

getNumRenderedShapes

public final long getNumRenderedShapes()

Specified by:
getNumRenderedShapes in class Renderer
Returns:
the number of shapes actually being rendered

getNumRenderedTriangles

public final long getNumRenderedTriangles()

Specified by:
getNumRenderedTriangles in class Renderer
Returns:
the number of rendered triangles

isRendering

public boolean isRendering()

Specified by:
isRendering in class Renderer
Returns:
true, if the view is currently rendering a frame