|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Camera
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.
Nested Class Summary | |
---|---|
static class |
Camera.FrustumIntersect
|
Method Summary | |
---|---|
void |
apply()
Apply the settings of the camera to the current graphics state. |
Camera.FrustumIntersect |
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 |
getScreenCoordinates(Vector3f worldPosition)
Convert world to screen coordinates. |
Vector3f |
getScreenCoordinates(Vector3f worldPosition,
Vector3f store)
Convert world to screen coordinates. |
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 |
Vector3f |
getWorldCoordinates(Vector2f screenPosition,
float zPos)
Convert screen to world coordinates. |
Vector3f |
getWorldCoordinates(Vector2f screenPosition,
float zPos,
Vector3f store)
Convert screen to world coordinates. |
boolean |
isParallelProjection()
|
void |
lookAt(Vector3f pos,
Vector3f worldUpVector)
lookAt is a convienence method for auto-setting the frame
based on a world position the user desires the camera to look at. |
void |
normalize()
|
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)
Resizes this camera's view with the given width and 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 |
setParallelProjection(boolean value)
Enable/disable parallel projection. |
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. |
Methods inherited from interface com.jme.util.export.Savable |
---|
getClassTag, read, write |
Method Detail |
---|
Vector3f getLocation()
getLocation
returns the position of the camera.
Vector3f getDirection()
getDirection
returns the direction the camera is facing.
Vector3f getLeft()
getLeft
returns the left axis of the camera.
Vector3f getUp()
getUp
returns the up axis of the camera.
void setLocation(Vector3f location)
setLocation
the position of the camera.
location
- the position of the camera.void setDirection(Vector3f direction)
setDirection
sets the direction the camera is facing.
direction
- the new direction of the camera.void setLeft(Vector3f left)
setLeft
sets the left axis of the camera.
left
- the new left axis of the camera.void setUp(Vector3f up)
setUp
sets the up axis of the camera.
up
- the new up axis of the camera.void setAxes(Vector3f left, Vector3f up, Vector3f direction)
setAxes
sets the axes that define the camera's
orientation.
left
- the new left axis of the camera.up
- the new up axis of the camera.direction
- the new direction of the camera.void setAxes(Quaternion axes)
setAxes
sets the camera's orientation via a rotational
matrix.
axes
- the matrix that defines the camera orientation.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.
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.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
fovY
- Frame of view angle along the Y.aspect
- Width:Height rationear
- Near view plane distancefar
- Far view plane distancefloat getFrustumBottom()
getFrustumBottom
returns the value of the bottom frustum
plane.
void setFrustumBottom(float frustumBottom)
setFrustumBottom
sets the value of the bottom frustum
plane.
frustumBottom
- the value of the bottom frustum plane.float getFrustumFar()
getFrustumFar
gets the value of the far frustum plane.
void setFrustumFar(float frustumFar)
setFrustumFar
sets the value of the far frustum plane.
frustumFar
- the value of the far frustum plane.float getFrustumLeft()
getFrustumLeft
gets the value of the left frustum plane.
void setFrustumLeft(float frustumLeft)
setFrustumLeft
sets the value of the left frustum plane.
frustumLeft
- the value of the left frustum plane.float getFrustumNear()
getFrustumNear
gets the value of the near frustum plane.
void setFrustumNear(float frustumNear)
setFrustumNear
sets the value of the near frustum plane.
frustumNear
- the value of the near frustum plane.float getFrustumRight()
getFrustumRight
gets the value of the right frustum plane.
void setFrustumRight(float frustumRight)
setFrustumRight
sets the value of the right frustum plane.
frustumRight
- the value of the right frustum plane.float getFrustumTop()
getFrustumTop
gets the value of the top frustum plane.
void setFrustumTop(float frustumTop)
setFrustumTop
sets the value of the top frustum plane.
frustumTop
- the value of the top frustum plane.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.
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.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.
location
- the position of the camera.axes
- the matrix that defines the orientation of the camera.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.
void normalize()
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.
void setPlaneState(int planeState)
setPlaneState
sets the state to keep track of tested
planes for culling.
planeState
- the updated state.float getViewPortLeft()
getViewPortLeft
gets the left boundary of the viewport
void setViewPortLeft(float left)
setViewPortLeft
sets the left boundary of the viewport
left
- the left boundary of the viewportfloat getViewPortRight()
getViewPortRight
gets the right boundary of the viewport
void setViewPortRight(float right)
setViewPortRight
sets the right boundary of the viewport
right
- the right boundary of the viewportfloat getViewPortTop()
getViewPortTop
gets the top boundary of the viewport
void setViewPortTop(float top)
setViewPortTop
sets the top boundary of the viewport
top
- the top boundary of the viewportfloat getViewPortBottom()
getViewPortBottom
gets the bottom boundary of the viewport
void setViewPortBottom(float bottom)
setViewPortBottom
sets the bottom boundary of the viewport
bottom
- the bottom boundary of the viewportvoid setViewPort(float left, float right, float bottom, float top)
setViewPort
sets the boundaries of the viewport
left
- the left boundary of the viewportright
- the right boundary of the viewportbottom
- the bottom boundary of the viewporttop
- the top boundary of the viewportCamera.FrustumIntersect 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.
bound
- the bound to check for culling
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 onFrameChange()
onFrameChange
is an update callback that is activated if
the frame changes.
void lookAt(Vector3f pos, Vector3f worldUpVector)
lookAt
is a convienence method for auto-setting the frame
based on a world position the user desires the camera to look at. It
repoints the camera towards the given position using the difference
between the position and the current camera location as a direction
vector and the worldUpVector to compute up and left camera vectors.
pos
- where to look at in terms of world coordinatesworldUpVector
- a normalized vector indicating the up direction of the world.
(typically {0, 1, 0} in jME.)void resize(int width, int height)
width
- the view widthheight
- the view heightboolean isParallelProjection()
setParallelProjection(boolean)
void setParallelProjection(boolean value)
value
- true to set up this camera for parallel projection is enable, false to enter normal perspective modeVector3f getWorldCoordinates(Vector2f screenPosition, float zPos)
screenPosition
- Vector2f representing the screen position with 0,0 at the
bottom leftzPos
- float The z position away from the viewing plane.
Vector3f getWorldCoordinates(Vector2f screenPosition, float zPos, Vector3f store)
screenPosition
- Vector2f representing the screen position with 0,0 at the
bottom leftzPos
- float The z position away from the viewing plane.store
- Vector3f The vector to store the result in.
Vector3f getScreenCoordinates(Vector3f worldPosition)
worldPosition
- Vector3f representing the world position
Vector3f getScreenCoordinates(Vector3f worldPosition, Vector3f store)
worldPosition
- Vector3f representing the world positionstore
- Vector3f The vector to store the result in.
void apply()
If state should be applied even if not dirty, make sure to call update()
before.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |