|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jme.renderer.AbstractCamera
public abstract class AbstractCamera
AbstractCamera implments the Camera interface
implementing all non-API specific camera calculations. Those requiring API
(LWJGL, JOGL, etc) specific calls are not implemented making this class
abstract. API specific classes are expected to extend this class and handle
renderer viewport setting.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.jme.renderer.Camera |
|---|
Camera.FrustumIntersect |
| Field Summary | |
|---|---|
protected Matrix4f |
_modelView
|
protected Matrix4f |
_projection
|
protected Matrix4f |
_transMatrix
|
static int |
BOTTOM_PLANE
BOTTOM_PLANE represents the bottom plane of the camera frustum. |
protected float[] |
coeffBottom
|
protected float[] |
coeffLeft
|
protected float[] |
coeffRight
|
protected float[] |
coeffTop
|
protected Vector3f |
direction
Direction the camera is facing. |
static int |
FAR_PLANE
FAR_PLANE represents the far plane of the camera frustum. |
static int |
FRUSTUM_PLANES
FRUSTUM_PLANES represents the number of planes of the camera frustum. |
protected float |
frustumBottom
Distance from camera to bottom frustum plane. |
protected float |
frustumFar
Distance from camera to far frustum plane. |
protected float |
frustumLeft
Distance from camera to left frustum plane. |
protected float |
frustumNear
Distance from camera to near frustum plane. |
protected float |
frustumRight
Distance from camera to right frustum plane. |
protected float |
frustumTop
Distance from camera to top frustum plane. |
protected int |
height
|
protected Vector3f |
left
Direction of camera's 'left' |
static int |
LEFT_PLANE
LEFT_PLANE represents the left plane of the camera frustum. |
protected Vector3f |
location
Camera's location |
static int |
MAX_WORLD_PLANES
MAX_WORLD_PLANES holds the maximum planes allowed by the system. |
static int |
NEAR_PLANE
NEAR_PLANE represents the near plane of the camera frustum. |
protected Vector3f |
newDirection
Computation vector used in lookAt operations. |
protected int |
planeQuantity
|
static int |
RIGHT_PLANE
RIGHT_PLANE represents the right plane of the camera frustum. |
static int |
TOP_PLANE
TOP_PLANE represents the top plane of the camera frustum. |
protected Vector3f |
up
Direction of 'up' for camera. |
protected float |
viewPortBottom
Percent value on display where vertical viewing begins for this camera. |
protected float |
viewPortLeft
Percent value on display where horizontal viewing starts for this camera. |
protected float |
viewPortRight
Percent value on display where horizontal viewing ends for this camera. |
protected float |
viewPortTop
Percent value on display where vertical viewing ends for this camera. |
protected int |
width
|
protected Plane[] |
worldPlane
Array holding the planes that this camera will check for culling. |
| Constructor Summary | |
|---|---|
AbstractCamera()
Constructor instantiates a new AbstractCamera object. |
|
AbstractCamera(boolean dataOnly)
Constructor instantiates a new AbstractCamera object. |
|
| Method Summary | |
|---|---|
Camera.FrustumIntersect |
contains(BoundingVolume bound)
culled tests a bounding volume against the planes of the
camera's frustum. |
java.lang.Class<AbstractCamera> |
getClassTag()
The peristed type for the object. |
Vector3f |
getDirection()
getDirection retrieves the direction vector 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. |
abstract int |
getHeight()
|
Vector3f |
getLeft()
getLeft retrieves the left axis of the camera. |
Vector3f |
getLocation()
getLocation retrieves the location vector of the camera. |
Matrix4f |
getModelViewMatrix()
|
int |
getPlaneState()
getPlaneState returns the state of the frustum planes. |
Matrix4f |
getProjectionMatrix()
|
Vector3f |
getScreenCoordinates(Vector3f worldPos)
Convert world to screen coordinates. |
Vector3f |
getScreenCoordinates(Vector3f worldPosition,
Vector3f store)
Implementation contributed by Zbyl. |
Vector3f |
getUp()
getUp retrieves 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 |
abstract int |
getWidth()
|
Vector3f |
getWorldCoordinates(Vector2f screenPos,
float zPos)
Convert screen to world coordinates. |
Vector3f |
getWorldCoordinates(Vector2f screenPosition,
float zPos,
Vector3f store)
Convert screen to world coordinates. |
boolean |
isDataOnly()
|
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()
normalize normalizes the camera vectors. |
void |
onFrameChange()
onFrameChange updates the view frame of the camera. |
void |
onFrustumChange()
onFrustumChange updates the frustum to reflect any changes
made to the planes. |
void |
read(JMEImporter e)
|
void |
setAxes(Quaternion axes)
setAxes uses a rotational matrix to set the axes of the
camera. |
void |
setAxes(Vector3f left,
Vector3f up,
Vector3f direction)
setAxes sets the axes (left, up and direction) for this
camera. |
void |
setDataOnly(boolean dataOnly)
|
void |
setDirection(Vector3f direction)
setDirection sets the direction this camera is facing. |
void |
setFrame(Vector3f location,
Quaternion axes)
setFrame sets the orientation and location of the camera. |
void |
setFrame(Vector3f location,
Vector3f left,
Vector3f up,
Vector3f direction)
setFrame sets the orientation and location of the camera. |
void |
setFrustum(float near,
float far,
float left,
float right,
float top,
float bottom)
setFrustum sets the frustum of this camera object. |
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 this camera. |
void |
setLocation(Vector3f location)
setLocation sets 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 this 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 camera parameters by calling
onFrustumChange,onViewPortChange and
onFrameChange. |
void |
write(JMEExporter e)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.jme.renderer.Camera |
|---|
apply, onViewPortChange, resize |
| Field Detail |
|---|
public static final int LEFT_PLANE
public static final int RIGHT_PLANE
public static final int BOTTOM_PLANE
public static final int TOP_PLANE
public static final int FAR_PLANE
public static final int NEAR_PLANE
public static final int FRUSTUM_PLANES
public static final int MAX_WORLD_PLANES
protected Vector3f location
protected Vector3f left
protected Vector3f up
protected Vector3f direction
protected float frustumNear
protected float frustumFar
protected float frustumLeft
protected float frustumRight
protected float frustumTop
protected float frustumBottom
protected float[] coeffLeft
protected float[] coeffRight
protected float[] coeffBottom
protected float[] coeffTop
protected int planeQuantity
protected float viewPortLeft
protected float viewPortRight
protected float viewPortTop
protected float viewPortBottom
protected Plane[] worldPlane
protected Vector3f newDirection
protected int width
protected int height
protected final Matrix4f _transMatrix
protected final Matrix4f _modelView
protected final Matrix4f _projection
| Constructor Detail |
|---|
public AbstractCamera()
AbstractCamera object. All
values of the camera are set to default.
public AbstractCamera(boolean dataOnly)
AbstractCamera object. All
values of the camera are set to default.
| Method Detail |
|---|
public float getFrustumBottom()
getFrustumBottom returns the value of the bottom frustum
plane.
getFrustumBottom in interface Camerapublic void setFrustumBottom(float frustumBottom)
setFrustumBottom sets the value of the bottom frustum
plane.
setFrustumBottom in interface CamerafrustumBottom - the value of the bottom frustum plane.public float getFrustumFar()
getFrustumFar gets the value of the far frustum plane.
getFrustumFar in interface Camerapublic void setFrustumFar(float frustumFar)
setFrustumFar sets the value of the far frustum plane.
setFrustumFar in interface CamerafrustumFar - the value of the far frustum plane.public float getFrustumLeft()
getFrustumLeft gets the value of the left frustum plane.
getFrustumLeft in interface Camerapublic void setFrustumLeft(float frustumLeft)
setFrustumLeft sets the value of the left frustum plane.
setFrustumLeft in interface CamerafrustumLeft - the value of the left frustum plane.public float getFrustumNear()
getFrustumNear gets the value of the near frustum plane.
getFrustumNear in interface Camerapublic void setFrustumNear(float frustumNear)
setFrustumNear sets the value of the near frustum plane.
setFrustumNear in interface CamerafrustumNear - the value of the near frustum plane.public float getFrustumRight()
getFrustumRight gets the value of the right frustum plane.
getFrustumRight in interface Camerapublic void setFrustumRight(float frustumRight)
setFrustumRight sets the value of the right frustum plane.
setFrustumRight in interface CamerafrustumRight - the value of the right frustum plane.public float getFrustumTop()
getFrustumTop gets the value of the top frustum plane.
getFrustumTop in interface Camerapublic void setFrustumTop(float frustumTop)
setFrustumTop sets the value of the top frustum plane.
setFrustumTop in interface CamerafrustumTop - the value of the top frustum plane.public Vector3f getLocation()
getLocation retrieves the location vector of the camera.
getLocation in interface CameraCamera.getLocation()public Vector3f getDirection()
getDirection retrieves the direction vector the camera is
facing.
getDirection in interface CameraCamera.getDirection()public Vector3f getLeft()
getLeft retrieves the left axis of the camera.
getLeft in interface CameraCamera.getLeft()public Vector3f getUp()
getUp retrieves the up axis of the camera.
getUp in interface CameraCamera.getUp()public void setLocation(Vector3f location)
setLocation sets the position of the camera.
setLocation in interface Cameralocation - the position of the camera.Camera.setLocation(com.jme.math.Vector3f)public void setDirection(Vector3f direction)
setDirection sets the direction this camera is facing. In
most cases, this changes the up and left vectors of the camera. If your
left or up vectors change, you must updates those as well for correct
culling.
setDirection in interface Cameradirection - the direction this camera is facing.Camera.setDirection(com.jme.math.Vector3f)public void setLeft(Vector3f left)
setLeft sets the left axis of this camera. In most cases,
this changes the up and direction vectors of the camera. If your
direction or up vectors change, you must updates those as well for
correct culling.
setLeft in interface Cameraleft - the left axis of this camera.Camera.setLeft(com.jme.math.Vector3f)public void setUp(Vector3f up)
setUp sets the up axis of this camera. In most cases, this
changes the direction and left vectors of the camera. If your left or up
vectors change, you must updates those as well for correct culling.
setUp in interface Cameraup - the up axis of this camera.Camera.setUp(com.jme.math.Vector3f)
public void setAxes(Vector3f left,
Vector3f up,
Vector3f direction)
setAxes sets the axes (left, up and direction) for this
camera.
setAxes in interface Cameraleft - the left axis of the camera.up - the up axis of the camera.direction - the direction the camera is facing.Camera.setAxes(com.jme.math.Vector3f,com.jme.math.Vector3f,com.jme.math.Vector3f)public void setAxes(Quaternion axes)
setAxes uses a rotational matrix to set the axes of the
camera.
setAxes in interface Cameraaxes - the matrix that defines the orientation of the camera.public void normalize()
normalize in interface Camera
public void setFrustum(float near,
float far,
float left,
float right,
float top,
float bottom)
setFrustum sets the frustum of this camera object.
setFrustum in interface Cameranear - the near plane.far - the far plane.left - the left plane.right - the right plane.top - the top plane.bottom - the bottom plane.Camera.setFrustum(float, float, float, float,
float, float)
public void setFrustumPerspective(float fovY,
float aspect,
float near,
float far)
CamerasetFrustumPerspective defines the frustum for the camera. This
frustum is defined by a viewing angle, aspect ratio, and near/far planes
setFrustumPerspective in interface CamerafovY - Frame of view angle along the Y.aspect - Width:Height rationear - Near view plane distancefar - Far view plane distance
public void setFrame(Vector3f location,
Vector3f left,
Vector3f up,
Vector3f direction)
setFrame sets the orientation and location of the camera.
setFrame in interface Cameralocation - the point position of the camera.left - the left axis of the camera.up - the up axis of the camera.direction - the facing of the camera.Camera.setFrame(com.jme.math.Vector3f,
com.jme.math.Vector3f, com.jme.math.Vector3f, com.jme.math.Vector3f)
public 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.
lookAt in interface Camerapos - 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.)
public void setFrame(Vector3f location,
Quaternion axes)
setFrame sets the orientation and location of the camera.
setFrame in interface Cameralocation - the point position of the camera.axes - the orientation of the camera.public void update()
update updates the camera parameters by calling
onFrustumChange,onViewPortChange and
onFrameChange.
update in interface CameraCamera.update()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.
getPlaneState in interface Camerapublic void setPlaneState(int planeState)
setPlaneState sets the state to keep track of tested
planes for culling.
setPlaneState in interface CameraplaneState - the updated state.public float getViewPortLeft()
getViewPortLeft gets the left boundary of the viewport
getViewPortLeft in interface Camerapublic void setViewPortLeft(float left)
setViewPortLeft sets the left boundary of the viewport
setViewPortLeft in interface Cameraleft - the left boundary of the viewportpublic float getViewPortRight()
getViewPortRight gets the right boundary of the viewport
getViewPortRight in interface Camerapublic void setViewPortRight(float right)
setViewPortRight sets the right boundary of the viewport
setViewPortRight in interface Cameraright - the right boundary of the viewportpublic float getViewPortTop()
getViewPortTop gets the top boundary of the viewport
getViewPortTop in interface Camerapublic void setViewPortTop(float top)
setViewPortTop sets the top boundary of the viewport
setViewPortTop in interface Cameratop - the top boundary of the viewportpublic float getViewPortBottom()
getViewPortBottom gets the bottom boundary of the viewport
getViewPortBottom in interface Camerapublic void setViewPortBottom(float bottom)
setViewPortBottom sets the bottom boundary of the viewport
setViewPortBottom in interface Camerabottom - the bottom boundary of the viewport
public void setViewPort(float left,
float right,
float bottom,
float top)
setViewPort sets the boundaries of the viewport
setViewPort in interface Cameraleft - the left boundary of the viewportright - the right boundary of the viewportbottom - the bottom boundary of the viewporttop - the top boundary of the viewportpublic Camera.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. If bound is null, false is returned and the object will not
be culled.
contains in interface Camerabound - the bound to check for culling
public void onFrustumChange()
onFrustumChange updates the frustum to reflect any changes
made to the planes. The new frustum values are kept in a temporary
location for use when calculating the new frame. It should be noted that
the abstract implementation of this class only updates the data, and does
not make any rendering calls. As such, any impelmenting subclass should
insure to override this method call it with super and then call the
rendering specific code.
onFrustumChange in interface Camerapublic void onFrameChange()
onFrameChange updates the view frame of the camera. It
should be noted that the abstract implementation of this class only
updates the data, and does not make any rendering calls. As such, any
implementing subclass should insure to override this method call it with
super and then call the rendering specific code.
onFrameChange in interface Camerapublic boolean isParallelProjection()
isParallelProjection in interface CamerasetParallelProjection(boolean)public void setParallelProjection(boolean value)
setParallelProjection in interface Cameravalue - true to set up this camera for parallel projection is enable, false to enter normal perspective mode
public Vector3f getWorldCoordinates(Vector2f screenPos,
float zPos)
Camera
getWorldCoordinates in interface CamerascreenPos - Vector2f representing the screen position with 0,0 at the
bottom leftzPos - float The z position away from the viewing plane.
public Matrix4f getProjectionMatrix()
public Matrix4f getModelViewMatrix()
public Vector3f getWorldCoordinates(Vector2f screenPosition,
float zPos,
Vector3f store)
Camera
getWorldCoordinates in interface CamerascreenPosition - 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.
public Vector3f getScreenCoordinates(Vector3f worldPos)
Camera
getScreenCoordinates in interface CameraworldPos - Vector3f representing the world position
public Vector3f getScreenCoordinates(Vector3f worldPosition,
Vector3f store)
getScreenCoordinates in interface CameraworldPosition - Vector3f representing the world positionstore - Vector3f The vector to store the result in.
Camera.getScreenCoordinates(Vector3f, Vector3f)public abstract int getHeight()
public abstract int getWidth()
public void write(JMEExporter e)
throws java.io.IOException
write in interface Savablejava.io.IOException
public void read(JMEImporter e)
throws java.io.IOException
read in interface Savablejava.io.IOExceptionpublic java.lang.Class<AbstractCamera> getClassTag()
Savable
getClassTag in interface Savablepublic void setDataOnly(boolean dataOnly)
public boolean isDataOnly()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||