render
Class RenderCore

java.lang.Object
  extended byrender.RenderCore
All Implemented Interfaces:
java.lang.Runnable

public class RenderCore
extends java.lang.Object
implements java.lang.Runnable


Constructor Summary
RenderCore(RenderablePanel parentComponent)
          METHODS
 
Method Summary
 void addLight(double x, double y, double z, double r, double g, double b)
          Adds light source with direction (x, y, z) & color (r, g, b).
 Widget addMenu(java.lang.String label, int x, int y)
           
 void addMenu(Widget menu)
           
 void damage()
          Forces a refresh of the renderer.
 double getCurrentTime()
          Get the current system time in seconds
 double getFL()
          gets the camera's focal length.
 double getFOV()
          gets the field of view value.
 Geometry getGeometry(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).
 boolean getGeometryBuffer()
           
 int getLod()
           
 Matrix[] getMatrix()
           
 int[] getPix()
          returns the pix array
 boolean getPoint(int x, int y, double[] xyz)
          Returns xyz world coords of the frontmost object at pixel (x,y)
 Renderable getRenderable()
           
 Renderer getRenderer()
           
 Geometry getWorld()
           
 void identity()
          Sets current matrix to the identity matrix.
 void init()
          Initializes the applet and internal variables.
 boolean keyUp(java.awt.Event event, int key)
           
 Matrix m()
          Returns the matrix at the top of the stack.
 Widget menu(int i)
           
 boolean mouseDown(java.awt.Event event, int x, int y)
          Listener for mouse down.
 boolean mouseDrag(java.awt.Event event, int x, int y)
          Dragging the mouse causes gradual view rotation in the phi and theta directions.
 boolean mouseMove(java.awt.Event event, int x, int y)
          Listener for mouse movement.
 boolean mouseUp(java.awt.Event event, int x, int y)
          Listens for mouse release and controls aspects of the renderer.
 void pause()
          prevents the renderer from redrawing the scene.
 void pop()
          Pops the top matrix from the stack.
 boolean processCommand(int key)
          Keyboard listener: various default control keys to modify render style (Use CTRL + key).
 int pull(Geometry s, double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)
          Deforms a geometric shape according to the beginning, middle, and end parameters in each dimension.
 void push()
          Pushes a copy of the top matrix onto the stack.
 void removeMenu(Widget menu)
           
 void rotateX(double t)
          Rotates the top matrix around the X axis by angle t (radians).
 void rotateY(double t)
          Rotates the top matrix around the Y axis by angle t (radians).
 void rotateZ(double t)
          Rotates the top matrix around the Z axis by angle t (radians).
 void run()
          Renderer thread
 void scale(double x, double y, double z)
          Scales the top matrix by x, y, z in their respective dimensions.
 void setFL(double value)
          Sets the camera's focal length.
 void setFOV(double value)
          Sets the field of view value.
 void setGeometryBuffer(boolean value)
           
 void setLod(int value)
           
 void setRenderable(Renderable renderable)
           
 void setRenderer(Renderer renderer)
           
 void start()
          Starts the renderer thread.
 void stop()
          Stops the renderer thread.
 void transform(Geometry s)
          Applies the top transformation matrix to Geometrys.
 void translate(double[] v)
          Translates the top matrix by vector v.
 void translate(double x, double y, double z)
          Translates the top matrix by x, y, z.
 void update(java.awt.Graphics g)
          Updates the image buffer to output device.
 Widget widgetAt(int x, int y)
          Find the widget at the mouse.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderCore

public RenderCore(RenderablePanel parentComponent)
METHODS

Method Detail

init

public void init()
Initializes the applet and internal variables. To initialize components of the application program use #initialize().

See Also:
#initialize()

getCurrentTime

public double getCurrentTime()
Get the current system time in seconds


pause

public void pause()
prevents the renderer from redrawing the scene.


damage

public void damage()
Forces a refresh of the renderer. Sets isDamage true.


setFOV

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

Parameters:
value -
See Also:
Renderer.setFOV(double value)

setFL

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

Parameters:
value - focal length
See Also:
Renderer.setFL(double value)

getFOV

public double getFOV()
gets the field of view value.

See Also:
Renderer#getFOV(double value)

getFL

public double getFL()
gets the camera's focal length.

See Also:
Renderer.setFL(double value)

getPix

public int[] getPix()
returns the pix array

Returns:
See Also:
#pix

getPoint

public boolean getPoint(int x,
                        int y,
                        double[] xyz)
Returns xyz world coords of the frontmost object at pixel (x,y)

Parameters:
x - x pixel coordinate
y - y pixel coordinate
xyz - output point in world coords
Returns:
true iff not a background pixel

getGeometry

public Geometry getGeometry(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

widgetAt

public Widget widgetAt(int x,
                       int y)
Find the widget at the mouse.

Returns:
widget at mouse or null

addLight

public void addLight(double x,
                     double y,
                     double z,
                     double r,
                     double g,
                     double b)
Adds light source with direction (x, y, z) & color (r, g, b). Arguments x,y,z indicate light direction. Arguments r,g,b indicate light direction.

See Also:
Renderer.addLight(double x,double y,double z, double r,double g,double b)

getMatrix

public Matrix[] getMatrix()
Returns:
matrix stack

identity

public void identity()
Sets current matrix to the identity matrix.


m

public Matrix m()
Returns the matrix at the top of the stack.

Returns:
the top matrix on the stack

pop

public void pop()
Pops the top matrix from the stack.


push

public void push()
Pushes a copy of the top matrix onto the stack.


rotateX

public void rotateX(double t)
Rotates the top matrix around the X axis by angle t (radians).

Parameters:
t - angle in radians

rotateY

public void rotateY(double t)
Rotates the top matrix around the Y axis by angle t (radians).

Parameters:
t - angle in radians

rotateZ

public void rotateZ(double t)
Rotates the top matrix around the Z axis by angle t (radians).

Parameters:
t - angle in radians

scale

public void scale(double x,
                  double y,
                  double z)
Scales the top matrix by x, y, z in their respective dimensions.

Parameters:
x - x scale factor
y - y scale factor
z - z scale factor

transform

public void transform(Geometry s)
Applies the top transformation matrix to Geometrys.

Parameters:
s - Geometry object

translate

public void translate(double[] v)
Translates the top matrix by vector v.

Parameters:
v - an array of three doubles representing translations in the x,y,z directions.

translate

public void translate(double x,
                      double y,
                      double z)
Translates the top matrix by x, y, z.

Parameters:
x - - translation in the x direction.
y - - translation in the y direction.
z - - translation in the z direction.

pull

public int pull(Geometry s,
                double x0,
                double x1,
                double x2,
                double y0,
                double y1,
                double y2,
                double z0,
                double z1,
                double z2)
Deforms a geometric shape according to the beginning, middle, and end parameters in each dimension. For each dimesion the three parameters indicate the amount of deformation at each position.

0 - beginning, 1 - middle, 2 - end. To indicate infinity (a constant transformation) set two adjacent parameters to the same value. Setting all three parameters to the same value transforms the shape geometry consistently across the entire axis of the parameters.

Parameters:
s - shape object to be deformed
x0 - location of beginning of deformation along the x axis
x1 - location of beginning of deformation along the x axis
x2 - location of beginning of deformation along the x axis
y0 - location of beginning of deformation along the y axis
y1 - location of beginning of deformation along the y axis
y2 - location of beginning of deformation along the y axis
z0 - location of beginning of deformation along the z axis
z1 - location of beginning of deformation along the z axis
z2 - location of beginning of deformation along the z axis
Returns:
1 if pull operation was successful, 0 otherwise
See Also:
Geometry.pull(render.Matrix, double, double, double, double, double, double, double, double, double)

getWorld

public Geometry getWorld()
Returns:
root world #Geometry

addMenu

public Widget addMenu(java.lang.String label,
                      int x,
                      int y)

addMenu

public void addMenu(Widget menu)

menu

public Widget menu(int i)

removeMenu

public void removeMenu(Widget menu)

start

public void start()
Starts the renderer thread.


stop

public void stop()
Stops the renderer thread.


run

public void run()
Renderer thread

Specified by:
run in interface java.lang.Runnable

update

public void update(java.awt.Graphics g)
Updates the image buffer to output device.

Parameters:
g - Specifies the output device.

mouseMove

public boolean mouseMove(java.awt.Event event,
                         int x,
                         int y)
Listener for mouse movement. If mouse is placed in the lower left cornder it displays the framerate.

Returns:
true

mouseDown

public boolean mouseDown(java.awt.Event event,
                         int x,
                         int y)
Listener for mouse down. Mouse down starts a view rotation.

Returns:
true

mouseUp

public boolean mouseUp(java.awt.Event event,
                       int x,
                       int y)
Listens for mouse release and controls aspects of the renderer.

A release in the upper left corner toggles Renderer.tableMode.

A release in the upper right corner toggle visibility of the Material#tabledisplay. When true, the current material table is displayed in the upper left corner of the window. Position of the mouse determines current material.

A release in the lower right toggles Renderer.showMesh

Parameters:
event - Event
x - current x coordinate
y - current y coordinate
Returns:
true

mouseDrag

public boolean mouseDrag(java.awt.Event event,
                         int x,
                         int y)
Dragging the mouse causes gradual view rotation in the phi and theta directions.

Parameters:
event - Event
x - - new x coordinate
y - - new y coordinate

processCommand

public boolean processCommand(int key)
Keyboard listener: various default control keys to modify render style (Use CTRL + key).

'e' - toggles Renderer.showMesh, that just displays the shapes as mesh wireframes
'l' - toggles Renderer.getOutline()which produces a sketch-line drawing rendition of the scene
'm' - toggles Renderer.seeMeshwhich determines mesh visibility
't' - toggles global texture manipulation method (MIP on/off) (@link Texture#useMIP)

Parameters:
key - value of the key released
Returns:
true if one of the above keys was just released, false otherwise.

keyUp

public boolean keyUp(java.awt.Event event,
                     int key)

getRenderable

public Renderable getRenderable()
Returns:
Returns the renderable.

setRenderable

public void setRenderable(Renderable renderable)
Parameters:
renderable - The renderable to set.

getRenderer

public Renderer getRenderer()
Returns:
Returns the renderer.

setRenderer

public void setRenderer(Renderer renderer)
Parameters:
renderer - The renderer to set.

setLod

public void setLod(int value)

getLod

public int getLod()

getGeometryBuffer

public boolean getGeometryBuffer()
Returns:
Returns the status of the geometry z-buffer.

setGeometryBuffer

public void setGeometryBuffer(boolean value)
Parameters:
value - enables or disables the geometry z-buffer.