|
||||||||||
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()
|
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 Camera
public void setFrustumBottom(float frustumBottom)
setFrustumBottom
sets the value of the bottom frustum
plane.
setFrustumBottom
in interface Camera
frustumBottom
- the value of the bottom frustum plane.public float getFrustumFar()
getFrustumFar
gets the value of the far frustum plane.
getFrustumFar
in interface Camera
public void setFrustumFar(float frustumFar)
setFrustumFar
sets the value of the far frustum plane.
setFrustumFar
in interface Camera
frustumFar
- the value of the far frustum plane.public float getFrustumLeft()
getFrustumLeft
gets the value of the left frustum plane.
getFrustumLeft
in interface Camera
public void setFrustumLeft(float frustumLeft)
setFrustumLeft
sets the value of the left frustum plane.
setFrustumLeft
in interface Camera
frustumLeft
- the value of the left frustum plane.public float getFrustumNear()
getFrustumNear
gets the value of the near frustum plane.
getFrustumNear
in interface Camera
public void setFrustumNear(float frustumNear)
setFrustumNear
sets the value of the near frustum plane.
setFrustumNear
in interface Camera
frustumNear
- the value of the near frustum plane.public float getFrustumRight()
getFrustumRight
gets the value of the right frustum plane.
getFrustumRight
in interface Camera
public void setFrustumRight(float frustumRight)
setFrustumRight
sets the value of the right frustum plane.
setFrustumRight
in interface Camera
frustumRight
- the value of the right frustum plane.public float getFrustumTop()
getFrustumTop
gets the value of the top frustum plane.
getFrustumTop
in interface Camera
public void setFrustumTop(float frustumTop)
setFrustumTop
sets the value of the top frustum plane.
setFrustumTop
in interface Camera
frustumTop
- the value of the top frustum plane.public Vector3f getLocation()
getLocation
retrieves the location vector of the camera.
getLocation
in interface Camera
Camera.getLocation()
public Vector3f getDirection()
getDirection
retrieves the direction vector the camera is
facing.
getDirection
in interface Camera
Camera.getDirection()
public Vector3f getLeft()
getLeft
retrieves the left axis of the camera.
getLeft
in interface Camera
Camera.getLeft()
public Vector3f getUp()
getUp
retrieves the up axis of the camera.
getUp
in interface Camera
Camera.getUp()
public void setLocation(Vector3f location)
setLocation
sets the position of the camera.
setLocation
in interface Camera
location
- 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 Camera
direction
- 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 Camera
left
- 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 Camera
up
- 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 Camera
left
- 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 Camera
axes
- 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 Camera
near
- 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)
Camera
setFrustumPerspective
defines the frustum for the camera. This
frustum is defined by a viewing angle, aspect ratio, and near/far planes
setFrustumPerspective
in interface Camera
fovY
- Frame of view angle along the Y.aspect
- Width:Height rationear
- Near view plane distancefar
- Far view plane distancepublic void setFrame(Vector3f location, Vector3f left, Vector3f up, Vector3f direction)
setFrame
sets the orientation and location of the camera.
setFrame
in interface Camera
location
- 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 Camera
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.)public void setFrame(Vector3f location, Quaternion axes)
setFrame
sets the orientation and location of the camera.
setFrame
in interface Camera
location
- 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 Camera
Camera.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 Camera
public void setPlaneState(int planeState)
setPlaneState
sets the state to keep track of tested
planes for culling.
setPlaneState
in interface Camera
planeState
- the updated state.public float getViewPortLeft()
getViewPortLeft
gets the left boundary of the viewport
getViewPortLeft
in interface Camera
public void setViewPortLeft(float left)
setViewPortLeft
sets the left boundary of the viewport
setViewPortLeft
in interface Camera
left
- the left boundary of the viewportpublic float getViewPortRight()
getViewPortRight
gets the right boundary of the viewport
getViewPortRight
in interface Camera
public void setViewPortRight(float right)
setViewPortRight
sets the right boundary of the viewport
setViewPortRight
in interface Camera
right
- the right boundary of the viewportpublic float getViewPortTop()
getViewPortTop
gets the top boundary of the viewport
getViewPortTop
in interface Camera
public void setViewPortTop(float top)
setViewPortTop
sets the top boundary of the viewport
setViewPortTop
in interface Camera
top
- the top boundary of the viewportpublic float getViewPortBottom()
getViewPortBottom
gets the bottom boundary of the viewport
getViewPortBottom
in interface Camera
public void setViewPortBottom(float bottom)
setViewPortBottom
sets the bottom boundary of the viewport
setViewPortBottom
in interface Camera
bottom
- the bottom boundary of the viewportpublic void setViewPort(float left, float right, float bottom, float top)
setViewPort
sets the boundaries of the viewport
setViewPort
in interface Camera
left
- 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 Camera
bound
- 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 Camera
public 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 Camera
public boolean isParallelProjection()
isParallelProjection
in interface Camera
setParallelProjection(boolean)
public void setParallelProjection(boolean value)
setParallelProjection
in interface Camera
value
- true to set up this camera for parallel projection is enable, false to enter normal perspective modepublic Vector3f getWorldCoordinates(Vector2f screenPos, float zPos)
Camera
getWorldCoordinates
in interface Camera
screenPos
- 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 Camera
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.
public Vector3f getScreenCoordinates(Vector3f worldPos)
Camera
getScreenCoordinates
in interface Camera
worldPos
- Vector3f representing the world position
public Vector3f getScreenCoordinates(Vector3f worldPosition, Vector3f store)
getScreenCoordinates
in interface Camera
worldPosition
- 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 Savable
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
java.io.IOException
public java.lang.Class<AbstractCamera> getClassTag()
getClassTag
in interface Savable
public void setDataOnly(boolean dataOnly)
public boolean isDataOnly()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |