com.jme.renderer
Interface Camera

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractCamera

public interface Camera
extends java.io.Serializable

Camera defines an interface that encapsulates viewport management. Provided are convenience methods for setting up the view port and the camera model. The frustum is also maintained here to allow for easy frustum culling.

Version:
$Id: Camera.java,v 1.14 2004/09/14 03:05:35 renanse Exp $
Author:
Mark Powell, Gregg Patton

Field Summary
static int INSIDE_FRUSTUM
          defines a constant assigned to spatials that are completely inside the camera's view frustum.
static int INTERSECTS_FRUSTUM
          defines a constant assigned to spatials that are intersecting one of the six planes that define the view frustum.
static int OUTSIDE_FRUSTUM
          defines a constant assigned to spatials that are outside of this camera's view frustum.
 
Method Summary
 int contains(BoundingVolume bound)
          culled tests a bounding volume against the planes of the camera's frustum.
 Vector3f getDirection()
          getDirection returns the direction the camera is facing.
 float getFrustumBottom()
          getFrustumBottom returns the value of the bottom frustum plane.
 float getFrustumFar()
          getFrustumFar gets the value of the far frustum plane.
 float getFrustumLeft()
          getFrustumLeft gets the value of the left frustum plane.
 float getFrustumNear()
          getFrustumNear gets the value of the near frustum plane.
 float getFrustumRight()
          getFrustumRight gets the value of the right frustum plane.
 float getFrustumTop()
          getFrustumTop gets the value of the top frustum plane.
 Vector3f getLeft()
          getLeft returns the left axis of the camera.
 Vector3f getLocation()
          getLocation returns the position of the camera.
 int getPlaneState()
          getPlaneState returns the state of the frustum planes.
 Vector3f getUp()
          getUp returns the up axis of the camera.
 float getViewPortBottom()
          getViewPortBottom gets the bottom boundary of the viewport
 float getViewPortLeft()
          getViewPortLeft gets the left boundary of the viewport
 float getViewPortRight()
          getViewPortRight gets the right boundary of the viewport
 float getViewPortTop()
          getViewPortTop gets the top boundary of the viewport
 void lookAt(Vector3f pos)
          lookAt is a convienence method for auto-setting the frame.
 void onFrameChange()
          onFrameChange is an update callback that is activated if the frame changes.
 void onFrustumChange()
          onFrustumChange is an update callback that is activated if the frustum values change.
 void onViewPortChange()
          onViewPortChange is an update callback that is activated if the view port changes.
 void resize(int width, int height)
          resize resizes this cameras view with the given width/height.
 void setAxes(Quaternion axes)
          setAxes sets the camera's orientation via a rotational matrix.
 void setAxes(Vector3f left, Vector3f up, Vector3f direction)
          setAxes sets the axes that define the camera's orientation.
 void setDirection(Vector3f direction)
          setDirection sets the direction the camera is facing.
 void setFrame(Vector3f location, Quaternion axes)
          setFrame sets the view frame of the camera by setting the location and the orientation of the camera model.
 void setFrame(Vector3f location, Vector3f left, Vector3f up, Vector3f direction)
          setFrame sets the view frame of the camera by setting the location and orientation of the camera model.
 void setFrustum(float near, float far, float left, float right, float top, float bottom)
          setFrustum defines the frustum planes of the camera.
 void setFrustumBottom(float frustumBottom)
          setFrustumBottom sets the value of the bottom frustum plane.
 void setFrustumFar(float frustumFar)
          setFrustumFar sets the value of the far frustum plane.
 void setFrustumLeft(float frustumLeft)
          setFrustumLeft sets the value of the left frustum plane.
 void setFrustumNear(float frustumNear)
          setFrustumNear sets the value of the near frustum plane.
 void setFrustumPerspective(float fovY, float aspect, float near, float far)
          setFrustumPerspective defines the frustum for the camera.
 void setFrustumRight(float frustumRight)
          setFrustumRight sets the value of the right frustum plane.
 void setFrustumTop(float frustumTop)
          setFrustumTop sets the value of the top frustum plane.
 void setLeft(Vector3f left)
          setLeft sets the left axis of the camera.
 void setLocation(Vector3f location)
          setLocation the position of the camera.
 void setPlaneState(int planeState)
          setPlaneState sets the state to keep track of tested planes for culling.
 void setUp(Vector3f up)
          setUp sets the up axis of the camera.
 void setViewPort(float left, float right, float bottom, float top)
          setViewPort sets the boundaries of the viewport
 void setViewPortBottom(float bottom)
          setViewPortBottom sets the bottom boundary of the viewport
 void setViewPortLeft(float left)
          setViewPortLeft sets the left boundary of the viewport
 void setViewPortRight(float right)
          setViewPortRight sets the right boundary of the viewport
 void setViewPortTop(float top)
          setViewPortTop sets the top boundary of the viewport
 void update()
          update updates the frustum viewport and frame of the camera checking for any possible change in the position or orientation of the camera.
 

Field Detail

OUTSIDE_FRUSTUM

public static final int OUTSIDE_FRUSTUM
defines a constant assigned to spatials that are outside of this camera's view frustum.

See Also:
Constant Field Values

INTERSECTS_FRUSTUM

public static final int INTERSECTS_FRUSTUM
defines a constant assigned to spatials that are intersecting one of the six planes that define the view frustum.

See Also:
Constant Field Values

INSIDE_FRUSTUM

public static final int INSIDE_FRUSTUM
defines a constant assigned to spatials that are completely inside the camera's view frustum.

See Also:
Constant Field Values
Method Detail

getLocation

public Vector3f getLocation()
getLocation returns the position of the camera.

Returns:
the position of the camera.

getDirection

public Vector3f getDirection()
getDirection returns the direction the camera is facing.

Returns:
the direction this camera object is facing.

getLeft

public Vector3f getLeft()
getLeft returns the left axis of the camera.

Returns:
the left axis of this camera object.

getUp

public Vector3f getUp()
getUp returns the up axis of the camera.

Returns:
the up axis of this camera object.

setLocation

public void setLocation(Vector3f location)
setLocation the position of the camera.

Parameters:
location - the position of the camera.

setDirection

public void setDirection(Vector3f direction)
setDirection sets the direction the camera is facing.

Parameters:
direction - the new direction of the camera.

setLeft

public void setLeft(Vector3f left)
setLeft sets the left axis of the camera.

Parameters:
left - the new left axis of the camera.

setUp

public void setUp(Vector3f up)
setUp sets the up axis of the camera.

Parameters:
up - the new up axis of the camera.

setAxes

public void setAxes(Vector3f left,
                    Vector3f up,
                    Vector3f direction)
setAxes sets the axes that define the camera's orientation.

Parameters:
left - the new left axis of the camera.
up - the new up axis of the camera.
direction - the new direction of the camera.

setAxes

public void setAxes(Quaternion axes)
setAxes sets the camera's orientation via a rotational matrix.

Parameters:
axes - the matrix that defines the camera orientation.

setFrustum

public void setFrustum(float near,
                       float far,
                       float left,
                       float right,
                       float top,
                       float bottom)
setFrustum defines the frustum planes of the camera. This frustum is defined by a six-sided box.

Parameters:
near - the frustum plane closest to the eye point.
far - the frustum plane furthest from the eye point.
left - the frustum plane left of the eye point.
right - the frustum plane right of the eye point.
top - the frustum plane above the eye point.
bottom - the frustum plane below the eye point.

setFrustumPerspective

public void setFrustumPerspective(float fovY,
                                  float aspect,
                                  float near,
                                  float far)
setFrustumPerspective defines the frustum for the camera. This frustum is defined by a viewing angle, aspect ratio, and near/far planes

Parameters:
fovY - Frame of view angle along the Y.
aspect - Width:Height ratio
near - Near view plane distance
far - Far view plane distance

getFrustumBottom

public float getFrustumBottom()
getFrustumBottom returns the value of the bottom frustum plane.

Returns:
the value of the bottom frustum plane.

setFrustumBottom

public void setFrustumBottom(float frustumBottom)
setFrustumBottom sets the value of the bottom frustum plane.

Parameters:
frustumBottom - the value of the bottom frustum plane.

getFrustumFar

public float getFrustumFar()
getFrustumFar gets the value of the far frustum plane.

Returns:
the value of the far frustum plane.

setFrustumFar

public void setFrustumFar(float frustumFar)
setFrustumFar sets the value of the far frustum plane.

Parameters:
frustumFar - the value of the far frustum plane.

getFrustumLeft

public float getFrustumLeft()
getFrustumLeft gets the value of the left frustum plane.

Returns:
the value of the left frustum plane.

setFrustumLeft

public void setFrustumLeft(float frustumLeft)
setFrustumLeft sets the value of the left frustum plane.

Parameters:
frustumLeft - the value of the left frustum plane.

getFrustumNear

public float getFrustumNear()
getFrustumNear gets the value of the near frustum plane.

Returns:
the value of the near frustum plane.

setFrustumNear

public void setFrustumNear(float frustumNear)
setFrustumNear sets the value of the near frustum plane.

Parameters:
frustumNear - the value of the near frustum plane.

getFrustumRight

public float getFrustumRight()
getFrustumRight gets the value of the right frustum plane.

Returns:
frustumRight the value of the right frustum plane.

setFrustumRight

public void setFrustumRight(float frustumRight)
setFrustumRight sets the value of the right frustum plane.

Parameters:
frustumRight - the value of the right frustum plane.

getFrustumTop

public float getFrustumTop()
getFrustumTop gets the value of the top frustum plane.

Returns:
the value of the top frustum plane.

setFrustumTop

public void setFrustumTop(float frustumTop)
setFrustumTop sets the value of the top frustum plane.

Parameters:
frustumTop - the value of the top frustum plane.

setFrame

public void setFrame(Vector3f location,
                     Vector3f left,
                     Vector3f up,
                     Vector3f direction)
setFrame sets the view frame of the camera by setting the location and orientation of the camera model.

Parameters:
location - the position of the camera.
left - the left axis of the camera.
up - the up axis of the camera.
direction - the direction the camera is facing.

setFrame

public void setFrame(Vector3f location,
                     Quaternion axes)
setFrame sets the view frame of the camera by setting the location and the orientation of the camera model.

Parameters:
location - the position of the camera.
axes - the matrix that defines the orientation of the camera.

update

public void update()
update updates the frustum viewport and frame of the camera checking for any possible change in the position or orientation of the camera.


getPlaneState

public int getPlaneState()
getPlaneState returns the state of the frustum planes. So checks can be made as to which frustum plane has been examined for culling thus far.

Returns:
the current plane state int.

setPlaneState

public void setPlaneState(int planeState)
setPlaneState sets the state to keep track of tested planes for culling.

Parameters:
planeState - the updated state.

getViewPortLeft

public float getViewPortLeft()
getViewPortLeft gets the left boundary of the viewport

Returns:
the left boundary of the viewport

setViewPortLeft

public void setViewPortLeft(float left)
setViewPortLeft sets the left boundary of the viewport

Parameters:
left - the left boundary of the viewport

getViewPortRight

public float getViewPortRight()
getViewPortRight gets the right boundary of the viewport

Returns:
the right boundary of the viewport

setViewPortRight

public void setViewPortRight(float right)
setViewPortRight sets the right boundary of the viewport

Parameters:
right - the right boundary of the viewport

getViewPortTop

public float getViewPortTop()
getViewPortTop gets the top boundary of the viewport

Returns:
the top boundary of the viewport

setViewPortTop

public void setViewPortTop(float top)
setViewPortTop sets the top boundary of the viewport

Parameters:
top - the top boundary of the viewport

getViewPortBottom

public float getViewPortBottom()
getViewPortBottom gets the bottom boundary of the viewport

Returns:
the bottom boundary of the viewport

setViewPortBottom

public void setViewPortBottom(float bottom)
setViewPortBottom sets the bottom boundary of the viewport

Parameters:
bottom - the bottom boundary of the viewport

setViewPort

public void setViewPort(float left,
                        float right,
                        float bottom,
                        float top)
setViewPort sets the boundaries of the viewport

Parameters:
left - the left boundary of the viewport
right - the right boundary of the viewport
bottom - the bottom boundary of the viewport
top - the top boundary of the viewport

contains

public int contains(BoundingVolume bound)
culled tests a bounding volume against the planes of the camera's frustum. The frustums planes are set such that the normals all face in towards the viewable scene. Therefore, if the bounding volume is on the negative side of the plane is can be culled out. If the object should be culled (i.e. not rendered) true is returned, otherwise, false is returned.

Parameters:
bound - the bound to check for culling
Returns:
true if the bound should be culled, false otherwise.

onFrustumChange

public void onFrustumChange()
onFrustumChange is an update callback that is activated if the frustum values change.


onViewPortChange

public void onViewPortChange()
onViewPortChange is an update callback that is activated if the view port changes.


onFrameChange

public void onFrameChange()
onFrameChange is an update callback that is activated if the frame changes.


lookAt

public void lookAt(Vector3f pos)
lookAt is a convienence method for auto-setting the frame.

Parameters:
pos - Vector3f

resize

public void resize(int width,
                   int height)
resize resizes this cameras view with the given width/height. This is similar to constructing a new camera, but reusing the same Object.

Parameters:
width - int
height - int