com.badlogic.gdx.utils.viewport
Class Viewport

java.lang.Object
  extended by com.badlogic.gdx.utils.viewport.Viewport
Direct Known Subclasses:
ExtendViewport, ScalingViewport, ScreenViewport

public abstract class Viewport
extends Object

Manages a Camera and determines how world coordinates are mapped to and from the screen.

Author:
Daniel Holderbaum, Nathan Sweet

Constructor Summary
Viewport()
           
 
Method Summary
 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 getTopGutterHeight()
          Returns the top gutter (black bar) height in screen coordinates.
 int getTopGutterY()
          Returns the top gutter (black bar) y in screen coordinates.
 int getViewportHeight()
           
 int getViewportWidth()
           
 int getViewportX()
           
 int getViewportY()
           
 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 setWorldHeight(float worldHeight)
           
 void setWorldSize(float worldWidth, float worldHeight)
           
 void setWorldWidth(float worldWidth)
           
 Vector2 toScreenCoordinates(Vector2 worldCoords, Matrix4 transformMatrix)
          Transforms a point to real screen coordinates (as oposed 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()
          Updates the viewport using the last computed values without changing the camera position.
 void update(int screenWidth, int screenHeight)
          Updates the viewport's camera without changing the camera position.
 void update(int screenWidth, int screenHeight, boolean centerCamera)
          Updates the viewport's camera.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Viewport

public Viewport()
Method Detail

update

public final void update()
Updates the viewport using the last computed values without changing the camera position.


update

public final void update(int screenWidth,
                         int screenHeight)
Updates the viewport's camera without changing the camera position.

See Also:
update(int, int, boolean)

update

public void update(int screenWidth,
                   int screenHeight,
                   boolean centerCamera)
Updates the viewport's camera. Typically called from ApplicationListener#resize(int, int) or Screen#resize(int, int).

The default implementation calls GL20.glViewport(int, int, int, int) and configures the camera viewport size.

Parameters:
centerCamera - If true, the camera position is set to the center of the world.

unproject

public Vector2 unproject(Vector2 screenCoords)
Transforms the specified screen coordinate to world coordinates.

Returns:
The vector that was passed in, transformed to world coordinates.
See Also:
Camera.unproject(Vector3)

project

public Vector2 project(Vector2 worldCoords)
Transforms the specified world coordinate to screen coordinates.

Returns:
The vector that was passed in, transformed to screen coordinates.
See Also:
Camera.project(Vector3)

unproject

public Vector3 unproject(Vector3 screenCoords)
Transforms the specified screen coordinate to world coordinates.

Returns:
The vector that was passed in, transformed to world coordinates.
See Also:
Camera.unproject(Vector3)

project

public Vector3 project(Vector3 worldCoords)
Transforms the specified world coordinate to screen coordinates.

Returns:
The vector that was passed in, transformed to screen coordinates.
See Also:
Camera.project(Vector3)

getPickRay

public Ray getPickRay(float screenX,
                      float screenY)
See Also:
Camera.getPickRay(float, float, float, float, float, float)

calculateScissors

public void calculateScissors(Matrix4 batchTransform,
                              Rectangle area,
                              Rectangle scissor)
See Also:
ScissorStack.calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle)

toScreenCoordinates

public Vector2 toScreenCoordinates(Vector2 worldCoords,
                                   Matrix4 transformMatrix)
Transforms a point to real screen coordinates (as oposed to OpenGL ES window coordinates), where the origin is in the top left and the the y-axis is pointing downwards.


getCamera

public Camera getCamera()

setCamera

public void setCamera(Camera camera)

setWorldSize

public void setWorldSize(float worldWidth,
                         float worldHeight)

getWorldWidth

public float getWorldWidth()

setWorldWidth

public void setWorldWidth(float worldWidth)

getWorldHeight

public float getWorldHeight()

setWorldHeight

public void setWorldHeight(float worldHeight)

getViewportX

public int getViewportX()

getViewportY

public int getViewportY()

getViewportWidth

public int getViewportWidth()

getViewportHeight

public int getViewportHeight()

getLeftGutterWidth

public int getLeftGutterWidth()
Returns the left gutter (black bar) width in screen coordinates.


getRightGutterX

public int getRightGutterX()
Returns the right gutter (black bar) x in screen coordinates.


getRightGutterWidth

public int getRightGutterWidth()
Returns the right gutter (black bar) width in screen coordinates.


getBottomGutterHeight

public int getBottomGutterHeight()
Returns the bottom gutter (black bar) height in screen coordinates.


getTopGutterY

public int getTopGutterY()
Returns the top gutter (black bar) y in screen coordinates.


getTopGutterHeight

public int getTopGutterHeight()
Returns the top gutter (black bar) height in screen coordinates.



Copyright © 2014. All Rights Reserved.