public class RenderList
extends java.lang.Object
IsRenderable.prerender(maspack.render.RenderList)
method is also called.
The sublist to which each renderable is added is determined based on
whether the flags returned by the its IsRenderable.getRenderHints()
method contains the settings IsRenderable.TRANSPARENT
and IsRenderable.TWO_DIMENSIONAL
. Renderables are also added to their
appropriate sublist in increasing order according to a z-order value,
where z denotes the viewing axis and a higher z-order indicates an object
which is ``closer to the eye''. If the renderable is an instance of HasRenderProps
and its HasRenderProps.getRenderProps()
methods
returns a non-null
set of render properties, then the z-order
is given by RenderProps.getZOrder()
for those properties. Otherwise,
the z-order is assumed to be 0.
Sorting the renderables is done because it allows some renderers to render the scene more realistically. For example, in OpenGL, better results are obtained in opaque objects are drawn before transparent ones, and transparent objects are drawn in increasing z-order.
Constructor and Description |
---|
RenderList() |
Modifier and Type | Method and Description |
---|---|
<C extends IsRenderable> |
addIfVisible(C r)
Calls the
IsRenderable.prerender(maspack.render.RenderList) method for a specified
renderable, and then adds it to this list if it is also visible. |
void |
addIfVisibleAll(java.util.Collection<? extends IsRenderable> renderables)
Calls
addIfVisible(C) for every renderable in a specified
collection. |
void |
clear()
Clears all renderables in this list.
|
IsRenderable |
get(int idx)
Returns the
idx -th renderable in this list. |
SortedRenderableList |
getOpaque() |
IsRenderable |
getOpaque(int i)
Returns the
i -th opaque renderable in this list. |
SortedRenderableList |
getOpaque2d() |
IsRenderable |
getOpaque2d(int i)
Returns the
i -th 2d opaque renderable in this list. |
SortedRenderableList |
getTransparent() |
IsRenderable |
getTransparent(int i)
Returns the
i -th transparent renderable in this list. |
SortedRenderableList |
getTransparent2d() |
IsRenderable |
getTransparent2d(int i)
Returns the
i -th 2d transparent renderable in this list. |
int |
numOpaque()
Returns the number of opaque objects in this list.
|
int |
numOpaque2d()
Returns the number of 2d opaque objects in this list.
|
int |
numSelectionQueriesNeeded() |
int |
numTransparent()
Returns the number of transparent objects in this list.
|
int |
numTransparent2d()
Returns the number of 2d transparent objects in this list.
|
void |
printOpaqueSelectionQueries() |
int |
renderOpaque(Renderer renderer,
int qid,
int flags) |
int |
renderOpaque2d(Renderer renderer,
int qid,
int flags) |
int |
renderTransparent(Renderer renderer,
int qid,
int flags) |
int |
renderTransparent2d(Renderer renderer,
int qid,
int flags) |
int |
size()
Returns the total number of renderables in this list.
|
void |
updateBounds(Vector3d pmin,
Vector3d pmax) |
public <C extends IsRenderable> boolean addIfVisible(C r)
IsRenderable.prerender(maspack.render.RenderList)
method for a specified
renderable, and then adds it to this list if it is also visible.
The renderable is considered to be visible if either
HasRenderProps
, or
HasRenderProps
and its
HasRenderProps.getRenderProps()
method returns a
non-null
value for which
RenderProps.isVisible()
returns true
.
The renderable is added to either the opaque, transparent, 2d opaque, or 2d transparent sublist, according to increasing z-order, as described in the class documentation.
r
- renderable to maybe add to this listtrue
if c
was added.public void addIfVisibleAll(java.util.Collection<? extends IsRenderable> renderables)
addIfVisible(C)
for every renderable in a specified
collection.renderables
- collection of renderables to maybe add to this list.public IsRenderable getOpaque(int i)
i
-th opaque renderable in this list.i
- index of the renderablei
-th opaque renderablepublic SortedRenderableList getOpaque()
public IsRenderable getTransparent(int i)
i
-th transparent renderable in this list.i
- index of the renderablei
-th transparent renderablepublic SortedRenderableList getTransparent()
public IsRenderable getOpaque2d(int i)
i
-th 2d opaque renderable in this list.i
- index of the renderablei
-th 2d opaque renderablepublic SortedRenderableList getOpaque2d()
public IsRenderable getTransparent2d(int i)
i
-th 2d transparent renderable in this list.i
- index of the renderablei
-th 2d transparent renderablepublic SortedRenderableList getTransparent2d()
public void clear()
public int numTransparent()
public int numOpaque()
public int numTransparent2d()
public int numOpaque2d()
public int numSelectionQueriesNeeded()
public void printOpaqueSelectionQueries()
public int size()
public int renderOpaque(Renderer renderer, int qid, int flags)
public int renderTransparent(Renderer renderer, int qid, int flags)
public int renderOpaque2d(Renderer renderer, int qid, int flags)
public int renderTransparent2d(Renderer renderer, int qid, int flags)
public IsRenderable get(int idx)
idx
-th renderable in this list.idx
- index of the desired renderableidx
-th renderablejava.lang.IndexOutOfBoundsException
- if idx
is out of bounds.