public class Camera extends FeaturableModel implements Viewer
Localizable
. Also, a view can be set to avoid useless rendering when
objects are outside of the camera view.
Camera construction order example:
Constructor and Description |
---|
Camera()
Create a camera.
|
Modifier and Type | Method and Description |
---|---|
void |
drawFov(Graphic g,
int x,
int y,
int gridH,
int gridV,
Surface surface)
Draw the camera field of view according to a grid.
|
int |
getHeight() |
double |
getMovementHorizontal()
Get the horizontal movement.
|
double |
getMovementVertical()
Get the horizontal movement.
|
int |
getScreenHeight() |
double |
getViewpointX(double x) |
double |
getViewpointY(double y) |
int |
getViewX() |
int |
getViewY() |
int |
getWidth() |
double |
getX() |
double |
getY() |
boolean |
isViewable(Localizable localizable,
int radiusX,
int radiusY) |
boolean |
isViewable(Shape shape,
int radiusX,
int radiusY) |
void |
moveLocation(double extrp,
double vx,
double vy)
Move camera by using specified vector.
|
void |
resetInterval(Localizable localizable)
Reset the camera interval to 0 by adapting its position.
|
void |
setIntervals(int intervalHorizontal,
int intervalVertical)
This represents the real position, between -interval and +interval.
|
void |
setLimits(Surface surface)
Define the maximum view limit.
|
void |
setLimits(SurfaceTile surface)
Define the maximum view limit.
|
void |
setLocation(double x,
double y)
Set the camera location.
|
void |
setView(int x,
int y,
int width,
int height,
int screenHeight)
Define the rendering area.
|
void |
teleport(double x,
double y)
Teleport the camera at the specified location and reset offset position.
|
addFeature, addFeatureAndGet, checkListener, clearCache, getFeature, getFeatures, getFeaturesType, getMedia, hasFeature
public void resetInterval(Localizable localizable)
localizable
- The localizable to center to.public void moveLocation(double extrp, double vx, double vy)
extrp
- The extrapolation value.vx
- The horizontal vector.vy
- The vertical vector.public void setLocation(double x, double y)
x
- The horizontal location.y
- The vertical location.public void teleport(double x, double y)
x
- The horizontal location.y
- The vertical location.public void drawFov(Graphic g, int x, int y, int gridH, int gridV, Surface surface)
g
- The graphic output.x
- The horizontal location.y
- The vertical location.gridH
- The horizontal grid.gridV
- The vertical grid.surface
- The surface referential (minimap).public void setIntervals(int intervalHorizontal, int intervalVertical)
For example: if the camera is following an object and the camera horizontal interval is 16, anything that is rendered using the camera view point will see its horizontal axis change when the object horizontal location will be before / after the camera location -16 / +16:
<--camera movement--> -16[..no camera movement..]+16 <--camera movement-->
intervalHorizontal
- The horizontal margin.intervalVertical
- The vertical margin.public void setView(int x, int y, int width, int height, int screenHeight)
For example:
(0, 0, 320, 240)
, and the tile size is 16
, then
20
horizontal tiles and 15
vertical tiles will be rendered from 0, 0
(screen top-left).(64, 64, 240, 160)
, and the tile size is 16
, then
15
horizontal tiles and 10
vertical tiles will be rendered from 64, 64
(screen top-left).
It is also compatible with object rendering (by using an Handler
). The
object which is outside the camera view will not be rendered. This avoid useless rendering.
Note: The rendering view is from the camera location. So x
and y
are an offset from
this location.
x
- The horizontal offset.y
- The vertical offset.width
- The rendering width (positive value).height
- The rendering height (positive value).screenHeight
- The screen height.public void setLimits(Surface surface)
Note: Must be called after set view (setView(int, int, int, int, int)
).
surface
- The surface reference.LionEngineException
- If null
surface.public void setLimits(SurfaceTile surface)
Note: Must be called after set view (setView(int, int, int, int, int)
).
surface
- The surface reference.LionEngineException
- If null
surface.public double getMovementHorizontal()
public double getMovementVertical()
public double getViewpointX(double x)
getViewpointX
in interface Viewer
public double getViewpointY(double y)
getViewpointY
in interface Viewer
public double getX()
getX
in interface Localizable
public double getY()
getY
in interface Localizable
public int getScreenHeight()
getScreenHeight
in interface Viewer
public boolean isViewable(Localizable localizable, int radiusX, int radiusY)
isViewable
in interface Viewer
public boolean isViewable(Shape shape, int radiusX, int radiusY)
isViewable
in interface Viewer
Copyright © 2017 Byron 3D Games Studio. All rights reserved.