go
Class Go

java.lang.Object
  |
  +--go.Go

public class Go
extends java.lang.Object


Field Summary
static int AUTO_NORMAL
           
static int BACKGROUND
           
static int BOUND_BOX
           
static int COLOR
           
static int CONTEXT
           
static int CULL
           
static int DIRECTIONAL
           
static int FEEDBACK
           
static int FLAGS
           
static int FLAT_SHADE
           
static int IMAGE
           
static int LIGHT
           
static int LIGHT_0
           
static int LIGHT_1
           
static int LIGHT_2
           
static int LIGHT_3
           
static int LINE
           
static int MATRIX
           
static int MATRIX_MODE
           
static int MODELVIEW
           
static int NAME
           
static int NONE
           
static int NORMAL
           
static int POSITIONAL
           
static int PROJECTION
           
static int RENDER_MODE
           
static int SELECTION
           
static int TRIANGLE
           
 
Constructor Summary
Go()
          Constructor for a new rendering context.
Go(int width, int height)
          Constructor for a new rendering context.
 
Method Summary
 void background(double r, double g, double b)
          Sets the image background color.
 void background(GoColor color)
          Sets the image background color.
 GoBoundBox boundBox()
          Returns the cumulative bounding box of rendered primitives.
 void clear(int flags)
          Clears the image buffer, selection list, feedback list or cumulative bounding box.
 void color(double r, double g, double b)
          Sets the image foreground color.
 void color(GoColor color)
          Sets the image foreground color.
 void disable(int flags)
          Disable features.
 void enable(int flags)
          Enable features.
 GoFeedback feedback(boolean sort)
          Returns the first item in the feedback list.
 void frustum(double left, double right, double bottom, double top, double zNear, double zFar)
          Multiply the current target matrix (see matrixMode) with a perspective matrix.
 void getBackground(GoColor background)
          Returns the current background value (see background).
 void getColor(GoColor color)
          Returns the current color value (see color).
 int getFlags()
          Returns the current flags value (see enable and disable).
 boolean getLight(int number)
          Returns the on/off state of a light (see light(int, boolean)).
 void getLight(int number, GoLight light)
          Returns information about a light (see light(int, GoLight)).
 void getMatrix(GoMatrix m)
          Returns the current target matrix (see matrixMode).
 int getMatrixMode()
          Returns the current matrix mode value (see matrixMode).
 void getModelview(GoMatrix m)
          Returns the current modelview matrix.
 int getName()
          Returns the current name value (see name).
 void getProjection(GoMatrix m)
          Returns the current projection matrix.
 int getRenderMode()
          Returns the current rendering mode value (see renderMode).
 int height()
          Returns the height of the image rendering context.
 void identity()
          Replace the current target matrix (see matrixMode) with the identity matrix.
 void inverse()
          Replace the current target matrix (see matrixMode) with the matrix inverse of itself.
 void light(int number, boolean enabled)
          Turns a light on or off.
 void light(int number, GoLight light)
          Sets up the direction or position of a light.
 void light(int number, int type, double x, double y, double z)
          Sets up the direction or position of a light.
 void load(GoMatrix m)
          Replace the current target matrix (see matrixMode) with the specified matrix.
 void lookAt(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ)
          Multiply the current target matrix (see matrixMode) with a viewing matrix.
 void matrixMode(int mode)
          Specifies which matrix is the target for any subsequent matrix operations.
 void multiply(GoMatrix m)
          Multiply the current target matrix (see matrixMode) with the specified matrix.
 void name(int name)
          Sets the current name value.
 void ortho(double left, double right, double bottom, double top, double zNear, double zFar)
          Multiply the current target matrix (see matrixMode) with an orthographic matrix.
 void perspective(double fovy, double aspect, double zNear, double zFar)
          Multiply the current target matrix (see matrixMode) with a perspective matrix.
 void pop(int flags)
          Pop specified stacks.
 void push(int flags)
          Push specified stacks.
 void render(GoVertex data)
          Renders a primitive in the current rendering mode.
 void render(GoVertex data, int startIndex, int endIndex)
          Renders a primitive in the current rendering mode.
 void renderMode(int mode)
          Sets the current rendering mode.
 void rotate(double angle, double x, double y, double z)
          Multiply the current target matrix (see matrixMode) with a rotation matrix.
 void scale(double x, double y, double z)
          Multiply the current target matrix (see matrixMode) with a scaling matrix.
 void select(double x, double y, double width, double height)
          Multiply the current target matrix (see matrixMode) with a selection matrix.
 GoSelection selection()
          Returns the first item in the selection list.
 void size(int width, int height)
          Resize the rendering context.
 void translate(double x, double y, double z)
          Multiply the current target matrix (see matrixMode) with a translation matrix.
 int width()
          Returns the width of the image rendering context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE

IMAGE

public static final int IMAGE

SELECTION

public static final int SELECTION

FEEDBACK

public static final int FEEDBACK

BOUND_BOX

public static final int BOUND_BOX

RENDER_MODE

public static final int RENDER_MODE

NORMAL

public static final int NORMAL

AUTO_NORMAL

public static final int AUTO_NORMAL

BACKGROUND

public static final int BACKGROUND

COLOR

public static final int COLOR

NAME

public static final int NAME

LIGHT_0

public static final int LIGHT_0

LIGHT_1

public static final int LIGHT_1

LIGHT_2

public static final int LIGHT_2

LIGHT_3

public static final int LIGHT_3

LIGHT

public static final int LIGHT

MATRIX_MODE

public static final int MATRIX_MODE

MATRIX

public static final int MATRIX

MODELVIEW

public static final int MODELVIEW

PROJECTION

public static final int PROJECTION

CULL

public static final int CULL

FLAT_SHADE

public static final int FLAT_SHADE

FLAGS

public static final int FLAGS

CONTEXT

public static final int CONTEXT

LINE

public static final int LINE

TRIANGLE

public static final int TRIANGLE

POSITIONAL

public static final int POSITIONAL

DIRECTIONAL

public static final int DIRECTIONAL
Constructor Detail

Go

public Go()
Constructor for a new rendering context.

Equivalent to:

Go(0, 0)

Go

public Go(int width,
          int height)
Constructor for a new rendering context.

Creates a rendering context with image size equal to width x height.

Method Detail

size

public void size(int width,
                 int height)
Resize the rendering context.

Sets the image rendering context to size width x height.


width

public int width()
Returns the width of the image rendering context.

height

public int height()
Returns the height of the image rendering context.

renderMode

public void renderMode(int mode)
Sets the current rendering mode.

Possible values for mode are one of:

IMAGE
Primitives are rasterized in the image buffer. This is the default rendering mode.
SELECTION
No rasterization is done, instead a list of names (associated with each primitive rendered) is created. The start of this list can be obtained via the method selection().
FEEDBACK
No rasterization is done, instead a list of lines and triangles (associated with each primitive rendered) is created. The start of this list can be obtained via the method feedback().
BOUND_BOX
No rasterization is done, instead the enclosing bounding box of each primitive rendered is added to the cumulative bounding box. The cumulative bounding box can be obtained via the method boundBox().

render

public void render(GoVertex data)
Renders a primitive in the current rendering mode.

Equivalent to:

render(data, 0, data.vertexNum - 1)

render

public void render(GoVertex data,
                   int startIndex,
                   int endIndex)
Renders a primitive in the current rendering mode.

Render the vertices pointed to by data according it's primitive type. The data index range included starts at startIndex and ends at endindex.

data can be a one of the following GoVertex subclasses:


selection

public GoSelection selection()
Returns the first item in the selection list.

The selection list is generated when the rendering mode is set to SELECTION. To clear the selection list, use the method clear(SELECTION). An example of traversing the selection list is as follows:

for(GoSelection selection = Go.selection();
    selection != null;
    selection = selection.next()) {

    for(int i = 0; i < selection.stackSize(); i++) {
        // process selection.name(i)     } }
clear(SELECTION);

feedback

public GoFeedback feedback(boolean sort)
Returns the first item in the feedback list.

The feedback list is generated when the rendering mode is set to FEEDBACK. If sort is equal to true, then the feedback will be depth sorted, else it will leave it in the order that the primitives were rendered. To clear the feedback list, use the method clear(FEEDBACK). An example of traversing the feedback list is as follows:

for(GoFeedback feedback = Go.feedback(true);
    feedback != null;
    feedback = feedback.next()) {

    // process feedback }
clear(FEEDBACK);

boundBox

public GoBoundBox boundBox()
Returns the cumulative bounding box of rendered primitives.

The cumulative bounding box is generated when the rendering mode is set to BOUND_BOX. This is done by first transforming primitives to object coordinates (i.e. vertices of each primitive are multiplied with the current value of the modelview matrix) and then, if necessary, replacing the minimum and maximum cumulative bounding box values in order to include all rendered primitives. To clear the cumulative bounding box, use the method clear(BOUND_BOX).


clear

public void clear(int flags)
Clears the image buffer, selection list, feedback list or cumulative bounding box.

The bits set in flags determine what is to be cleared.

Possible values for flags are any or'ed combination of:

IMAGE
Clears the image buffer.
SELECTION
Clears the selection list.
FEEDBACK
Clears the feedback list.
BOUND_BOX
Clears the cumulative bounding box.

enable

public void enable(int flags)
Enable features.

The bits set in flags determine what features are to be enabled.

Possible values for flags are any or'ed combination of:

CULL
Enables back facing triangles to be culled (i.e. not rendered). A back facing triangle is a triangle who's projected vertices are defined in a clockwise manner. A front facing triangle is a triangle who's projected vertices are defined in a counterclockwise manner. By default this is disabled.
FLAT_SHADE
Enables shading of lines and triangles to consist of a solid color. By default this is disabled.

disable

public void disable(int flags)
Disable features.

The bits set in flags determine what features are to be disabled.

Possible values for flags are any or'ed combination of:

CULL
Disables back facing triangles to be culled. By default this is disabled.
FLAT_SHADE
Disables shading of lines and triangles to consist of a solid color. By default this is disabled.

light

public void light(int number,
                  boolean enabled)
Turns a light on or off.

The light of interest is specified with number. If enabled is equal to true the light is on, else it is off. All lights are by default off.

Possible values for number are one of:

LIGHT_0
Light number 0.
LIGHT_1
Light number 1.
LIGHT_2
Light number 2.
LIGHT_3
Light number 3.

light

public void light(int number,
                  GoLight light)
Sets up the direction or position of a light.

Equivalent to:

light(number, light.type, light.x, light.y, light.z)

light

public void light(int number,
                  int type,
                  double x,
                  double y,
                  double z)
Sets up the direction or position of a light.

Lights are defined in object coordinates, hence, upon calling this method, the x, y and z are multiplied with the current value of the modelview matrix.

The light of interest is specified with number.

Possible values for number are one of:

LIGHT_0
Light number 0.
LIGHT_1
Light number 1.
LIGHT_2
Light number 2.
LIGHT_3
Light number 3.

The light will be treated as either a directional or positional light, which is specified with type.

Possible values for type are one of:

DIRECTIONAL
Sets up the specified light as a directional light. A directional light treats x, y and z as the lights direction in object coordinates. The light shines opposite to it's direction. By default all lights are directional with an (x, y, z) value of (0, 0, 1), which defines a light positioned at an infinite distance along the positive z-axis and pointed towards the negative z-axis.
POSITIONAL
Sets up the specified light as a positional light. A positional light treats x, y and z as the lights position in object coordinates.

background

public void background(GoColor color)
Sets the image background color.

Equivalent to:

background(color.r, color.g, color.b)

background

public void background(double r,
                       double g,
                       double b)
Sets the image background color.

The image background RGB color value is set to (r, g, b). The background color is used to clear the image buffer when the method clear(IMAGE) is called.

The default background color is set to gray (0.5, 0.5, 0.5).


color

public void color(GoColor color)
Sets the image foreground color.

Equivalent to:

color(color.r, color.g, color.b)

color

public void color(double r,
                  double g,
                  double b)
Sets the image foreground color.

The image foreground RGB color value is set to (r, g, b). The foreground color is used in conjunction with a call to the method:

render(data)
If data contains no color information, then the foreground color is used while rendering data.

The default foreground color is set to white (1.0, 1.0, 1.0).


name

public void name(int name)
Sets the current name value.

The current name value is set to name. This method is usually used in conjunction with selection and feedback rendering modes.

The default name value is set to 0.


matrixMode

public void matrixMode(int mode)
Specifies which matrix is the target for any subsequent matrix operations.

The target is either the modelview matrix or projection matrix.

Possible values for mode are one of:

MODELVIEW
Target matrix will be set to the modelview matrix. This is the default matrix.
PROJECTION
Target matrix will be set to the projection matrix.

load

public void load(GoMatrix m)
Replace the current target matrix (see matrixMode) with the specified matrix.

The current target matrix is replaced with:

 /                        \
| m[0]  m[4]  m[8]   m[12] | 
| m[1]  m[5]  m[9]   m[13] |
| m[2]  m[6]  m[10]  m[14] |
| m[3]  m[7]  m[11]  m[15] |
 \                        /

multiply

public void multiply(GoMatrix m)
Multiply the current target matrix (see matrixMode) with the specified matrix.

If c is the current target matrix, then c will will be replaces with:

 /                        \     /                        \
| c[0]  c[4]  c[8]   c[12] |   | m[0]  m[4]  m[8]   m[12] |
| c[1]  c[5]  c[9]   c[13] | X | m[1]  m[5]  m[9]   m[13] |
| c[2]  c[6]  c[10]  c[14] |   | m[2]  m[6]  m[10]  m[14] |
| c[3]  c[7]  c[11]  c[15] |   | m[3]  m[7]  m[11]  m[15] |
 \                        /     \                        /

identity

public void identity()
Replace the current target matrix (see matrixMode) with the identity matrix.

The current target matrix is replaced with:

 /       \
| 1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
 \       /

inverse

public void inverse()
Replace the current target matrix (see matrixMode) with the matrix inverse of itself.

translate

public void translate(double x,
                      double y,
                      double z)
Multiply the current target matrix (see matrixMode) with a translation matrix.

The translation matrix will be set up internally based on the arguments:

x - units translated along x-axis
y - units translated along y-axis
z - units translated along z-axis

scale

public void scale(double x,
                  double y,
                  double z)
Multiply the current target matrix (see matrixMode) with a scaling matrix.

The scaling matrix will be set up internally based on the arguments:

x - scale factor for x-axis
y - scale factor for y-axis
z - scale factor for z-axis

rotate

public void rotate(double angle,
                   double x,
                   double y,
                   double z)
Multiply the current target matrix (see matrixMode) with a rotation matrix.

The rotation matrix will be set up internally based on the arguments:

angle - degrees to rotate
(x, y, z) - vector to rotate about

ortho

public void ortho(double left,
                  double right,
                  double bottom,
                  double top,
                  double zNear,
                  double zFar)
Multiply the current target matrix (see matrixMode) with an orthographic matrix. This method is usually called when the target matrix is set to the projection matrix.

The orthographic matrix will be set up internally based on the arguments:

left, right - x coordinates specifying left and right vertical clipping planes
bottom, top - y coordinates specifying bottom and top horizontal clipping planes
zNear, zFar - z coordinates specifying the near and far perpendicular clipping planes

frustum

public void frustum(double left,
                    double right,
                    double bottom,
                    double top,
                    double zNear,
                    double zFar)
Multiply the current target matrix (see matrixMode) with a perspective matrix. This method is usually called when the target matrix is set to the projection matrix.

The perspective matrix will be set up internally based on the arguments:

left, right - x coordinates specifying left and right vertical clipping planes
bottom, top - y coordinates specifying bottom and top horizontal clipping planes
zNear, zFar - z coordinates specifying the near and far perpendicular clipping planes

lookAt

public void lookAt(double eyeX,
                   double eyeY,
                   double eyeZ,
                   double centerX,
                   double centerY,
                   double centerZ,
                   double upX,
                   double upY,
                   double upZ)
Multiply the current target matrix (see matrixMode) with a viewing matrix. This method is usually called when the target matrix is set to the modelview matrix.

The viewing matrix will be set up internally based on the arguments:

eyeX, eyeY, eyeZ - position of eye
centerX, centerY, centerZ - center of scene
upX, upY, upZ - up vector

perspective

public void perspective(double fovy,
                        double aspect,
                        double zNear,
                        double zFar)
Multiply the current target matrix (see matrixMode) with a perspective matrix. This method is usually called when the target matrix is set to the projection matrix.

The perspective matrix will be set up internally based on the arguments:

fovy - field of view angle, in degrees, in the y direction
aspect - aspect ratio that determines the field of view in the x direction
zNear, zFar - z coordinates specifying the near and far perpendicular clipping planes

select

public void select(double x,
                   double y,
                   double width,
                   double height)
Multiply the current target matrix (see matrixMode) with a selection matrix. This method is usually called when the target matrix is set to the projection matrix.

The selection matrix will be set up internally based on the arguments:

x, y - center of selection in image coordinates
width, height - width and height of selection in image coordinates

push

public void push(int flags)
Push specified stacks.

The stacks that are to be pushed are indicated by the bit fields in the flags argument.

Possible values for flags are any or'ed combination of:

RENDER_MODE
Push the current render mode value (see renderMode) onto the render mode stack.
FLAGS
Push the current flags value (see enable and disable) onto the flags stack.
LIGHT_0
Push the current state of light number 0 (see light(int, boolean) and light(int, int, double, double, double)) onto the light number 0 stack.
LIGHT_1
Push the current state of light number 1 (see light(int, boolean) and light(int, int, double, double, double)) onto the light number 1 stack.
LIGHT_2
Push the current state of light number 2 (see light(int, boolean) and light(int, int, double, double, double)) onto the light number 2 stack.
LIGHT_3
Push the current state of light number 3 (see light(int, boolean) and light(int, int, double, double, double)) onto the light number 3 stack.
LIGHT
Equivalent to:
LIGHT_0 | LIGHT_1 | LIGHT_2 | LIGHT_3
BACKGROUND
Push the current background value (see background) onto the background stack.
COLOR
Push the current color value (see color) onto the color stack.
NAME
Push the current name value (see name) onto the name stack.
MATRIX_MODE
Push the current matrix mode value (see matrixMode) onto the matrix mode stack.
MATRIX
Push the current target matrix onto the target matrix stack (see matrixMode).
MODELVIEW
Push the current modelview matrix onto the modelview matrix stack.
PROJECTION
Push the current projection matrix onto the projection matrix stack.
CONTEXT
Equivalent to:
RENDER_MODE | FLAGS | LIGHT | BACKGROUND | COLOR |
NAME | MATRIX_MODE | MODELVIEW | PROJECTION

pop

public void pop(int flags)
Pop specified stacks.

The stacks that are to be popped are indicated by the bit fields in the flags argument.

Possible values for flags are any or'ed combination of:

RENDER_MODE
Pop the render mode stack and set the current render mode value (see renderMode) equal to the popped off value.
FLAGS
Pop the flags stack and set the current flags value (see enable and disable) equal to the popped off value.
LIGHT_0
Pop the light number 0 stack and set the current state of light number 0 (see light(int, boolean) and light(int, int, double, double, double)) equal to the popped off value.
LIGHT_1
Pop the light number 1 stack and set the current state of light number 1 (see light(int, boolean) and light(int, int, double, double, double)) equal to the popped off value.
LIGHT_2
Pop the light number 2 stack and set the current state of light number 2 (see light(int, boolean) and light(int, int, double, double, double)) equal to the popped off value.
LIGHT_3
Pop the light number 3 stack and set the current state of light number 3 (see light(int, boolean) and light(int, int, double, double, double)) equal to the popped off value.
LIGHT
Equivalent to:
LIGHT_0 | LIGHT_1 | LIGHT_2 | LIGHT_3
BACKGROUND
Pop the background stack and set the current background value (see background) equal to the popped off value.
COLOR
Pop the color stack and set the current color value (see color) equal to the popped off value.
NAME
Pop the name stack and set the current name value (see name) equal to the popped off value.
MATRIX_MODE
Pop the matrix mode stack and set the current matrix mode value (see matrixMode) equal to the popped off value.
MATRIX
Pop the current matrix stack and set the current target matrix equal to the popped off matrix (see matrixMode).
MODELVIEW
Pop the modelview matrix stack and set the current modelview matrix equal to the popped off matrix.
PROJECTION
Pop the projection matrix stack and set the current projection matrix equal to the popped off matrix.
CONTEXT
Equivalent to:
RENDER_MODE | FLAGS | LIGHT | BACKGROUND | COLOR |
NAME | MATRIX_MODE | MODELVIEW | PROJECTION

getRenderMode

public int getRenderMode()
Returns the current rendering mode value (see renderMode).

getFlags

public int getFlags()
Returns the current flags value (see enable and disable).

getLight

public boolean getLight(int number)
Returns the on/off state of a light (see light(int, boolean)).

The value of number indicates the light of interest. Possible values for number are the same as for light(int, boolean).


getLight

public void getLight(int number,
                     GoLight light)
Returns information about a light (see light(int, GoLight)).

The value of number indicates the light of interest. Possible values for number are the same as for light(int, GoLight).

The argument light is filled in with the light type and direction/position information (see GoLight).


getBackground

public void getBackground(GoColor background)
Returns the current background value (see background).

getColor

public void getColor(GoColor color)
Returns the current color value (see color).

getName

public int getName()
Returns the current name value (see name).

getMatrixMode

public int getMatrixMode()
Returns the current matrix mode value (see matrixMode).

getMatrix

public void getMatrix(GoMatrix m)
Returns the current target matrix (see matrixMode).

getModelview

public void getModelview(GoMatrix m)
Returns the current modelview matrix.

getProjection

public void getProjection(GoMatrix m)
Returns the current projection matrix.