public abstract class Camera extends Object
OrthographicCamera
and PerspectiveCamera
.Modifier and Type | Field and Description |
---|---|
Matrix4 |
combined
the combined projection and view matrix
|
Vector3 |
direction
the unit length direction vector of the camera
|
float |
far
the far clipping plane distance, has to be positive
|
Frustum |
frustum
the frustum
|
Matrix4 |
invProjectionView
the inverse combined projection and view matrix
|
float |
near
the near clipping plane distance, has to be positive
|
Vector3 |
position
the position of the camera
|
Matrix4 |
projection
the projection matrix
|
Vector3 |
up
the unit length up vector of the camera
|
Matrix4 |
view
the view matrix
|
float |
viewportHeight
the viewport height
|
float |
viewportWidth
the viewport width
|
Constructor and Description |
---|
Camera() |
Modifier and Type | Method and Description |
---|---|
Ray |
getPickRay(float screenX,
float screenY)
Creates a picking
Ray from the coordinates given in screen coordinates. |
Ray |
getPickRay(float screenX,
float screenY,
float viewportX,
float viewportY,
float viewportWidth,
float viewportHeight)
Creates a picking
Ray from the coordinates given in screen coordinates. |
void |
lookAt(float x,
float y,
float z)
Recalculates the direction of the camera to look at the point (x, y, z).
|
void |
lookAt(Vector3 target)
Recalculates the direction of the camera to look at the point (x, y, z).
|
void |
normalizeUp()
Normalizes the up vector by first calculating the right vector via a cross product between direction and up, and then
recalculating the up vector via a cross product between right and direction.
|
Vector3 |
project(Vector3 worldCoords)
Projects the
Vector3 given in world space to screen coordinates. |
Vector3 |
project(Vector3 worldCoords,
float viewportX,
float viewportY,
float viewportWidth,
float viewportHeight)
Projects the
Vector3 given in world space to screen coordinates. |
void |
rotate(float angle,
float axisX,
float axisY,
float axisZ)
Rotates the direction and up vector of this camera by the given angle around the given axis.
|
void |
rotate(Matrix4 transform)
Rotates the direction and up vector of this camera by the given rotation matrix.
|
void |
rotate(Quaternion quat)
Rotates the direction and up vector of this camera by the given
Quaternion . |
void |
rotate(Vector3 axis,
float angle)
Rotates the direction and up vector of this camera by the given angle around the given axis.
|
void |
rotateAround(Vector3 point,
Vector3 axis,
float angle)
Rotates the direction and up vector of this camera by the given angle around the given axis, with the axis attached to given
point.
|
void |
transform(Matrix4 transform)
Transform the position, direction and up vector by the given matrix
|
void |
translate(float x,
float y,
float z)
Moves the camera by the given amount on each axis.
|
void |
translate(Vector3 vec)
Moves the camera by the given vector.
|
Vector3 |
unproject(Vector3 screenCoords)
Function to translate a point given in screen coordinates to world space.
|
Vector3 |
unproject(Vector3 screenCoords,
float viewportX,
float viewportY,
float viewportWidth,
float viewportHeight)
Function to translate a point given in screen coordinates to world space.
|
abstract void |
update()
Recalculates the projection and view matrix of this camera and the
Frustum planes. |
abstract void |
update(boolean updateFrustum)
Recalculates the projection and view matrix of this camera and the
Frustum planes if updateFrustum is
true. |
public final Vector3 position
public final Vector3 direction
public final Vector3 up
public final Matrix4 projection
public final Matrix4 view
public final Matrix4 combined
public final Matrix4 invProjectionView
public float near
public float far
public float viewportWidth
public float viewportHeight
public final Frustum frustum
public abstract void update()
Frustum
planes. Use this after you've manipulated
any of the attributes of the camera.public abstract void update(boolean updateFrustum)
Frustum
planes if updateFrustum
is
true. Use this after you've manipulated any of the attributes of the camera.public void lookAt(float x, float y, float z)
x
- the x-coordinate of the point to look aty
- the x-coordinate of the point to look atz
- the x-coordinate of the point to look atpublic void lookAt(Vector3 target)
target
- the point to look atpublic void normalizeUp()
public void rotate(float angle, float axisX, float axisY, float axisZ)
angle
- the angleaxisX
- the x-component of the axisaxisY
- the y-component of the axisaxisZ
- the z-component of the axispublic void rotate(Vector3 axis, float angle)
axis
- the axis to rotate aroundangle
- the anglepublic void rotate(Matrix4 transform)
transform
- The rotation matrixpublic void rotate(Quaternion quat)
Quaternion
. The direction and up vector will not be
orthogonalized.quat
- The quaternionpublic void rotateAround(Vector3 point, Vector3 axis, float angle)
point
- the point to attach the axis toaxis
- the axis to rotate aroundangle
- the anglepublic void transform(Matrix4 transform)
transform
- The transform matrixpublic void translate(float x, float y, float z)
x
- the displacement on the x-axisy
- the displacement on the y-axisz
- the displacement on the z-axispublic void translate(Vector3 vec)
vec
- the displacement vectorpublic Vector3 unproject(Vector3 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
Input
. A z-coordinate of 0 will return a
point on the near plane, a z-coordinate of 1 will return a point on the far plane. This method allows you to specify the
viewport position and dimensions in the coordinate system expected by GL20.glViewport(int, int, int, int)
, with the
origin in the bottom left corner of the screen.screenCoords
- the point in screen coordinates (origin top left)viewportX
- the coordinate of the bottom left corner of the viewport in glViewport coordinates.viewportY
- the coordinate of the bottom left corner of the viewport in glViewport coordinates.viewportWidth
- the width of the viewport in pixelsviewportHeight
- the height of the viewport in pixelspublic Vector3 unproject(Vector3 screenCoords)
Graphics.getWidth()
and
Graphics.getHeight()
. The x- and y-coordinate of vec are assumed to be in screen coordinates (origin is the top left
corner, y pointing down, x pointing to the right) as reported by the touch methods in Input
. A z-coordinate of 0
will return a point on the near plane, a z-coordinate of 1 will return a point on the far plane.screenCoords
- the point in screen coordinatespublic Vector3 project(Vector3 worldCoords)
Vector3
given in world space to screen coordinates. It's the same as GLU gluProject with one small
deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the
bottom left, with the y-axis pointing upwards and the x-axis pointing to the right. This makes it easily
useable in conjunction with Batch
and similar classes.public Vector3 project(Vector3 worldCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
Vector3
given in world space to screen coordinates. It's the same as GLU gluProject with one small
deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the
bottom left, with the y-axis pointing upwards and the x-axis pointing to the right. This makes it easily
useable in conjunction with Batch
and similar classes. This method allows you to specify the viewport position and
dimensions in the coordinate system expected by GL20.glViewport(int, int, int, int)
, with the origin in the bottom
left corner of the screen.viewportX
- the coordinate of the bottom left corner of the viewport in glViewport coordinates.viewportY
- the coordinate of the bottom left corner of the viewport in glViewport coordinates.viewportWidth
- the width of the viewport in pixelsviewportHeight
- the height of the viewport in pixelspublic Ray getPickRay(float screenX, float screenY, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
Ray
from the coordinates given in screen coordinates. It is assumed that the viewport spans the
whole screen. The screen coordinates origin is assumed to be in the top left corner, its y-axis pointing down, the x-axis
pointing to the right. The returned instance is not a new instance but an internal member only accessible via this function.viewportX
- the coordinate of the bottom left corner of the viewport in glViewport coordinates.viewportY
- the coordinate of the bottom left corner of the viewport in glViewport coordinates.viewportWidth
- the width of the viewport in pixelsviewportHeight
- the height of the viewport in pixelspublic Ray getPickRay(float screenX, float screenY)
Ray
from the coordinates given in screen coordinates. It is assumed that the viewport spans the
whole screen. The screen coordinates origin is assumed to be in the top left corner, its y-axis pointing down, the x-axis
pointing to the right. The returned instance is not a new instance but an internal member only accessible via this function.Copyright © 2015. All rights reserved.