public abstract class Viewport extends Object
Camera
and determines how world coordinates are mapped to and from the screen.Constructor and Description |
---|
Viewport() |
Modifier and Type | Method and Description |
---|---|
void |
apply()
Calls
apply(boolean) with false. |
void |
apply(boolean centerCamera)
Applies the viewport to the camera and sets the glViewport.
|
void |
calculateScissors(Matrix4 batchTransform,
Rectangle area,
Rectangle scissor) |
int |
getBottomGutterHeight()
Returns the bottom gutter (black bar) height in screen coordinates.
|
Camera |
getCamera() |
int |
getLeftGutterWidth()
Returns the left gutter (black bar) width in screen coordinates.
|
Ray |
getPickRay(float screenX,
float screenY) |
int |
getRightGutterWidth()
Returns the right gutter (black bar) width in screen coordinates.
|
int |
getRightGutterX()
Returns the right gutter (black bar) x in screen coordinates.
|
int |
getScreenHeight() |
int |
getScreenWidth() |
int |
getScreenX() |
int |
getScreenY() |
int |
getTopGutterHeight()
Returns the top gutter (black bar) height in screen coordinates.
|
int |
getTopGutterY()
Returns the top gutter (black bar) y in screen coordinates.
|
float |
getWorldHeight() |
float |
getWorldWidth() |
Vector2 |
project(Vector2 worldCoords)
Transforms the specified world coordinate to screen coordinates.
|
Vector3 |
project(Vector3 worldCoords)
Transforms the specified world coordinate to screen coordinates.
|
void |
setCamera(Camera camera) |
void |
setScreenBounds(int screenX,
int screenY,
int screenWidth,
int screenHeight)
Sets the viewport's bounds in screen coordinates.
|
void |
setScreenHeight(int screenHeight)
Sets the viewport's height in screen coordinates.
|
void |
setScreenPosition(int screenX,
int screenY)
Sets the viewport's position in screen coordinates.
|
void |
setScreenSize(int screenWidth,
int screenHeight)
Sets the viewport's size in screen coordinates.
|
void |
setScreenWidth(int screenWidth)
Sets the viewport's width in screen coordinates.
|
void |
setScreenX(int screenX)
Sets the viewport's offset from the left edge of the screen.
|
void |
setScreenY(int screenY)
Sets the viewport's offset from the bottom edge of the screen.
|
void |
setWorldHeight(float worldHeight)
The virtual height of this viewport in world coordinates.
|
void |
setWorldSize(float worldWidth,
float worldHeight) |
void |
setWorldWidth(float worldWidth)
The virtual width of this viewport in world coordinates.
|
Vector2 |
toScreenCoordinates(Vector2 worldCoords,
Matrix4 transformMatrix)
Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top
left and the the y-axis is pointing downwards.
|
Vector2 |
unproject(Vector2 screenCoords)
Transforms the specified screen coordinate to world coordinates.
|
Vector3 |
unproject(Vector3 screenCoords)
Transforms the specified screen coordinate to world coordinates.
|
void |
update(int screenWidth,
int screenHeight)
Calls
update(int, int, boolean) with false. |
void |
update(int screenWidth,
int screenHeight,
boolean centerCamera)
Configures this viewport's screen bounds using the specified screen size and calls
apply(boolean) . |
public void apply()
apply(boolean)
with false.public void apply(boolean centerCamera)
centerCamera
- If true, the camera position is set to the center of the world.public final void update(int screenWidth, int screenHeight)
update(int, int, boolean)
with false.public void update(int screenWidth, int screenHeight, boolean centerCamera)
apply(boolean)
. Typically called
from ApplicationListener.resize(int, int)
or Screen.resize(int, int)
.
The default implementation only calls apply(boolean)
.
public Vector2 unproject(Vector2 screenCoords)
Camera.unproject(Vector3)
public Vector2 project(Vector2 worldCoords)
Camera.project(Vector3)
public Vector3 unproject(Vector3 screenCoords)
Camera.unproject(Vector3)
public Vector3 project(Vector3 worldCoords)
Camera.project(Vector3)
public Ray getPickRay(float screenX, float screenY)
public void calculateScissors(Matrix4 batchTransform, Rectangle area, Rectangle scissor)
public Vector2 toScreenCoordinates(Vector2 worldCoords, Matrix4 transformMatrix)
public Camera getCamera()
public void setCamera(Camera camera)
public float getWorldWidth()
public void setWorldWidth(float worldWidth)
public float getWorldHeight()
public void setWorldHeight(float worldHeight)
public void setWorldSize(float worldWidth, float worldHeight)
public int getScreenX()
public void setScreenX(int screenX)
update(int, int, boolean)
.public int getScreenY()
public void setScreenY(int screenY)
update(int, int, boolean)
.public int getScreenWidth()
public void setScreenWidth(int screenWidth)
update(int, int, boolean)
.public int getScreenHeight()
public void setScreenHeight(int screenHeight)
update(int, int, boolean)
.public void setScreenPosition(int screenX, int screenY)
update(int, int, boolean)
.public void setScreenSize(int screenWidth, int screenHeight)
update(int, int, boolean)
.public void setScreenBounds(int screenX, int screenY, int screenWidth, int screenHeight)
update(int, int, boolean)
.public int getLeftGutterWidth()
public int getRightGutterX()
public int getRightGutterWidth()
public int getBottomGutterHeight()
public int getTopGutterY()
public int getTopGutterHeight()
Copyright © 2014. All rights reserved.