Package arc.graphics
Class Camera
java.lang.Object
arc.graphics.Camera
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionSets the specified rectangle to this camera's bounds.project
(float screenX, float screenY) Seeproject(Vec2)
.Projects theVec3
given in world space to screen coordinates.project
(Vec2 worldCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight) Projects theVec3
given in world space to screen coordinates.void
resize
(float viewportWidth, float viewportHeight) unproject
(float screenX, float screenY) Seeunproject(Vec2)
.Function to translate a point given in screen coordinates to world space.unproject
(Vec2 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight) Function to translate a point given in screen coordinates to world space.void
update()
Recalculates the projection and view matrix of this camera.
-
Field Details
-
position
the position of the camera -
mat
the view matrix -
inv
the inverse view matrix -
width
public float widththe viewport width and height -
height
public float heightthe viewport width and height
-
-
Constructor Details
-
Camera
public Camera()
-
-
Method Details
-
update
public void update()Recalculates the projection and view matrix of this camera. Use this after you've manipulated any of the attributes of the camera. -
resize
public void resize(float viewportWidth, float viewportHeight) -
unproject
public Vec2 unproject(Vec2 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight) Function to translate a point given in screen coordinates to world space. It's the same as GLU gluUnProject, but does not rely on OpenGL. The x- and y-coordinate of vec are assumed to be in screen coordinates (origin is the bottom left corner, y pointing up, x pointing to the right) as reported by the touch methods inInput
. 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 byGL20.glViewport(int, int, int, int)
, with the origin in the bottom left corner of the screen.- Parameters:
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 pixels- Returns:
- the mutated and unprojected screenCoords
Vec3
-
unproject
Function to translate a point given in screen coordinates to world space. It's the same as GLU gluUnProject but does not rely on OpenGL. The viewport is assumed to span the whole screen and is fetched fromGraphics.getWidth()
andGraphics.getHeight()
. The x- and y-coordinate of vec are assumed to be in screen coordinates (origin is the bottom left corner, y pointing up, x pointing to the right) as reported by the touch methods inInput
. 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.- Parameters:
screenCoords
- the point in screen coordinates- Returns:
- the mutated and unprojected screenCoords
Vec3
-
unproject
Seeunproject(Vec2)
. Returns the same Vec2 each time. -
project
Projects theVec3
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.- Returns:
- the mutated and projected worldCoords
Vec3
-
project
Seeproject(Vec2)
. Returns the same Vec2 each time. -
project
public Vec2 project(Vec2 worldCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight) Projects theVec3
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 method allows you to specify the viewport position and dimensions in the coordinate system expected byGL20.glViewport(int, int, int, int)
, with the origin in the bottom left corner of the screen.- Parameters:
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 pixels- Returns:
- the mutated and projected worldCoords
Vec3
-
bounds
Sets the specified rectangle to this camera's bounds.
-