public class

Graphics

extends Object
java.lang.Object
   ↳ casmi.graphics.Graphics

Class Overview

Wrapper of JOGL to make it easy to use.

Summary

Nested Classes
enum Graphics.MatrixMode  
Public Constructors
Graphics(GL2 gl, GLU glu, GLUT glut, int width, int height)
Public Methods
void applyMatrix(double[] n)
Applies the transformation matrix.
void applyMatrix(DoubleBuffer n)
void beginShape()
Starts to draw polygon.
void clear()
void disableTexture(Texture image)
Disables texture.
void enableTexture(Texture image)
Enables texture.
void endShape()
Ends to draw polygon.
double getAlpha()
GL2 getGL()
GLU getGLU()
GLUT getGLUT()
int getHeight()
Returns the height of the display window.
int getWidth()
Returns the width of the display window.
void loadMatrix(DoubleBuffer n)
void loadMatrix(double[] n)
Loads the transformation matrix.
void matrixMode(Graphics.MatrixMode mode)
Sets the MatrixMode.
void popMatrix()
Replaces the current transformation matrix with the top of the stack.
void pushMatrix()
Pushes a copy of the current transformation matrix onto the stack.
void render(Renderable r, boolean selection)
void resetMatrix()
Resets the current transformation matrix.
void rotate(double angle, double vx, double vy, double vz)
Rotates about a vector in space.
void rotateX(double angle)
Rotates around the X axis.
void rotateY(double angle)
Rotates around the Y axis.
void rotateZ(double angle)
Rotates around the Z axis.
void scale(double s)
Scales in all dimensions.
void scale(double sx, double sy)
Scales in X and Y.
void scale(double sx, double sy, double sz)
Scales in X ,Y and Z.
void setAlpha(double alpha)
void setAmbientLight(Color color, boolean enableColor, Vector3D v)
Sets the color value and the position of the ambientLight
void setAmbientLight(float r, float g, float b, Vector3D v)
Sets the RGB value and the position of the ambientLight
void setAmbientLight(int i, float r, float g, float b, float x, float y, float z)
Sets the RBG value and the position of the No.i ambientLight
void setAmbientLight(float r, float g, float b, float x, float y, float z)
Sets the RGB value and the position of the ambientLight
void setAmbientLight(int i, Color color, boolean enableColor, Vector3D v)
Sets the color value and the position of the No.i ambientLight
void setAmbientLight(int i, float r, float g, float b)
Sets the RGB value of the No.i ambientLight
void setAmbientLight(int i, float r, float g, float b, Vector3D v)
Sets the RBG value and the position of the No.i ambientLight
void setAmbientLight(int i, Color color, boolean enableColor)
Sets the color value of the No.i ambientLight
void setAmbientLight(float r, float g, float b)
Sets the RGB value of the ambientLight
void setAmbientLight(Color color)
Sets the color value of the ambientLight
void setBackgroud(Color color)
Sets the background to a RGB or HSB and alpha value.
void setBackground(float x, float y, float z, float a)
Sets the background to a RGB and alpha value.
void setBackground(float gray)
Sets the background to a grayscale value.
void setBackground(float x, float y, float z)
Sets the background to a RGB and value.
void setBackground(float gray, float alpha)
Sets the background to a grayscale value.
void setBackground(ColorSet colorset)
void setCamera()
Sets the default camera position.
void setCamera(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ)
Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward.
void setColor(float gray)
void setColor(Color color)
void setColor(int x, int y, int z)
void setColor(int x, int y, int z, int a)
void setDirectionalLight(int i, Color color, boolean enableColor, Vector3D v)
Sets the color value and the position of the No.i directionalLight
void setDirectionalLight(int i, Color color, boolean enableColor, float x, float y, float z)
Sets the color value and the position of the No.i directionalLight
void setFrustum()
void setFrustum(double left, double right, double bottom, double top, double near, double far)
Sets a perspective matrix defined through the parameters.
void setHeight(int height)
Sets the height of the display window.
void setJustFrustum()
void setJustFrustum(double left, double right, double bottom, double top, double near, double far)
void setJustOrtho()
void setJustOrtho(double left, double right, double bottom, double top, double near, double far)
void setJustPerspective()
void setJustPerspective(double fov, double aspect, double zNear, double zFar)
void setLightAttenuation(int i, float constant, float liner, float quadratic)
Set attenuation rates for point lights, spot lights, and ambient lights.
void setLightDiffuse(int i, Color color)
Sets the diffuse color for No.i light.
void setLightSpecular(int i, Color color)
Sets the specular color for No.i light.
void setOrtho()
Sets the default orthographic projection.
void setOrtho(double left, double right, double bottom, double top, double near, double far)
Sets an orthographic projection and defines a parallel clipping volume.
void setPerspective(double fov, double aspect, double zNear, double zFar)
Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones.
void setPerspective()
Sets a default perspective.
void setPointLight(int i, Color color, boolean enableColor, Vector3D v)
Sets the color value and the position of the No.i pointLight
void setPointLight(int i, Color color, boolean enableColor, float x, float y, float z)
Sets the color value and the position of the No.i pointLight
void setSpotLight(int i, Color color, boolean enableColor, Vector3D v, float nx, float ny, float nz, float angle)
Sets the color value, position, direction and the angle of the spotlight cone of the No.i spotLight
void setVertex(Vector3D v, float nx, float ny)
Sets texture vertex(nx,ny) at position v.
void setVertex(float x, float y, float z, float nx, float ny)
Sets texture vertex(nx,ny) at position(x,y,z).
void setVertex(float x, float y, float nx, float ny)
Sets texture vertex(nx,ny) at position(x,y).
void setWidth(int width)
Sets the width of the display window.
void translate(double tx, double ty, double tz)
Translates in X, Y and Z.
void translate(double tx, double ty)
Translates in X and Y.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Graphics (GL2 gl, GLU glu, GLUT glut, int width, int height)

Public Methods

public void applyMatrix (double[] n)

Applies the transformation matrix.

public void applyMatrix (DoubleBuffer n)

public void beginShape ()

Starts to draw polygon.

public void clear ()

public void disableTexture (Texture image)

Disables texture.

public void enableTexture (Texture image)

Enables texture.

public void endShape ()

Ends to draw polygon.

public double getAlpha ()

public GL2 getGL ()

public GLU getGLU ()

public GLUT getGLUT ()

public int getHeight ()

Returns the height of the display window.

public int getWidth ()

Returns the width of the display window.

public void loadMatrix (DoubleBuffer n)

public void loadMatrix (double[] n)

Loads the transformation matrix.

public void matrixMode (Graphics.MatrixMode mode)

Sets the MatrixMode.

Parameters
mode Either PROJECTION or MODELVIEW

public void popMatrix ()

Replaces the current transformation matrix with the top of the stack.

public void pushMatrix ()

Pushes a copy of the current transformation matrix onto the stack.

public void render (Renderable r, boolean selection)

public void resetMatrix ()

Resets the current transformation matrix.

public void rotate (double angle, double vx, double vy, double vz)

Rotates about a vector in space. Same as the glRotated() function.

public void rotateX (double angle)

Rotates around the X axis.

public void rotateY (double angle)

Rotates around the Y axis.

public void rotateZ (double angle)

Rotates around the Z axis.

public void scale (double s)

Scales in all dimensions.

public void scale (double sx, double sy)

Scales in X and Y. Equivalent to scale(sx, sy, 1).

public void scale (double sx, double sy, double sz)

Scales in X ,Y and Z.

public void setAlpha (double alpha)

public void setAmbientLight (Color color, boolean enableColor, Vector3D v)

Sets the color value and the position of the ambientLight

public void setAmbientLight (float r, float g, float b, Vector3D v)

Sets the RGB value and the position of the ambientLight

public void setAmbientLight (int i, float r, float g, float b, float x, float y, float z)

Sets the RBG value and the position of the No.i ambientLight

public void setAmbientLight (float r, float g, float b, float x, float y, float z)

Sets the RGB value and the position of the ambientLight

public void setAmbientLight (int i, Color color, boolean enableColor, Vector3D v)

Sets the color value and the position of the No.i ambientLight

public void setAmbientLight (int i, float r, float g, float b)

Sets the RGB value of the No.i ambientLight

public void setAmbientLight (int i, float r, float g, float b, Vector3D v)

Sets the RBG value and the position of the No.i ambientLight

public void setAmbientLight (int i, Color color, boolean enableColor)

Sets the color value of the No.i ambientLight

public void setAmbientLight (float r, float g, float b)

Sets the RGB value of the ambientLight

public void setAmbientLight (Color color)

Sets the color value of the ambientLight

public void setBackgroud (Color color)

Sets the background to a RGB or HSB and alpha value.

Parameters
color The RGB or HSB value of the background.

public void setBackground (float x, float y, float z, float a)

Sets the background to a RGB and alpha value.

Parameters
x The R value of the background.
y The G value of the background.
z The B value of the background.
a The alpha opacity of the background.

public void setBackground (float gray)

Sets the background to a grayscale value.

Parameters
gray The grayscale value of the background.

public void setBackground (float x, float y, float z)

Sets the background to a RGB and value.

Parameters
x The R value of the background.
y The G value of the background.
z The B value of the background.

public void setBackground (float gray, float alpha)

Sets the background to a grayscale value.

Parameters
gray The grayscale value of the background.
alpha The alpha opacity of the background.

public void setBackground (ColorSet colorset)

public void setCamera ()

Sets the default camera position.

public void setCamera (double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ)

Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward. Moving the eye position and the direction it is pointing (the center of the scene) allows the images to be seen from different angles.

Parameters
eyeX x-coordinate for the eye
eyeY y-coordinate for the eye
eyeZ z-coordinate for the eye
centerX x-coordinate for the center of the scene
centerY x-coordinate for the center of the scene
centerZ z-coordinate for the center of the scene
upX usually 0.0, 1.0, or -1.0
upY usually 0.0, 1.0, or -1.0
upZ usually 0.0, 1.0, or -1.0

public void setColor (float gray)

public void setColor (Color color)

public void setColor (int x, int y, int z)

public void setColor (int x, int y, int z, int a)

public void setDirectionalLight (int i, Color color, boolean enableColor, Vector3D v)

Sets the color value and the position of the No.i directionalLight

public void setDirectionalLight (int i, Color color, boolean enableColor, float x, float y, float z)

Sets the color value and the position of the No.i directionalLight

public void setFrustum ()

public void setFrustum (double left, double right, double bottom, double top, double near, double far)

Sets a perspective matrix defined through the parameters. Works like glFrustum, except it wipes out the current perspective matrix rather than multiplying itself with it.

Parameters
left left coordinate of the clipping plane
right right coordinate of the clipping plane
bottom bottom coordinate of the clipping plane
top top coordinate of the clipping plane
near near component of the clipping plane
far far component of the clipping plane

public void setHeight (int height)

Sets the height of the display window.

public void setJustFrustum ()

public void setJustFrustum (double left, double right, double bottom, double top, double near, double far)

public void setJustOrtho ()

public void setJustOrtho (double left, double right, double bottom, double top, double near, double far)

public void setJustPerspective ()

public void setJustPerspective (double fov, double aspect, double zNear, double zFar)

public void setLightAttenuation (int i, float constant, float liner, float quadratic)

Set attenuation rates for point lights, spot lights, and ambient lights.

public void setLightDiffuse (int i, Color color)

Sets the diffuse color for No.i light.

public void setLightSpecular (int i, Color color)

Sets the specular color for No.i light.

public void setOrtho ()

Sets the default orthographic projection.

public void setOrtho (double left, double right, double bottom, double top, double near, double far)

Sets an orthographic projection and defines a parallel clipping volume. All objects with the same dimension appear the same size, regardless of whether they are near or far from the camera. The parameters to this function specify the clipping volume where left and right are the minimum and maximum x values, top and bottom are the minimum and maximum y values, and near and far are the minimum and maximum z values.

Parameters
left left plane of the clipping volume
right right plane of the clipping volume
bottom bottom plane of the clipping volume
top top plane of the clipping volume
near maximum distance from the origin to the viewer
far maximum distance from the origin away from the viewer

public void setPerspective (double fov, double aspect, double zNear, double zFar)

Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones. The parameters define a viewing volume with the shape of truncated pyramid. Objects near to the front of the volume appear their actual size, while farther objects appear smaller. This projection simulates the perspective of the world more accurately than orthographic projection.

Parameters
fov field-of-view angle for vertical direction
aspect ratio of width to height
zNear z-position of nearest clipping plane
zFar z-position of nearest farthest plane

public void setPerspective ()

Sets a default perspective.

public void setPointLight (int i, Color color, boolean enableColor, Vector3D v)

Sets the color value and the position of the No.i pointLight

public void setPointLight (int i, Color color, boolean enableColor, float x, float y, float z)

Sets the color value and the position of the No.i pointLight

public void setSpotLight (int i, Color color, boolean enableColor, Vector3D v, float nx, float ny, float nz, float angle)

Sets the color value, position, direction and the angle of the spotlight cone of the No.i spotLight

public void setVertex (Vector3D v, float nx, float ny)

Sets texture vertex(nx,ny) at position v.

public void setVertex (float x, float y, float z, float nx, float ny)

Sets texture vertex(nx,ny) at position(x,y,z).

public void setVertex (float x, float y, float nx, float ny)

Sets texture vertex(nx,ny) at position(x,y).

public void setWidth (int width)

Sets the width of the display window.

public void translate (double tx, double ty, double tz)

Translates in X, Y and Z.

public void translate (double tx, double ty)

Translates in X and Y.