de.jreality.scene
Class Camera

java.lang.Object
  extended by de.jreality.scene.SceneGraphNode
      extended by de.jreality.scene.Camera

public class Camera
extends SceneGraphNode

The camera represents essentially a projection from three dimensions into two, that is a specification of a viewing frustrum. The camera coordinate system is assumed to point down the positive z-axis. (Note: specific backends may flip the orientation of the z-axis. This issue is handled separately from the camera description here).

All instance of Camera require specifying the near and far clipping planes.

The camera can be either perspective or orthographic. If it is perspective, then its viewing frustum can be specified by giving the field of view setFieldOfView(double). This implies that the camera is on-axis, that is, the viewing frustum is centered on the z-axis.

There is also support for off-axis cameras (setOnAxis(boolean)). Use the setViewPort(Rectangle2D) method to specify the desired viewport, which is assumed to lie in the z=1 plane. In this case the field of view is ignored.

The camera also supports stereo viewing @link #setStereo(boolean). For most desktop environments the only other required parameters are:

For CAVE-like environments where the eyes are not always oriented horizontally, there is an additional parameter: an orientation matrix (@link #setOrientationMatrix(double[])), a 4x4 transformation matrix which defines the rotation that has to be applied to the x-axis to get the line in camera coordinates on which the eyes lie. (This matrix should fix (0,0,0,1)!).

Default eye positions are (-eyeSeparation/2,0,0) and (eyeSeparation, 0,0) in the camera coordinate system. Use de.jreality.util.CameraUtility#getNDCToCamera(Camera, double, int) to generate the appropriate projection matrices.

Instances of CameraListener can register with the camera to be notified when the camera changes.

Due to refactoring, the camera no longer has enough state to provide the perspective viewing transformation from/to camera to/from Normalized Device Coordinates (NDC). It basically lacks the aspect ratio of the output device. This allows to use the same camera for different viewers with i. e. different window sizes. See CameraUtility for methods which provide this functionality.

Author:
Charles Gunn
See Also:
CameraUtility

Constructor Summary
Camera()
           
Camera(String name)
           
 
Method Summary
 void accept(SceneGraphVisitor v)
          The accept method for a SceneGraphVisitor.
 void addCameraListener(CameraListener listener)
           
 double getEyeSeparation()
           
 double getFar()
           
 double getFieldOfView()
           
 double getFocalLength()
          Values useful in Renderman backend.
 double getFocus()
           
 double getFStop()
          Values useful in Renderman backend.
 double getNear()
           
 double[] getOrientationMatrix()
          The orientation matrix describes the transformation in camera coordinate system which describes the orientation of the head; the "standard" position is that the eyes are on the x-axis, up is the y-axis, and z is the direction of projection The orientation matrix is used for cameras such as those in the PORTAL.
 Rectangle2D getViewPort()
           
 boolean isOnAxis()
           
 boolean isPerspective()
           
 boolean isStereo()
           
 void removeCameraListener(CameraListener listener)
           
 void setEyeSeparation(double eyeSeparation)
           
 void setFar(double d)
           
 void setFieldOfView(double d)
           
 void setFocalLength(double focalLength)
           
 void setFocus(double d)
           
 void setFStop(double fstop)
           
 void setNear(double d)
           
 void setOnAxis(boolean b)
           
 void setOrientationMatrix(double[] orientationMatrix)
           
 void setPerspective(boolean b)
           
 void setStereo(boolean isStereo)
           
 void setViewPort(Rectangle2D rectangle2D)
           
 
Methods inherited from class de.jreality.scene.SceneGraphNode
getName, getOwner, getThreadSafe, isReadOnly, setName, setOwner, setReadOnly, setThreadSafe, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Camera

public Camera(String name)

Camera

public Camera()
Method Detail

getNear

public double getNear()

setNear

public void setNear(double d)

getFar

public double getFar()

setFar

public void setFar(double d)

getFieldOfView

public double getFieldOfView()

setFieldOfView

public void setFieldOfView(double d)

getFocus

public double getFocus()

setFocus

public void setFocus(double d)

getViewPort

public Rectangle2D getViewPort()

setViewPort

public void setViewPort(Rectangle2D rectangle2D)

isOnAxis

public boolean isOnAxis()

setOnAxis

public void setOnAxis(boolean b)

isPerspective

public boolean isPerspective()

setPerspective

public void setPerspective(boolean b)

getEyeSeparation

public double getEyeSeparation()

setEyeSeparation

public void setEyeSeparation(double eyeSeparation)
Parameters:
eyeSeparation - The eyeSeparation to set.

getOrientationMatrix

public double[] getOrientationMatrix()
The orientation matrix describes the transformation in camera coordinate system which describes the orientation of the head; the "standard" position is that the eyes are on the x-axis, up is the y-axis, and z is the direction of projection The orientation matrix is used for cameras such as those in the PORTAL.

Returns:
Returns the orientationMatrix.

setOrientationMatrix

public void setOrientationMatrix(double[] orientationMatrix)

isStereo

public boolean isStereo()

setStereo

public void setStereo(boolean isStereo)

addCameraListener

public void addCameraListener(CameraListener listener)

removeCameraListener

public void removeCameraListener(CameraListener listener)

accept

public void accept(SceneGraphVisitor v)
Description copied from class: SceneGraphNode
The accept method for a SceneGraphVisitor.

Overrides:
accept in class SceneGraphNode

getFocalLength

public double getFocalLength()
Values useful in Renderman backend.

Returns:

getFStop

public double getFStop()
Values useful in Renderman backend.

Returns:

setFStop

public void setFStop(double fstop)

setFocalLength

public void setFocalLength(double focalLength)