#include <camera.h>
Public Member Functions | |
Camera (const std::string &id, Layer *layer, const Rect &viewport, const ExactModelCoordinate &emc, RenderBackend *renderbackend, ImagePool *ipool, AnimationPool *apool) | |
virtual | ~Camera () |
const std::string & | getId () const |
void | setId (const std::string &id) |
void | setTilt (double tilt) |
double | getTilt () const |
void | setRotation (double rotation) |
double | getRotation () const |
void | setZoom (double zoom) |
double | getZoom () const |
void | setCellImageDimensions (unsigned int width, unsigned int height) |
Point | getCellImageDimensions () |
Point | getCellImageDimensions (Layer *layer) |
void | setLocation (const Location &location) |
Location | getLocation () const |
Location & | getLocationRef () |
void | attach (Instance *instance) |
void | detach () |
Instance * | getAttached () const |
void | setViewPort (const Rect &viewport) |
const Rect & | getViewPort () const |
ExactModelCoordinate | toMapCoordinates (ScreenPoint screen_coords, bool z_calculated=true) |
ScreenPoint | toScreenCoordinates (ExactModelCoordinate map_coords) |
void | setEnabled (bool enabled) |
bool | isEnabled () |
void | getMatchingInstances (ScreenPoint screen_coords, Layer &layer, std::list< Instance * > &instances) |
void | getMatchingInstances (Rect screen_rect, Layer &layer, std::list< Instance * > &instances) |
void | getMatchingInstances (Location &loc, std::list< Instance * > &instances, bool use_exactcoordinates=false) |
void | update () |
void | refresh () |
void | resetUpdates () |
void | addRenderer (RendererBase *renderer) |
RendererBase * | getRenderer (const std::string &name) |
void | resetRenderers () |
void | calculateZValue (ScreenPoint &screen_coords) |
void | onRendererPipelinePositionChanged (RendererBase *renderer) |
void | onRendererEnabledChanged (RendererBase *renderer) |
void | render () |
Camera describes properties of a view port shown in the main screen Main screen can have multiple cameras active simultanously Different cameras can have different properties, like location to shoot, zoom or tilt
Definition at line 57 of file camera.h.
FIFE::Camera::Camera | ( | const std::string & | id, | |
Layer * | layer, | |||
const Rect & | viewport, | |||
const ExactModelCoordinate & | emc, | |||
RenderBackend * | renderbackend, | |||
ImagePool * | ipool, | |||
AnimationPool * | apool | |||
) |
Constructor Camera needs to be added to the view. If not done so, it is not rendered.
id | identifier for the camera | |
layer | layer where camera is bound. Camera is bound to a layer for two reasons: * camera's scaling is done based on cell image dimensions. Cell image is layer based ( |
viewport | used viewport for the camera. Viewport is measured in pixels in relation to game main screen | |
emc | coordinate, where camera is focused on given layer | |
renderbackend | to use with rendering | |
ipool | to use with rendering | |
apool | to use with rendering |
Definition at line 55 of file camera.cpp.
FIFE::Camera::~Camera | ( | ) | [virtual] |
Destructor
Definition at line 91 of file camera.cpp.
void FIFE::Camera::addRenderer | ( | RendererBase * | renderer | ) |
Adds new renderer on the view. Ownership is transferred to the camera.
Definition at line 421 of file camera.cpp.
Referenced by FIFE::Map::addCamera().
void FIFE::Camera::attach | ( | Instance * | instance | ) |
Attaches the camera to an instance.
instance | Instance to which the camera shall be attached |
Definition at line 384 of file camera.cpp.
void FIFE::Camera::calculateZValue | ( | ScreenPoint & | screen_coords | ) |
calculates z-value for given screenpoint
Definition at line 228 of file camera.cpp.
void FIFE::Camera::detach | ( | ) |
Detaches the camera from an instance.
Definition at line 393 of file camera.cpp.
Instance* FIFE::Camera::getAttached | ( | ) | const [inline] |
Gets screen cell image dimensions for given layer.
Definition at line 169 of file camera.cpp.
Point FIFE::Camera::getCellImageDimensions | ( | ) |
Gets screen cell image dimensions.
Definition at line 165 of file camera.cpp.
const std::string& FIFE::Camera::getId | ( | ) | const [inline] |
Location FIFE::Camera::getLocation | ( | ) | const |
Gets the location camera is rendering
Definition at line 187 of file camera.cpp.
Location & FIFE::Camera::getLocationRef | ( | ) |
Gets a reference to the camera location
Definition at line 191 of file camera.cpp.
void FIFE::Camera::getMatchingInstances | ( | ScreenPoint | screen_coords, | |
Layer & | layer, | |||
std::list< Instance * > & | instances | |||
) |
Returns instances that match given screen coordinate
screen_coords | screen coordinates to be used for hit search | |
layer | layer to use for search | |
instances | list of instances that is filled based on hit test results |
Definition at line 291 of file camera.cpp.
void FIFE::Camera::getMatchingInstances | ( | Rect | screen_rect, | |
Layer & | layer, | |||
std::list< Instance * > & | instances | |||
) |
Returns instances that match given screen coordinate
screen_point1 | top left screen coordinates to be used for hit search | |
screen_point2 | right bottom screen coordinates to be used for hit search | |
layer | layer to use for search | |
instances | list of instances that is filled based on hit test results |
Definition at line 324 of file camera.cpp.
void FIFE::Camera::getMatchingInstances | ( | Location & | loc, | |
std::list< Instance * > & | instances, | |||
bool | use_exactcoordinates = false | |||
) |
Returns instances that match given location. Instances are sorted based on camera view, so that "topmost" instance is first in returned list
loc | location where to fetch instances from | |
instances | list of instances that is filled based on hit test results | |
use_exactcoordinates | if true, comparison is done using exact coordinates. if not, cell coordinates are used |
Definition at line 365 of file camera.cpp.
RendererBase * FIFE::Camera::getRenderer | ( | const std::string & | name | ) | [virtual] |
Gets renderer with given name
Implements FIFE::IRendererContainer.
Definition at line 445 of file camera.cpp.
double FIFE::Camera::getRotation | ( | ) | const |
double FIFE::Camera::getTilt | ( | ) | const |
const Rect & FIFE::Camera::getViewPort | ( | ) | const |
double FIFE::Camera::getZoom | ( | ) | const |
bool FIFE::Camera::isEnabled | ( | ) |
Gets if camera is enabled / disabled
Definition at line 207 of file camera.cpp.
void FIFE::Camera::onRendererEnabledChanged | ( | RendererBase * | renderer | ) | [virtual] |
Renderer is enabled / disabled
Implements FIFE::IRendererListener.
Definition at line 434 of file camera.cpp.
void FIFE::Camera::onRendererPipelinePositionChanged | ( | RendererBase * | renderer | ) | [virtual] |
Renderer's pipeline position has been changed
Implements FIFE::IRendererListener.
Definition at line 430 of file camera.cpp.
void FIFE::Camera::refresh | ( | ) |
Refreshes camera view in case e.g. location is updated directly (not via setLocation)
Definition at line 407 of file camera.cpp.
void FIFE::Camera::render | ( | ) |
Renders camera
Definition at line 472 of file camera.cpp.
void FIFE::Camera::resetRenderers | ( | ) |
resets active layer information on all renderers.
Definition at line 464 of file camera.cpp.
void FIFE::Camera::resetUpdates | ( | ) |
Resets temporary values from last update round, like warped flag
Definition at line 412 of file camera.cpp.
void FIFE::Camera::setCellImageDimensions | ( | unsigned int | width, | |
unsigned int | height | |||
) |
Sets screen cell image dimensions. Cell image dimension is basically width and height of a bitmap, that covers one cell in the layer where camera is bind
Definition at line 134 of file camera.cpp.
void FIFE::Camera::setEnabled | ( | bool | enabled | ) |
Sets camera enabled / disabled
Definition at line 203 of file camera.cpp.
void FIFE::Camera::setId | ( | const std::string & | id | ) | [inline] |
void FIFE::Camera::setLocation | ( | const Location & | location | ) |
Sets the location for camera
location | location (center point) to render |
Definition at line 142 of file camera.cpp.
void FIFE::Camera::setRotation | ( | double | rotation | ) |
Sets rotation for the camera. Rotation can be visualized by thinking camera that rotates around an object that it is rendering
rotation | rotation for the camera |
Definition at line 110 of file camera.cpp.
void FIFE::Camera::setTilt | ( | double | tilt | ) |
Sets tilt for the camera. e.g. overhead camera has tilt 0, while traditional isometric camera has tilt 45
tilt | tilt for the camera |
Definition at line 99 of file camera.cpp.
void FIFE::Camera::setViewPort | ( | const Rect & | viewport | ) |
Sets the viewport for camera viewport is rectangle inside the view where camera renders
viewport | area for camera render |
Definition at line 195 of file camera.cpp.
void FIFE::Camera::setZoom | ( | double | zoom | ) |
Sets zoom for the camera.
zoom | zoom for the camera |
Definition at line 121 of file camera.cpp.
ExactModelCoordinate FIFE::Camera::toMapCoordinates | ( | ScreenPoint | screen_coords, | |
bool | z_calculated = true | |||
) |
Transforms given point from screen coordinates to map coordinates
screen_coords | screen coordinates to transform | |
z_calculated | if true, z-value (depth cut point) is pre-calculated. If false, camera calculates it |
Definition at line 233 of file camera.cpp.
ScreenPoint FIFE::Camera::toScreenCoordinates | ( | ExactModelCoordinate | map_coords | ) |
Transforms given point from map coordinates to screen coordinates
Definition at line 243 of file camera.cpp.
void FIFE::Camera::update | ( | ) |
General update routine. In this function, the camera's position gets updated when its attached to another instance.
Definition at line 397 of file camera.cpp.