com.threerings.opengl.camera
Class CameraHandler

java.lang.Object
  extended by com.threerings.opengl.camera.CameraHandler
All Implemented Interfaces:
Renderer.Observer
Direct Known Subclasses:
OrbitCameraHandler

public abstract class CameraHandler
extends Object
implements Renderer.Observer

Controls the camera parameters.


Nested Class Summary
static interface CameraHandler.Offset
          Provides a means of temporarily offsetting the camera transform.
 
Field Summary
protected  Camera _camera
          The camera that we're handling.
protected  GlContext _ctx
          The renderer context.
protected  float _far
          The distance to the far clip plane.
protected  float _fovy
          The vertical field of view (in radians).
protected  boolean _matchRenderSurface
          Whether or not we're to match the size of the render surface.
protected  float _near
          The distance to the near clip plane.
protected  List<CameraHandler.Offset> _offsets
          The list of registered offsets.
 
Constructor Summary
CameraHandler(GlContext ctx)
          Creates a new camera handler for the compositor camera.
CameraHandler(GlContext ctx, Camera camera, boolean matchRenderSurface)
          Creates a new camera handler for the specified camera.
 
Method Summary
 void addOffset(CameraHandler.Offset offset)
          Adds an element to the list of offsets to apply.
 float getFar()
          Returns the distance to the far clip plane.
 float getFieldOfView()
          Returns the camera's field of view in radians.
 float getNear()
          Returns the distance to the near clip plane.
protected abstract  void getTransform(Transform3D transform)
          Computes the base (pre-offset) camera transform.
 Quaternion getViewerRotation()
          Returns a reference to the rotation to use for the viewer.
 Vector3f getViewerTranslation()
          Returns a reference to the translation to use for the notional "viewer."
 boolean isAdded()
          Determines whether the camera handler is currently active.
 void setPerspective(float fovy, float near, float far)
          Sets the camera's perspective parameters.
 void sizeChanged(int width, int height)
          Notes that the size of the renderer's drawable surface has changed.
 void updatePerspective()
          Updates the camera perspective parameters.
 void updatePosition()
          Updates the camera position.
 void wasAdded()
          Notifies the handler that it has been added.
 void wasRemoved()
          Notifies the handler that it has been removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ctx

protected GlContext _ctx
The renderer context.


_camera

protected Camera _camera
The camera that we're handling.


_matchRenderSurface

protected boolean _matchRenderSurface
Whether or not we're to match the size of the render surface.


_fovy

protected float _fovy
The vertical field of view (in radians).


_near

protected float _near
The distance to the near clip plane.


_far

protected float _far
The distance to the far clip plane.


_offsets

protected List<CameraHandler.Offset> _offsets
The list of registered offsets.

Constructor Detail

CameraHandler

public CameraHandler(GlContext ctx)
Creates a new camera handler for the compositor camera.


CameraHandler

public CameraHandler(GlContext ctx,
                     Camera camera,
                     boolean matchRenderSurface)
Creates a new camera handler for the specified camera.

Parameters:
matchRenderSurface - if true, automatically adjust the camera viewport to match the dimensions of the renderer surface.
Method Detail

setPerspective

public void setPerspective(float fovy,
                           float near,
                           float far)
Sets the camera's perspective parameters.


getFieldOfView

public float getFieldOfView()
Returns the camera's field of view in radians.


getNear

public float getNear()
Returns the distance to the near clip plane.


getFar

public float getFar()
Returns the distance to the far clip plane.


addOffset

public void addOffset(CameraHandler.Offset offset)
Adds an element to the list of offsets to apply.


getViewerTranslation

public Vector3f getViewerTranslation()
Returns a reference to the translation to use for the notional "viewer."


getViewerRotation

public Quaternion getViewerRotation()
Returns a reference to the rotation to use for the viewer.


isAdded

public boolean isAdded()
Determines whether the camera handler is currently active.


wasAdded

public void wasAdded()
Notifies the handler that it has been added.


wasRemoved

public void wasRemoved()
Notifies the handler that it has been removed.


updatePerspective

public void updatePerspective()
Updates the camera perspective parameters.


updatePosition

public void updatePosition()
Updates the camera position.


sizeChanged

public void sizeChanged(int width,
                        int height)
Description copied from interface: Renderer.Observer
Notes that the size of the renderer's drawable surface has changed.

Specified by:
sizeChanged in interface Renderer.Observer

getTransform

protected abstract void getTransform(Transform3D transform)
Computes the base (pre-offset) camera transform.