org.jrabbit.standard.game.world.camera
Class Camera

java.lang.Object
  extended by org.jrabbit.standard.game.world.camera.Camera
All Implemented Interfaces:
Updateable, GLTransform, GLGroupTransformed, Located, Rotated, Scaled, Viewer

public class Camera
extends java.lang.Object
implements Viewer, Located, Rotated, Scaled, Updateable, GLGroupTransformed

A Camera is an object used by a World to view a particular section of the game's "space." It functions like a real-world camera; it has a location, rotation, and x/y zoom (and, for fun, it can be "shaken").

Author:
Chris Molini

Field Summary
protected  Vector2f baseLocation
          The base viewpoint of the Camera.
protected  Rotation baseRotation
          The base rotation of the Camera.
protected  Scalar baseScalar
          The base scaling (i.e., zoom) of the Camera.
protected  CameraShaker shake
          This is the object used to handle shaking the Camera.
protected  GLGroupTransform transforms
          The dynamic list of GLTransforms applied by the camera.
protected  CameraViewChecker viewCalc
          This is the object used to handle culling.
protected  Vector2f viewedLocation
          This is the Vector2f that is actually used in setting the view and culling objects.
protected  Rotation viewedRotation
          This is the Rotation that is actually used in rotating the view and culling objects.
protected  Scalar viewedScalar
          This is the Scalar that is actually used in zooming view and culling objects.
 
Constructor Summary
Camera()
          Creates a Camera at [0, 0].
Camera(BaseVector2f target)
          Creates a Camera at the indicated coordinates.
Camera(float x, float y)
          Creates a Camera at the indicated coordinates.
 
Method Summary
 void bind()
          Applies the Camera's transforms.
 Vector2f location()
          Accesses the viewpoint of the Camera.
 void makeActive()
          Makes this the active camera in the active World.
 void release()
          Releases the Camera's transforms.
 Rotation rotation()
          Accesses the rotation control of the Camera.
 Scalar scalar()
          Accesses the "zoom" control of the camera.
 void setShake(CameraShaker shake)
          Redefines the CameraShaker this camera uses to handle shaking.
 CameraShaker shake()
          Accesses the current CameraShaker.
 GLGroupTransform transforms()
          Accesses the dynamic list of GLTransforms.
 void update(int delta)
          Updates the Camera and its components.
 boolean views(float x, float y, float radius)
          Determines if the object described can be viewed by this Camera.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseLocation

protected Vector2f baseLocation
The base viewpoint of the Camera.


viewedLocation

protected Vector2f viewedLocation
This is the Vector2f that is actually used in setting the view and culling objects. Every frame, this is set to the same values as the base location, but then it can be affected by camera shaking. In this way, the target viewpoint remains consistent over time, but the camera shake has free rein.


baseRotation

protected Rotation baseRotation
The base rotation of the Camera.


viewedRotation

protected Rotation viewedRotation
This is the Rotation that is actually used in rotating the view and culling objects. Every frame, this is set to the same value as the base rotation, but then it can be affected by camera shaking.


baseScalar

protected Scalar baseScalar
The base scaling (i.e., zoom) of the Camera.


viewedScalar

protected Scalar viewedScalar
This is the Scalar that is actually used in zooming view and culling objects. Every frame, this is set to the same value as the base rotation, but then it can be affected by camera shaking.


shake

protected CameraShaker shake
This is the object used to handle shaking the Camera.


viewCalc

protected CameraViewChecker viewCalc
This is the object used to handle culling.


transforms

protected GLGroupTransform transforms
The dynamic list of GLTransforms applied by the camera.

Constructor Detail

Camera

public Camera()
Creates a Camera at [0, 0].


Camera

public Camera(float x,
              float y)
Creates a Camera at the indicated coordinates.

Parameters:
x - The x-coordinate the Camera should initially look at.
y - The y-coordinate the Camera should initially look at.

Camera

public Camera(BaseVector2f target)
Creates a Camera at the indicated coordinates.

Parameters:
target - The coordinates the camera should initially look at.
Method Detail

location

public Vector2f location()
Accesses the viewpoint of the Camera.

Specified by:
location in interface Located
Returns:
the Vector2f that conrtols where the Camera looks at.

rotation

public Rotation rotation()
Accesses the rotation control of the Camera.

Specified by:
rotation in interface Rotated
Returns:
the Rotation used to rotate the view.

scalar

public Scalar scalar()
Accesses the "zoom" control of the camera.

Specified by:
scalar in interface Scaled
Returns:
The Scalar used to handle zooming the view.

transforms

public GLGroupTransform transforms()
Accesses the dynamic list of GLTransforms.

Specified by:
transforms in interface GLGroupTransformed
Returns:
The GLGroupTransform that is applied to this Camera.

shake

public CameraShaker shake()
Accesses the current CameraShaker.

Returns:
The object being used to shake the Camera.

setShake

public void setShake(CameraShaker shake)
Redefines the CameraShaker this camera uses to handle shaking.

Parameters:
shake - The new CameraShaker to use.

update

public void update(int delta)
Updates the Camera and its components.

Specified by:
update in interface Updateable
Parameters:
delta - The number of milliseconds that have passed since the last update.

bind

public void bind()
Applies the Camera's transforms.

Specified by:
bind in interface GLTransform

release

public void release()
Releases the Camera's transforms.

Specified by:
release in interface GLTransform

views

public boolean views(float x,
                     float y,
                     float radius)
Determines if the object described can be viewed by this Camera.

Specified by:
views in interface Viewer
Parameters:
x - The x-coordinate the object is centered at.
y - The y-coordinate the object is centered at.
radius - The radius the object fits within.
Returns:
True if the object is potentially visible, false otherwise.

makeActive

public void makeActive()
Makes this the active camera in the active World. This uses GameManager to accomplish this.