cz.cuni.jagrlib
Class DefaultRender3D

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
          extended by cz.cuni.jagrlib.DefaultRender3D
All Implemented Interfaces:
Breakable, Property, Render, Render3D, Trigger, Template
Direct Known Subclasses:
AntCity, DrawAxes, DrawAxesGL, GLBrepRender, GraphR2ToR, RenderPainter, RenderWireframe

public abstract class DefaultRender3D
extends Piece
implements Render3D, Trigger

Default implementation of Render3D.

Since:
0.25
See Also:
DefaultRender3D.java

Field Summary
protected  TrMatrix compound
          Compound transform matrix (model-view + projection + viewport, modelView .. no transform).
protected  int depthComparison
          Actual depth-test comparison function.
protected  TrMatrix modelView
          Actual model-view matrix (null .. no transform).
protected  boolean mvChanged
          Dirty-flag for the model-view matrix.
protected  boolean prChanged
          Dirty-flag for the projection matrix.
protected  TrMatrix projection
          Actual projection matrix (null .. no transform).
protected  int renderStyle
          Actual rendering style.
protected  int vpHeight
          Viewport height in pixels.
protected  boolean vpChanged
          Dirty-flag for the viewport data.
protected  int vpWidth
          Viewport width in pixels.
protected  int vpX0
          Viewport origin: x-coordinate.
protected  int vpY0
          Viewport origin: y-coordinate.
 
Fields inherited from class cz.cuni.jagrlib.Piece
channels, info, pl, plugs, reg, TEMPLATE_TYPE, userBreak
 
Fields inherited from interface cz.cuni.jagrlib.iface.Render3D
DEPTH_GEQUAL, DEPTH_GREATER, DEPTH_LEQUAL, DEPTH_LESS
 
Fields inherited from interface cz.cuni.jagrlib.iface.Render
LINE_CAP, LINE_CAP_BUTT, LINE_CAP_ROUND, LINE_CAP_SQUARE, LINE_JOIN, LINE_JOIN_BEVEL, LINE_JOIN_DISJOINT, LINE_JOIN_MITER, LINE_JOIN_OVERLAP, LINE_JOIN_ROUND, LINE_WIDTH, PROJECTION, RENDER_STYLE, RENDER_STYLE_FLAT, RENDER_STYLE_GOURAUD, RENDER_STYLE_LINE, RENDER_STYLE_PHONG, RENDER_STYLE_TEXTURE
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Constructor Summary
DefaultRender3D()
           
 
Method Summary
 boolean fire(int type)
          Redraws the image immediately.
 void checkMatrix()
          Asserts validity of the compound matrix.
 void render()
          3D rendering using actual parameters.
 void render(TrMatrix mv, TrMatrix proj, int style)
          3D rendering using the given projection matrix.
 void setDepthComparison(int comp)
          Sets type of depth-test comparison.
 void setModelView(TrMatrix mv)
          Sets actual model-view matrix.
 boolean setProjection(double[] view, double[] up, double[] lookAt, double zoom)
          Sets actual projection parameters (non-mandatory).
 void setProjection(TrMatrix proj)
          Sets actual projection matrix.
 int setRenderStyle(int style)
          Sets actual rendering style.
 void setViewport(int x0, int y0, int width, int height)
          Sets actual viewport size.
 
Methods inherited from class cz.cuni.jagrlib.Piece
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplate, setTemplateDynamic, stop
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, get, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 
Methods inherited from interface cz.cuni.jagrlib.Breakable
setProgressListener, stop
 

Field Detail

renderStyle

protected int renderStyle
Actual rendering style.


modelView

protected TrMatrix modelView
Actual model-view matrix (null .. no transform).


mvChanged

protected boolean mvChanged
Dirty-flag for the model-view matrix.


projection

protected TrMatrix projection
Actual projection matrix (null .. no transform).


prChanged

protected boolean prChanged
Dirty-flag for the projection matrix.


vpX0

protected int vpX0
Viewport origin: x-coordinate.


vpY0

protected int vpY0
Viewport origin: y-coordinate.


vpWidth

protected int vpWidth
Viewport width in pixels.


vpHeight

protected int vpHeight
Viewport height in pixels.


vpChanged

protected boolean vpChanged
Dirty-flag for the viewport data.


compound

protected TrMatrix compound
Compound transform matrix (model-view + projection + viewport, modelView .. no transform).


depthComparison

protected int depthComparison
Actual depth-test comparison function.

Constructor Detail

DefaultRender3D

public DefaultRender3D()
Method Detail

setDepthComparison

public void setDepthComparison(int comp)
Sets type of depth-test comparison.

Specified by:
setDepthComparison in interface Render3D

setRenderStyle

public int setRenderStyle(int style)
Sets actual rendering style.

Specified by:
setRenderStyle in interface Render3D
Parameters:
style - New rendering style.
Returns:
Old rendering style.
See Also:
Render.RENDER_STYLE_LINE, Render.RENDER_STYLE_FLAT

setViewport

public void setViewport(int x0,
                        int y0,
                        int width,
                        int height)
Sets actual viewport size. The same semantics as glSetViewport().

Specified by:
setViewport in interface Render3D
Parameters:
x0 - Viewport origin (x-coord).
y0 - Viewport origin (y-coord).
width - Viewport width in pixels.
height - Viewport height in pixels.
See Also:
Render3D.setProjection(cz.cuni.jagrlib.TrMatrix)

setModelView

public void setModelView(TrMatrix mv)
Sets actual model-view matrix.

Specified by:
setModelView in interface Render3D
Parameters:
mv - New model-view matrix.

setProjection

public void setProjection(TrMatrix proj)
Sets actual projection matrix.

Specified by:
setProjection in interface Render3D
Parameters:
proj - New projection matrix.
See Also:
Render3D.setViewport(int, int, int, int)

setProjection

public boolean setProjection(double[] view,
                             double[] up,
                             double[] lookAt,
                             double zoom)
Sets actual projection parameters (non-mandatory).

Specified by:
setProjection in interface Render3D
Parameters:
view - Viewing vector (from camera to the scene).
up - Up vector (should always point up on the screen).
lookAt - Point in the middle of the view.
zoom - Zoom factor (camera - lookAt distance, element size on the screen, etc.).
Returns:
true if the method is implemented.

checkMatrix

public void checkMatrix()
Asserts validity of the compound matrix.


render

public void render()
3D rendering using actual parameters.

Specified by:
render in interface Render3D
See Also:
setModelView(TrMatrix), setProjection(TrMatrix), setRenderStyle(int), render(TrMatrix,TrMatrix,int)

render

public void render(TrMatrix mv,
                   TrMatrix proj,
                   int style)
3D rendering using the given projection matrix.

Specified by:
render in interface Render3D
Parameters:
mv - Local model-view matrix.
proj - Local projection matrix.
style - Local rendering style.
See Also:
render()

fire

public boolean fire(int type)
Redraws the image immediately.

Specified by:
fire in interface Trigger
Parameters:
type - The action type (whatever it means..).
Returns:
true if the action was successful.