com.ryanm.glvisualiser
Class GLCamera

java.lang.Object
  extended by com.ryanm.glvisualiser.GLCamera
All Implemented Interfaces:
Configurable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

@ConfigurableType(value="Camera")
public class GLCamera
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.KeyListener, Configurable

Defines a camera that the user can move about with quake-style controls. The position can be reset by pressing r. The controls are :
Forward = w
Back = s
Sidestep left = a
Sidestep right = d
Up = e
Down = q
The mouse controls are:
Right-button drag = look around - in best inverted style
Mouse wheel up = Zoom in
Mouse wheel down = Zoom out

Author:
ryanm

Field Summary
 Vector3f default3dPosition
          The default position of the camera
 Vector3f default3dTarget
          The default target of the camera
 float farPlane
          The distance to the far clipping plane
 float mouseWheelSensitivity
          The angle by which to alter the fov for every click of the wheel, in degrees
 float nearPlane
          The distances to the near and far clipping planes
 boolean originView
          When in originView mode, the near and far clipping planes are set so as to keep the unit cube in the positive octant in view.
 boolean ortho
          When true, an orthographic matrix is used
 float orthoWidth
          The minimum extent of the orthographic view in either the x or y directions
 int pickingSensitivity
          The size of the picking square
 float speed
          The movement speed of the camera, in units per second
 
Method Summary
 float getAspectRatio()
          Gets the aspect ratio of the viewport
 Configurator getConfigurator()
          Gets a Configurator object that describes and can manipulate the variables of this Configurable.
 double getFarPlane()
          Gets the distance to the far clipping plane
 float getFieldOfView()
          Gets the field of view of this camera
 float getMouseSensitivity()
          Gets the turning speed of the camera
 double getNearPlane()
          Gets the distance to the near clipping plane
 Point3f getPosition()
          Gets the camera's position
 Point3f getTarget()
          Gets the current view target
 Vector3f getUpVector()
          Gets the camera's up-vector
 Vector3f getViewDirection()
          Computes the current view vector
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent mwe)
           
 void setMouseSensitivity(float mouseSensitivity)
          Sets the turning speed of the camera.
 void setPosition(Point3f position)
          Sets the camera position.
 void setTarget(Point3f target)
          Sets the target point for the camera to look at
 void setTileMatrix(com.sun.opengl.util.TileRenderer tr)
          Sets the tile rendering matrix appropriately
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

default3dPosition

@ConfigurableVariable(value="Default position")
@Description(value="The default position of the camera")
@Priority(value=4)
public Vector3f default3dPosition
The default position of the camera


default3dTarget

@ConfigurableVariable(value="Default Target")
@Description(value="The default target point of the camera")
@Priority(value=5)
public Vector3f default3dTarget
The default target of the camera


originView

@ConfigurableVariable(value="Origin View")
@Description(value="When in origin view, the near and far clipping planes are set to keep the unit octant in view")
@Priority(value=6)
public boolean originView
When in originView mode, the near and far clipping planes are set so as to keep the unit cube in the positive octant in view.


ortho

@ConfigurableVariable(value="Orthographic")
@Description(value="Sets the camera to an orthographic view")
@Priority(value=9)
public boolean ortho
When true, an orthographic matrix is used


orthoWidth

@ConfigurableVariable(value="Orthographic size")
@Description(value="The minimum extent of the orthographic view in either the x or y directions")
@NumberRange(value={9.999999747378752E-6f,0f/0f})
@Priority(value=10)
public float orthoWidth
The minimum extent of the orthographic view in either the x or y directions


nearPlane

@ConfigurableVariable(value="Near clipping plane")
@Description(value="The distance to the near clipping plane")
@Priority(value=7)
public float nearPlane
The distances to the near and far clipping planes


farPlane

@ConfigurableVariable(value="Far clipping plane")
@Description(value="The distance to the far clipping plane")
@Priority(value=8)
public float farPlane
The distance to the far clipping plane


speed

@ConfigurableVariable(value="Speed")
@Description(value="The movement speed of the camera, in units per second")
@NumberRange(value={0.0f,5.0f})
@Priority(value=1)
public float speed
The movement speed of the camera, in units per second


mouseWheelSensitivity

@ConfigurableVariable(value="Wheel")
@Description(value="The wheel sensitivity, in degrees per click")
@NumberRange(value={0.0f,10.0f})
@Priority(value=3)
public float mouseWheelSensitivity
The angle by which to alter the fov for every click of the wheel, in degrees


pickingSensitivity

@ConfigurableVariable(value="Picking Sensitivity")
@Description(value="The size of the picking window, in pixels")
@NumberRange(value={1.0f,50.0f})
@Priority(value=11)
public int pickingSensitivity
The size of the picking square

Method Detail

setTarget

public void setTarget(Point3f target)
Sets the target point for the camera to look at

Parameters:
target - The target point, or null to leave target mode

getTarget

public Point3f getTarget()
Gets the current view target

Returns:
the current target

setPosition

public void setPosition(Point3f position)
Sets the camera position.

Parameters:
position - The desired position, or null to return to the default position

getPosition

public Point3f getPosition()
Gets the camera's position

Returns:
The position of the camera

getUpVector

public Vector3f getUpVector()
Gets the camera's up-vector

Returns:
The camera's up-vector

getViewDirection

public Vector3f getViewDirection()
Computes the current view vector

Returns:
The direction that the camera is pointing

getFieldOfView

public float getFieldOfView()
Gets the field of view of this camera

Returns:
the field of view angle, in degrees

getNearPlane

public double getNearPlane()
Gets the distance to the near clipping plane

Returns:
The near plane distance

getFarPlane

public double getFarPlane()
Gets the distance to the far clipping plane

Returns:
The far plane distance

getAspectRatio

public float getAspectRatio()
Gets the aspect ratio of the viewport

Returns:
the aspect ratio of the viewport

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent mwe)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

getConfigurator

public Configurator getConfigurator()
Description copied from interface: Configurable
Gets a Configurator object that describes and can manipulate the variables of this Configurable. This method must only return null if the Configurable object is Annotated such that an AnnotatedConfigurator can be built from it.

Specified by:
getConfigurator in interface Configurable
Returns:
A configurator object, or null if annotated

getMouseSensitivity

@ConfigurableVariable(value="Mouse")
public float getMouseSensitivity()
Gets the turning speed of the camera

Returns:
Returns the mouseSensitivity, in degrees per pixel

setMouseSensitivity

@ConfigurableVariable(value="Mouse")
@Description(value="The turning speed of the camera, in degrees per pixel of mouse movement")
@NumberRange(value={0.0f,2.0f})
@Priority(value=2)
public void setMouseSensitivity(float mouseSensitivity)
Sets the turning speed of the camera.

Parameters:
mouseSensitivity - The angle increment, in degrees per pixel.

setTileMatrix

public void setTileMatrix(com.sun.opengl.util.TileRenderer tr)
Sets the tile rendering matrix appropriately

Parameters:
tr - The tile render context