net.java.joglutils.msg.nodes
Class Camera

java.lang.Object
  extended by net.java.joglutils.msg.nodes.Node
      extended by net.java.joglutils.msg.nodes.Camera
Direct Known Subclasses:
OrthographicCamera, PerspectiveCamera

public abstract class Camera
extends Node

Represents a camera which is used to view the scene. The camera should be added to the scene graph before the geometry it is intended to view.

The camera's default parameters are a position at (0, 0, 1), facing down the negative Z axis with the Y axis up, an aspect ratio of 1.0, a near distance of 1.0, a far distance of 100.0, and a focal distance of 10.0.


Field Summary
protected  boolean projDirty
           
protected  Mat4f projMatrix
           
protected  boolean viewDirty
           
protected  Mat4f viewMatrix
           
 
Constructor Summary
Camera()
           
 
Method Summary
 void doAction(Action action)
          Performs the "typical" operation for this node when an action is applied to it.
 float getAspectRatio()
          Returns the aspect ratio of the camera -- the width of the viewport divided by the height of the viewport.
 float getFarDistance()
          Returns the distance from the eye point to the far clipping plane.
 float getFocalDistance()
          Returns the distance from the eye point to the focal point of the scene.
 float getNearDistance()
          Returns the distance from the eye point to the near clipping plane.
 Rotf getOrientation()
          Returns the orientation of the camera.
 Vec3f getPosition()
          Returns the position of the camera.
abstract  Mat4f getProjectionMatrix()
          Returns the projection matrix associated with this camera's parameters.
protected abstract  Vec3f getRayStartPoint(Vec2f point, Vec3f unprojectedPoint)
          Computes the start point of a ray for picking, given a point in normalized screen coordinates ((0, 0) to (1, 1)) and a 3D point which that point unprojects to.
 Mat4f getViewingMatrix()
          Returns the viewing matrix associated with this camera's parameters.
 void rayPick(RayPickAction action)
          Support for the built-in RayPickAction.
 void setAspectRatio(float aspectRatio)
          Sets the aspect ratio of the camera -- the width of the viewport divided by the height of the viewport.
 void setFarDistance(float farDistance)
          Sets the distance from the eye point to the far clipping plane.
 void setFocalDistance(float focalDistance)
          Sets the distance from the eye point to the focal point of the scene.
 void setNearDistance(float nearDistance)
          Sets the distance from the eye point to the near clipping plane.
 void setOrientation(Rotf orientation)
          Sets the orientation of the camera.
 void setPosition(Vec3f position)
          Sets the position of the camera.
 Line unproject(Vec2f point)
          Un-projects the given on-screen point to a line in 3D space which can be used for picking or other operations.
 void unproject(Vec2f point, Line line)
          Un-projects the given on-screen point in to the given line in 3D space (in world coordinates) which can be used for picking or other operations.
 
Methods inherited from class net.java.joglutils.msg.nodes.Node
render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

projDirty

protected boolean projDirty

viewDirty

protected boolean viewDirty

projMatrix

protected Mat4f projMatrix

viewMatrix

protected Mat4f viewMatrix
Constructor Detail

Camera

public Camera()
Method Detail

setPosition

public void setPosition(Vec3f position)
Sets the position of the camera.


getPosition

public Vec3f getPosition()
Returns the position of the camera.


setOrientation

public void setOrientation(Rotf orientation)
Sets the orientation of the camera.


getOrientation

public Rotf getOrientation()
Returns the orientation of the camera.


setAspectRatio

public void setAspectRatio(float aspectRatio)
Sets the aspect ratio of the camera -- the width of the viewport divided by the height of the viewport.


getAspectRatio

public float getAspectRatio()
Returns the aspect ratio of the camera -- the width of the viewport divided by the height of the viewport.


setNearDistance

public void setNearDistance(float nearDistance)
Sets the distance from the eye point to the near clipping plane.


getNearDistance

public float getNearDistance()
Returns the distance from the eye point to the near clipping plane.


setFarDistance

public void setFarDistance(float farDistance)
Sets the distance from the eye point to the far clipping plane.


getFarDistance

public float getFarDistance()
Returns the distance from the eye point to the far clipping plane.


setFocalDistance

public void setFocalDistance(float focalDistance)
Sets the distance from the eye point to the focal point of the scene. This is only used for mouse-based interaction with the scene and is not factored in to the rendering process.


getFocalDistance

public float getFocalDistance()
Returns the distance from the eye point to the focal point of the scene. This is only used for mouse-based interaction with the scene and is not factored in to the rendering process.


getViewingMatrix

public Mat4f getViewingMatrix()
Returns the viewing matrix associated with this camera's parameters.


getProjectionMatrix

public abstract Mat4f getProjectionMatrix()
Returns the projection matrix associated with this camera's parameters.


unproject

public Line unproject(Vec2f point)
Un-projects the given on-screen point to a line in 3D space which can be used for picking or other operations. The x and y coordinates of the point must be in normalized coordinates, where (0, 0) is the lower-left corner of the viewport and (1, 1) is the upper-right. Allocates new storage for the returned Line.


unproject

public void unproject(Vec2f point,
                      Line line)
               throws SingularMatrixException
Un-projects the given on-screen point in to the given line in 3D space (in world coordinates) which can be used for picking or other operations. The x and y coordinates of the point must be in normalized coordinates, where (0, 0) is the lower-left corner of the viewport and (1, 1) is the upper-right.

Throws:
SingularMatrixException

getRayStartPoint

protected abstract Vec3f getRayStartPoint(Vec2f point,
                                          Vec3f unprojectedPoint)
Computes the start point of a ray for picking, given a point in normalized screen coordinates ((0, 0) to (1, 1)) and a 3D point which that point unprojects to.


doAction

public void doAction(Action action)
Description copied from class: Node
Performs the "typical" operation for this node when an action is applied to it. The default implementation does nothing.

Overrides:
doAction in class Node

rayPick

public void rayPick(RayPickAction action)
Description copied from class: Node
Support for the built-in RayPickAction. Note that supplying virtual methods in Node subclasses to support various actions is not required due to the framework supporting action methods, but for built-in actions it may make it simpler.

Overrides:
rayPick in class Node