render
Class Renderer

java.lang.Object
  extended byrender.Renderer

public class Renderer
extends java.lang.Object

Provides the computational functionality to render geometric objects in realtime.


Field Summary
 boolean bufferg
          Flag that determines whether to keep a z-buffer of geometries, to to know the frontmost object at any position (x, y) in the image.
protected  int H
           
 boolean isHeadsUp
          Determines whether the camera tries to maintain a "heads up" orientation.
 int lod
          Set the level of detail for meshes.
protected  int[] pix
           
 boolean seeMesh
          When set true, only the wireframe structure of the objects is displayed using appropriate colors.
 boolean showMesh
          Shows/overlays the geometry mesh in black when true.
static boolean tableMode
          Flag controls table lookup mode for materials, true means on.
 boolean updateTransparency
          Allocate space for transparent objects when true.
protected  int W
           
 
Constructor Summary
Renderer()
           
 
Method Summary
 void addLight(double x, double y, double z, double r, double g, double b)
          Add a light source where x,y,z are light source direction; r,g,b are light source color.
 void colorLight(int i, double r, double g, double b)
          Assigns new color values to the light i.
 Matrix getCamera()
          Returns the matrix that defines the camera transformation.
 Geometry getGZbuffer(int x, int y)
          Returns the Geometry of the frontmost object at the point (x, y) in the image (like a z-buffer value of geometries).
 int getNumberOfLights()
          Returns the number of lights in the scene.
 double getOutline()
          Returns the outline threshold parameter for sketch-like (artistic) rendition of the scene.
 Geometry getWorld()
          Returns the root of the geometry tree.
 void headsUp(boolean tf)
          Sets whether the camera tries to maintain a "heads up" orientation.
 int[] init(int W, int H)
          Initializes the renderer.
static boolean isDragging()
          Returns whether dragging is active or not.
 void outline(double t)
          Thresholds t to produce a sketch-like (artistic) rendition of the scene.
 void placeLight(int i, double x, double y, double z)
          Moves an already defined light i, to point in the new direction of normalized [x, y, z].
 void refresh()
          Force a refresh of the entire window.
 void render()
          Render the entire world for this frame.
static void renderVertex(double[] v, Material m)
          Renders vertex v with material m, if table mode is enabled the data is just looked up in the material's table, otherwise it is computed.
static void renderVertex(int i, Material m)
          Renders vertex i ( packed x,y,z) with material m.
 void rotateView(double t, double p)
          Rotate angle of view.
 void setBgColor(double r, double g, double b)
          Set the background fill color.
 void setCamera(double theta, double phi)
          Forces an absolute value for the camera matrix.
 void setCamera(Matrix m)
          Sets the camera matrix directly.
static void setDragging(boolean tf)
          If the user is interactively dragging the mouse, we want the renderer to know about it, so that any other background process (eg: a material which is building a lookup table) can ask the renderer, and thereby avoid consuming scarce CPU resources simultaneously.
 void setFL(double value)
          Sets the camera's focal length.
 void setFOV(double value)
          Sets the camera field of view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableMode

public static boolean tableMode
Flag controls table lookup mode for materials, true means on.


lod

public int lod
Set the level of detail for meshes.


showMesh

public boolean showMesh
Shows/overlays the geometry mesh in black when true.


updateTransparency

public boolean updateTransparency
Allocate space for transparent objects when true.


bufferg

public boolean bufferg
Flag that determines whether to keep a z-buffer of geometries, to to know the frontmost object at any position (x, y) in the image.

See Also:
getGZbuffer(int x, int y)

isHeadsUp

public boolean isHeadsUp
Determines whether the camera tries to maintain a "heads up" orientation.


seeMesh

public boolean seeMesh
When set true, only the wireframe structure of the objects is displayed using appropriate colors.


W

protected int W

H

protected int H

pix

protected int[] pix
Constructor Detail

Renderer

public Renderer()
Method Detail

init

public int[] init(int W,
                  int H)
Initializes the renderer.

Parameters:
W - framebuffer width
H - framebuffer height.
Returns:
framebuffer array.

setDragging

public static void setDragging(boolean tf)
If the user is interactively dragging the mouse, we want the renderer to know about it, so that any other background process (eg: a material which is building a lookup table) can ask the renderer, and thereby avoid consuming scarce CPU resources simultaneously.

Parameters:
tf - dragging true or false

isDragging

public static boolean isDragging()
Returns whether dragging is active or not.

Returns:
true when dragging is active, false otherwise

setCamera

public void setCamera(double theta,
                      double phi)
Forces an absolute value for the camera matrix.

Parameters:
theta - horizontal angle (radians)
phi - vertical angle (radians)

headsUp

public void headsUp(boolean tf)
Sets whether the camera tries to maintain a "heads up" orientation.

Parameters:
tf - value true or false

setFL

public void setFL(double value)
Sets the camera's focal length.

Parameters:
value - focal lengh

setFOV

public void setFOV(double value)
Sets the camera field of view.

Parameters:
value - field of view

getWorld

public Geometry getWorld()
Returns the root of the geometry tree.

Returns:
the root of the geometry tree.

setBgColor

public void setBgColor(double r,
                       double g,
                       double b)
Set the background fill color.


addLight

public void addLight(double x,
                     double y,
                     double z,
                     double r,
                     double g,
                     double b)
Add a light source where x,y,z are light source direction; r,g,b are light source color.


getNumberOfLights

public int getNumberOfLights()
Returns the number of lights in the scene.

Returns:
the number of lights

placeLight

public void placeLight(int i,
                       double x,
                       double y,
                       double z)
Moves an already defined light i, to point in the new direction of normalized [x, y, z].

Parameters:
i - the index of the light to be changed
x - x direction of the light
y - y direction of the light
z - z direction of the light

colorLight

public void colorLight(int i,
                       double r,
                       double g,
                       double b)
Assigns new color values to the light i.

Parameters:
i - index of the light to change
r - the red color component value
g - the green color component
b - the blue color component

rotateView

public void rotateView(double t,
                       double p)
Rotate angle of view.


getCamera

public Matrix getCamera()
Returns the matrix that defines the camera transformation.

Returns:
the matrix that defines the camera transformation

setCamera

public void setCamera(Matrix m)
Sets the camera matrix directly. Matrix needs to be 4x4.


render

public void render()
Render the entire world for this frame.


getOutline

public double getOutline()
Returns the outline threshold parameter for sketch-like (artistic) rendition of the scene.


outline

public void outline(double t)
Thresholds t to produce a sketch-like (artistic) rendition of the scene.

Parameters:
t - outline threshold

refresh

public void refresh()
Force a refresh of the entire window.


renderVertex

public static void renderVertex(int i,
                                Material m)
Renders vertex i ( packed x,y,z) with material m.

Parameters:
i - vertex to be rendered
m - material properties to be applied to the vertex

renderVertex

public static void renderVertex(double[] v,
                                Material m)
Renders vertex v with material m, if table mode is enabled the data is just looked up in the material's table, otherwise it is computed.

Parameters:
v - vertex x,y,z and the r,g,b values for it.
m - material with which to render the vertex.

getGZbuffer

public Geometry getGZbuffer(int x,
                            int y)
Returns the Geometry of the frontmost object at the point (x, y) in the image (like a z-buffer value of geometries).

Parameters:
x - x coordinate in the image
y - y coordinate in the image
Returns:
the geometry of the foremost object at that location