com.threerings.opengl.camera
Class Camera

java.lang.Object
  extended by com.threerings.opengl.camera.Camera

public class Camera
extends Object

Contains the camera state.


Field Summary
protected  float _bottom
          The camera frustum parameters.
protected  float _far
          The camera frustum parameters.
protected  float _left
          The camera frustum parameters.
protected  Frustum _localVolume
          The camera's local view volume.
protected  boolean _mirrored
          Whether or not the camera is mirrored.
protected  float _near
          The camera frustum parameters.
protected  Vector3f _nearFarNormal
          The normal of the near/far clip planes.
protected  boolean _ortho
          Whether or not the camera is set to an orthographic projection.
protected  Matrix4f _projection
          The cached projection matrix.
protected  float _right
          The camera frustum parameters.
protected  float _top
          The camera frustum parameters.
protected  Rectangle _viewport
          The camera viewport.
protected  Transform3D _viewTransform
          The camera's view transform (the inverse of its world transform).
protected  Transform3D _worldTransform
          The camera's current transform in world space.
protected  Frustum _worldVolume
          The camera's world space view volume.
 
Constructor Summary
Camera()
           
 
Method Summary
 void apply(Renderer renderer)
          Applies the camera state to the specified renderer.
 float getBottom()
          Returns the location of the bottom edge of the view frustum at the near plane.
 void getCenterRay(Ray3D result)
          Populates the supplied object with a ray through the center of the viewport.
protected  void getEyeRay(float ex, float ey, Ray3D result)
          Populates the supplied object with a ray through the specified eye space coordinates (at the near clip plane).
 float getFar()
          Returns the distance to the far clip plane.
 float getLeft()
          Returns the location of the left edge of the view frustum at the near plane.
 Frustum getLocalVolume()
          Returns a reference to the volume that the camera occupies in view space.
 float getNear()
          Returns the distance to the near clip plane.
 Vector3f getNearFarNormal()
          Returns a reference to the normal of the near/far clip planes.
 void getPickRay(int x, int y, Ray3D result)
          Populates the supplied object with a ray through the specified viewport coordinates.
 Matrix4f getProjection()
          Returns a reference to the projection matrix.
 float getRight()
          Returns the location of the right edge of the view frustum at the near plane.
 void getTexGenPlanes(Vector4f s, Vector4f t, Vector4f q)
          Populates the supplied vectors with texture coordinate generation planes corresponding to the camera projection state.
 float getTop()
          Returns the location of the top edge of the view frustum at the near plane.
 Rectangle getViewport()
          Returns a reference to the camera viewport.
 Transform3D getViewTransform()
          Returns a reference to the camera view transform (the inverse of the world transform).
 Transform3D getWorldTransform()
          Returns a reference to the camera's current transform in world space.
 Frustum getWorldVolume()
          Returns a reference to the volume that the camera occupies in the world.
 boolean isMirrored()
          Determines whether or not the camera is mirrored.
 boolean isOrtho()
          Determines whether or not the camera is set to an orthographic projection.
 void setFrustum(float left, float right, float bottom, float top, float near, float far)
          Sets the camera frustum parameters.
 void setOrtho(float left, float right, float bottom, float top, float near, float far)
          Sets the camera frustum parameters.
 void setPerspective(float fovy, float aspect, float near, float far)
          Sets the camera perspective parameters.
 void setProjection(Camera ocamera)
          Copies the projection parameters of another camera.
 void setProjection(float left, float right, float bottom, float top, float near, float far, Vector3f nearFarNormal, boolean ortho, boolean mirrored)
          Sets the camera projection parameters.
 Box transform(Box box)
          Transforms and projects a box in world space into window space.
 Box transform(Box box, Box result)
          Transforms and projects a box in world space into window space, placing the result in the object provided.
 Vector3f transform(Vector3f point)
          Transforms and projects a point in world space into window space.
 Vector3f transform(Vector3f point, Vector3f result)
          Transforms and projects a point in world space into window space, placing the result in the object provided.
 Box transformLocal(Box box)
          Transforms and projects a box in world space into window space.
 Vector3f transformLocal(Vector3f point)
          Transforms and projects a point in world space into window space.
 void updateTransform()
          Updates the camera transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_viewport

protected Rectangle _viewport
The camera viewport.


_left

protected float _left
The camera frustum parameters.


_right

protected float _right
The camera frustum parameters.


_bottom

protected float _bottom
The camera frustum parameters.


_top

protected float _top
The camera frustum parameters.


_near

protected float _near
The camera frustum parameters.


_far

protected float _far
The camera frustum parameters.


_nearFarNormal

protected Vector3f _nearFarNormal
The normal of the near/far clip planes.


_ortho

protected boolean _ortho
Whether or not the camera is set to an orthographic projection.


_mirrored

protected boolean _mirrored
Whether or not the camera is mirrored.


_projection

protected Matrix4f _projection
The cached projection matrix.


_worldTransform

protected Transform3D _worldTransform
The camera's current transform in world space.


_viewTransform

protected Transform3D _viewTransform
The camera's view transform (the inverse of its world transform).


_localVolume

protected Frustum _localVolume
The camera's local view volume.


_worldVolume

protected Frustum _worldVolume
The camera's world space view volume.

Constructor Detail

Camera

public Camera()
Method Detail

getWorldTransform

public Transform3D getWorldTransform()
Returns a reference to the camera's current transform in world space.


getViewTransform

public Transform3D getViewTransform()
Returns a reference to the camera view transform (the inverse of the world transform).


getLocalVolume

public Frustum getLocalVolume()
Returns a reference to the volume that the camera occupies in view space.


getWorldVolume

public Frustum getWorldVolume()
Returns a reference to the volume that the camera occupies in the world.


getViewport

public Rectangle getViewport()
Returns a reference to the camera viewport.


setPerspective

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


setFrustum

public void setFrustum(float left,
                       float right,
                       float bottom,
                       float top,
                       float near,
                       float far)
Sets the camera frustum parameters.


setOrtho

public void setOrtho(float left,
                     float right,
                     float bottom,
                     float top,
                     float near,
                     float far)
Sets the camera frustum parameters.


setProjection

public void setProjection(Camera ocamera)
Copies the projection parameters of another camera.


setProjection

public void setProjection(float left,
                          float right,
                          float bottom,
                          float top,
                          float near,
                          float far,
                          Vector3f nearFarNormal,
                          boolean ortho,
                          boolean mirrored)
Sets the camera projection parameters.


getProjection

public Matrix4f getProjection()
Returns a reference to the projection matrix.


getLeft

public float getLeft()
Returns the location of the left edge of the view frustum at the near plane.


getRight

public float getRight()
Returns the location of the right edge of the view frustum at the near plane.


getBottom

public float getBottom()
Returns the location of the bottom edge of the view frustum at the near plane.


getTop

public float getTop()
Returns the location of the top edge of the view frustum at the near plane.


getNear

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


getFar

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


getNearFarNormal

public Vector3f getNearFarNormal()
Returns a reference to the normal of the near/far clip planes.


isOrtho

public boolean isOrtho()
Determines whether or not the camera is set to an orthographic projection.


isMirrored

public boolean isMirrored()
Determines whether or not the camera is mirrored.


updateTransform

public void updateTransform()
Updates the camera transform.


apply

public void apply(Renderer renderer)
Applies the camera state to the specified renderer.


transformLocal

public Box transformLocal(Box box)
Transforms and projects a box in world space into window space.

Returns:
a reference to the box, for chaining.

transform

public Box transform(Box box)
Transforms and projects a box in world space into window space.

Returns:
a new box containing the result.

transform

public Box transform(Box box,
                     Box result)
Transforms and projects a box in world space into window space, placing the result in the object provided.

Returns:
a reference to the result box, for chaining.

transformLocal

public Vector3f transformLocal(Vector3f point)
Transforms and projects a point in world space into window space.

Returns:
a reference to the point, for chaining.

transform

public Vector3f transform(Vector3f point)
Transforms and projects a point in world space into window space.

Returns:
a new vector containing the result.

transform

public Vector3f transform(Vector3f point,
                          Vector3f result)
Transforms and projects a point in world space into window space, placing the result in the object provided.

Returns:
a reference to the result vector, for chaining.

getTexGenPlanes

public void getTexGenPlanes(Vector4f s,
                            Vector4f t,
                            Vector4f q)
Populates the supplied vectors with texture coordinate generation planes corresponding to the camera projection state.


getCenterRay

public void getCenterRay(Ray3D result)
Populates the supplied object with a ray through the center of the viewport.


getPickRay

public void getPickRay(int x,
                       int y,
                       Ray3D result)
Populates the supplied object with a ray through the specified viewport coordinates.


getEyeRay

protected void getEyeRay(float ex,
                         float ey,
                         Ray3D result)
Populates the supplied object with a ray through the specified eye space coordinates (at the near clip plane).