public class DistortedNode extends java.lang.Object implements InternalChildrenList.Parent
Having organized such sets into a Tree, we can then render any Node to any OutputSurface. That recursively renders the set held in the Node and all its children.
The class takes special care to only render identical sub-trees once. Each Node holds a reference to sub-class 'NodeData'. Two identical sub-trees attached at different points of the main tree will point to the same NodeData; only the first of this is rendered (mData.numRender!).
Constructor and Description |
---|
DistortedNode(DistortedNode node,
int flags)
Copy-constructs new Node from another Node.
|
DistortedNode(org.distorted.library.main.InternalSurface surface,
DistortedEffects effects,
MeshBase mesh)
Constructs new Node.
|
Modifier and Type | Method and Description |
---|---|
void |
attach(DistortedNode node)
Adds a new child to the last position in the list of our Node's children.
|
DistortedNode |
attach(org.distorted.library.main.InternalSurface surface,
DistortedEffects effects,
MeshBase mesh)
Adds a new child to the last position in the list of our Node's children.
|
void |
detach(DistortedEffects effects)
Removes the first occurrence of a specified child from the list of children of our Node.
|
void |
detach(DistortedNode node)
Removes the first occurrence of a specified child from the list of children of our Node.
|
void |
detachAll()
Removes all children Nodes.
|
void |
enableDepthStencil(int depthStencil)
Enables/disables DEPTH and STENCIL buffers in the Framebuffer object that we render this Node to.
|
DistortedEffects |
getEffects()
Returns the DistortedEffects object that's in the Node.
|
MeshBase |
getMesh()
Returns the Mesh object that's in the Node.
|
org.distorted.library.main.InternalSurface |
getSurface()
Returns the surface this object gets rendered to.
|
void |
glBlendFunc(int src,
int dst)
When rendering this Node, use the following Blending mode.
|
void |
glClear(int mask)
Before rendering this Node, clear the following buffers.
|
void |
glColorMask(boolean r,
boolean g,
boolean b,
boolean a)
When rendering this Node, use ColorMask (r,g,b,a).
|
void |
glDepthFunc(int func)
When rendering this Node, use the following DepthFunc.
|
void |
glDepthMask(boolean mask)
When rendering this Node, switch on writing to Depth buffer?
|
void |
glDisable(int test)
When rendering this Node, which Tests to enable?
|
void |
glEnable(int test)
When rendering this Node, which Tests to enable?
|
void |
glStencilFunc(int func,
int ref,
int mask)
When rendering this Node, use the following StencilFunc.
|
void |
glStencilMask(int mask)
When rendering this Node, which bits of the Stencil buffer to write to?
|
void |
glStencilOp(int sfail,
int dpfail,
int dppass)
When rendering this Node, use the following StencilOp.
|
void |
markForDeletion() |
void |
resizeFBO(int width,
int height)
Resizes the DistortedFramebuffer object that we render this Node to.
|
void |
setOrderIndependentTransparency(boolean oit)
When rendering this Node, should we use the Order Independent Transparency render more?
|
void |
setOrderIndependentTransparency(boolean oit,
float initialSize)
When rendering this Node, should we use the Order Independent Transparency render more?
|
void |
setProjection(float fov,
float near)
Set Projection Matrix for the Framebuffer contained in this Node.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
adjustIsomorphism
public DistortedNode(org.distorted.library.main.InternalSurface surface, DistortedEffects effects, MeshBase mesh)
surface
- InputSurface to put into the new Node.effects
- DistortedEffects to put into the new Node.mesh
- MeshBase to put into the new Node.public DistortedNode(DistortedNode node, int flags)
node
- The DistortedNode to copy data from.flags
- bit field composed of a subset of the following:
DistortedLibrary.CLONE_SURFACE
, DistortedLibrary.CLONE_MATRIX
, DistortedLibrary.CLONE_VERTEX
,
DistortedLibrary.CLONE_FRAGMENT
and DistortedLibrary.CLONE_CHILDREN
.
For example flags = CLONE_SURFACE | CLONE_CHILDREN.public void markForDeletion()
public void setOrderIndependentTransparency(boolean oit)
There are two modes of rendering: the fast 'normal' way, which however renders transparent fragments in different ways depending on which fragments get rendered first, or the slower 'oit' way, which renders transparent fragments correctly regardless of their order.
oit
- True if we want to render more slowly, but in a way which accounts for transparency.public void setOrderIndependentTransparency(boolean oit, float initialSize)
There are two modes of rendering: the fast 'normal' way, which however renders transparent fragments in different ways depending on which fragments get rendered first, or the slower 'oit' way, which renders transparent fragments correctly regardless of their order.
oit
- True if we want to render more slowly, but in a way which accounts for transparency.initialSize
- Initial number of transparent fragments we expect, in screenfulls.
I.e '1.0' means 'the scene we are going to render contains dialog_about 1 screen
worth of transparent fragments'. Valid values: 0.0 < initialSize < 10.0
Even if you get this wrong, the library will detect that there are more
transparent fragments than it has space for and readjust its internal buffers,
but only after a few frames during which one will probably see missing objects.public void attach(DistortedNode node)
We cannot do this mid-render - actual attachment will be done just before the next render, by the InternalMaster (by calling doWork())
node
- The new Node to add.public DistortedNode attach(org.distorted.library.main.InternalSurface surface, DistortedEffects effects, MeshBase mesh)
We cannot do this mid-render - actual attachment will be done just before the next render, by the InternalMaster (by calling doWork())
surface
- InputSurface to initialize our child Node with.effects
- DistortedEffects to initialize our child Node with.mesh
- MeshBase to initialize our child Node with.public void detach(DistortedNode node)
We cannot do this mid-render - actual detachment will be done just before the next render, by the InternalMaster (by calling doWork())
node
- The Node to remove.public void detach(DistortedEffects effects)
A bit questionable method as there can be many different Nodes attached as children, some of them having the same Effects but - for instance - different Mesh. Use with care.
We cannot do this mid-render - actual detachment will be done just before the next render, by the InternalMaster (by calling doWork())
effects
- DistortedEffects to remove.public void detachAll()
We cannot do this mid-render - actual detachment will be done just before the next render, by the InternalMaster (by calling doWork())
public DistortedEffects getEffects()
public org.distorted.library.main.InternalSurface getSurface()
public MeshBase getMesh()
public void resizeFBO(int width, int height)
public void setProjection(float fov, float near)
If this Node is a Leaf and has no Framebuffer in it, this call does nothing.
fov
- Vertical 'field of view' of the Projection frustrum (in degrees).
Valid values: 0<=fov<180. FOV==0 means 'parallel projection'.near
- The Near plane.public void enableDepthStencil(int depthStencil)
public void glColorMask(boolean r, boolean g, boolean b, boolean a)
r
- Write to the RED color channel when rendering this Node?g
- Write to the GREEN color channel when rendering this Node?b
- Write to the BLUE color channel when rendering this Node?a
- Write to the ALPHA channel when rendering this Node?public void glDepthMask(boolean mask)
mask
- Write to the Depth buffer when rendering this Node?public void glStencilMask(int mask)
mask
- Marks the bits of the Stencil buffer we will write to when rendering this Node.public void glEnable(int test)
test
- Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLENDpublic void glDisable(int test)
test
- Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLENDpublic void glStencilFunc(int func, int ref, int mask)
func
- Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUALref
- Reference valut to compare our stencil with.mask
- Mask used when comparing.public void glStencilOp(int sfail, int dpfail, int dppass)
Valid values of all 3 parameters: GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP
sfail
- What to do when Stencil Test fails.dpfail
- What to do when Depth Test fails.dppass
- What to do when Depth Test passes.public void glDepthFunc(int func)
func
- Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUALpublic void glBlendFunc(int src, int dst)
Valid values: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE
src
- Source Blend functiondst
- Destination Blend functionpublic void glClear(int mask)
Valid values: 0, or bitwise OR of one or more values from the set GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. Default: 0
mask
- bitwise OR of BUFFER_BITs to clear.