org.gwoptics.graphics.camera
Class Camera3D

java.lang.Object
  extended by org.gwoptics.graphics.camera.Camera3D
All Implemented Interfaces:
processing.core.PConstants

public final class Camera3D
extends java.lang.Object
implements processing.core.PConstants

Camera3D is a camera class designed to be integrated into a processing sketch with minimal effort. This camera setup is specifically useful for 'orbiting' around an object that is to be viewed. Rather than applying the PApplet rotateX,rotateY and rotateZ, it uses matrix transformation to alter the position of the camera in the world space.

To use the camera simply import the class and create a new Camera3D object. The class will register itself with the parent applet for draw() calls, and internally handles mouse events for rotations.

History
Version 0.3.8 Added some static members to allow access too the various position, lookat and up vectors of the camera.

Version 0.3.5 Orthographic view is added to camera class, can now be set using the setOthographicView and setPerpectiveView methods

Since:
0.3.0
Author:
Daniel Brown 19/6/09

Field Summary
 
Fields inherited from interface processing.core.PConstants
AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
Camera3D(processing.core.PApplet parent)
          Sets default values of camera position to <100,100,100> and look at position to <0,0,0>.
Camera3D(processing.core.PApplet parent, boolean registerMouseEvents)
          Sets default camera properties as normal constructor but allows you to disable mouse events for a static camera.
 
Method Summary
 void dispose()
           
 void draw()
           
static processing.core.PVector getEyeVector()
          Gets a normalised vector stating the direction the camera is facing.
 float getFarLimit()
          Gets the furthest distance the camera can get to its lookat point
static processing.core.PVector getLookat()
          Gets the point the camera is looking at
 float getNearLimit()
          Gets the nearest distance the camera can get to its lookat point
static processing.core.PVector getPosition()
          Gets the position of the camera
static processing.core.PVector getRelativePosition()
          Gets the position of the camera relative to the position the camera is looking at.
static processing.core.PVector getRightVector()
          Returns the up cross with eye vector, to get a vector pointing to the right of the camera
static processing.core.PVector getUpVector()
          Gets a vector perpendicular to the eye vector pointing in the up direction.
 void mouseEvent(java.awt.event.MouseEvent event)
           
 void setFarLimit(float limit)
          Set the farthest zoom possible to the look at position.
 void setLookat(processing.core.PVector lookat)
          Set target location for cameras view.
 void setNearLimit(float limit)
          Set the closet zoom possible to the look at position.
 void setOrthographicView()
          This methods alters the projection matrix to display scene in an orthographic view.
 void setPerspectiveView()
          This methods alters the projection matrix to display scene in an Perspective view.
 void setPosition(processing.core.PVector position)
          Set world space position of the camera.
 void setUpVector(processing.core.PVector up)
          Set the camera upwards vector
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Camera3D

public Camera3D(processing.core.PApplet parent)
Sets default values of camera position to <100,100,100> and look at position to <0,0,0>. Throws NullPointerException on null parent object.


Camera3D

public Camera3D(processing.core.PApplet parent,
                boolean registerMouseEvents)
Sets default camera properties as normal constructor but allows you to disable mouse events for a static camera.

Parameters:
parent - PApplet containing camera
registerMouseEvents - Boolean, set false for static camera
Method Detail

setLookat

public void setLookat(processing.core.PVector lookat)
Set target location for cameras view.


setPosition

public void setPosition(processing.core.PVector position)
Set world space position of the camera.


setNearLimit

public void setNearLimit(float limit)
Set the closet zoom possible to the look at position.


setFarLimit

public void setFarLimit(float limit)
Set the farthest zoom possible to the look at position.


setUpVector

public void setUpVector(processing.core.PVector up)
Set the camera upwards vector

Parameters:
up - vector pointing upwards from the camera (0,-1,0) per default

getNearLimit

public float getNearLimit()
Gets the nearest distance the camera can get to its lookat point


getFarLimit

public float getFarLimit()
Gets the furthest distance the camera can get to its lookat point


getPosition

public static processing.core.PVector getPosition()
Gets the position of the camera


getLookat

public static processing.core.PVector getLookat()
Gets the point the camera is looking at


getUpVector

public static processing.core.PVector getUpVector()
Gets a vector perpendicular to the eye vector pointing in the up direction.


getEyeVector

public static processing.core.PVector getEyeVector()
Gets a normalised vector stating the direction the camera is facing.


getRightVector

public static processing.core.PVector getRightVector()
Returns the up cross with eye vector, to get a vector pointing to the right of the camera


getRelativePosition

public static processing.core.PVector getRelativePosition()
Gets the position of the camera relative to the position the camera is looking at.


dispose

public void dispose()

mouseEvent

public void mouseEvent(java.awt.event.MouseEvent event)

setOrthographicView

public void setOrthographicView()
This methods alters the projection matrix to display scene in an orthographic view.


setPerspectiveView

public void setPerspectiveView()
This methods alters the projection matrix to display scene in an Perspective view.


draw

public void draw()


processing library gwoptics by Daniel Brown and Andreas Freise. (c) 2009 onwards