FIFE
2008.0
|
#include <camera.h>
Public Member Functions | |
Camera (const std::string &id, Layer *layer, const Rect &viewport, RenderBackend *renderbackend) | |
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 (uint32_t width, uint32_t height) |
Point | getCellImageDimensions () |
Point | getCellImageDimensions (Layer *layer) |
double | getReferenceScale () const |
Point3D | getZOffset (Layer *layer) |
void | setLocation (const Location &location) |
Location | getLocation () const |
Point3D | getOrigin () 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 (const ExactModelCoordinate &map_coords) |
DoublePoint3D | toVirtualScreenCoordinates (const ExactModelCoordinate &map_coords) |
void | setEnabled (bool enabled) |
bool | isEnabled () |
void | getMatchingInstances (ScreenPoint screen_coords, Layer &layer, std::list< Instance * > &instances, uint8_t alpha=0) |
void | getMatchingInstances (Rect screen_rect, Layer &layer, std::list< Instance * > &instances, uint8_t alpha=0) |
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 | setLightingColor (float red, float green, float blue) |
void | resetLightingColor () |
std::vector< float > | getLightingColor () |
void | setOverlayColor (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) |
std::vector< uint8_t > | getOverlayColor () |
void | resetOverlayColor () |
void | setOverlayImage (int32_t id, bool fill=false) |
int32_t | getOverlayImage () |
void | resetOverlayImage () |
void | setOverlayAnimation (AnimationPtr anim, bool fill=false) |
AnimationPtr | getOverlayAnimation () |
void | resetOverlayAnimation () |
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
FIFE::Camera::Camera | ( | const std::string & | id, |
Layer * | layer, | ||
const Rect & | viewport, | ||
RenderBackend * | renderbackend | ||
) |
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:
|
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 77 of file camera.cpp.
References setLocation().
|
virtual |
Destructor
Definition at line 115 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 613 of file camera.cpp.
References FIFE::RendererBase::getName(), FIFE::RendererBase::isEnabled(), and FIFE::RendererBase::setRendererListener().
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 576 of file camera.cpp.
References FIFE::Instance::getLocation().
void FIFE::Camera::calculateZValue | ( | ScreenPoint & | screen_coords | ) |
calculates z-value for given screenpoint
Definition at line 319 of file camera.cpp.
References toScreenCoordinates().
Referenced by toMapCoordinates().
void FIFE::Camera::detach | ( | ) |
Detaches the camera from an instance.
Definition at line 585 of file camera.cpp.
|
inline |
Point FIFE::Camera::getCellImageDimensions | ( | ) |
Gets screen cell image dimensions.
Definition at line 229 of file camera.cpp.
Gets screen cell image dimensions for given layer.
Definition at line 233 of file camera.cpp.
References FIFE::Layer::getCellGrid().
|
inline |
std::vector< float > FIFE::Camera::getLightingColor | ( | ) |
Returns a vector that contain the light color
Definition at line 668 of file camera.cpp.
Location FIFE::Camera::getLocation | ( | ) | const |
Gets the location camera is rendering
Definition at line 251 of file camera.cpp.
Location & FIFE::Camera::getLocationRef | ( | ) |
Gets a reference to the camera location
Definition at line 255 of file camera.cpp.
void FIFE::Camera::getMatchingInstances | ( | ScreenPoint | screen_coords, |
Layer & | layer, | ||
std::list< Instance * > & | instances, | ||
uint8_t | alpha = 0 |
||
) |
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 465 of file camera.cpp.
void FIFE::Camera::getMatchingInstances | ( | Rect | screen_rect, |
Layer & | layer, | ||
std::list< Instance * > & | instances, | ||
uint8_t | alpha = 0 |
||
) |
Returns instances that match given screen coordinate
screen_rect | rect that contains screen coordinates to be used for search |
layer | layer to use for search |
instances | list of instances that is filled based on hit test results |
accurate | should be true if the search should be exactly but its also much slower |
Definition at line 503 of file camera.cpp.
References FIFE::RectType< T >::h, FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
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 551 of file camera.cpp.
References FIFE::Instance::getLocationRef().
Point3D FIFE::Camera::getOrigin | ( | ) | const |
Gets screen point for the camera location
Definition at line 275 of file camera.cpp.
AnimationPtr FIFE::Camera::getOverlayAnimation | ( | ) |
Returns an AnimationPtr to the overlay animation
Definition at line 735 of file camera.cpp.
std::vector< uint8_t > FIFE::Camera::getOverlayColor | ( | ) |
Returns a vector that contain the overlay color
Definition at line 690 of file camera.cpp.
int32_t FIFE::Camera::getOverlayImage | ( | ) |
Returns the pool id of the overlay image
Definition at line 715 of file camera.cpp.
|
inline |
|
virtual |
Gets renderer with given name
Implements FIFE::IRendererContainer.
Definition at line 637 of file camera.cpp.
double FIFE::Camera::getRotation | ( | ) | const |
double FIFE::Camera::getTilt | ( | ) | const |
const Rect & FIFE::Camera::getViewPort | ( | ) | const |
Gets the viewport for camera
Definition at line 263 of file camera.cpp.
Referenced by render().
Gets a point that contain the visual z(z=1) difference, based on the given layer.
Definition at line 410 of file camera.cpp.
References FIFE::Layer::getCellGrid(), and toScreenCoordinates().
double FIFE::Camera::getZoom | ( | ) | const |
bool FIFE::Camera::isEnabled | ( | ) |
Gets if camera is enabled / disabled
Definition at line 271 of file camera.cpp.
|
virtual |
Renderer is enabled / disabled
Implements FIFE::IRendererListener.
Definition at line 626 of file camera.cpp.
References FIFE::RendererBase::getName(), and FIFE::RendererBase::isEnabled().
|
virtual |
Renderer's pipeline position has been changed
Implements FIFE::IRendererListener.
Definition at line 622 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 599 of file camera.cpp.
void FIFE::Camera::render | ( | ) |
Renders camera
Definition at line 827 of file camera.cpp.
References FIFE::Map::getLayers(), FIFE::RenderBackend::getLightingModel(), FIFE::RenderBackend::getName(), getViewPort(), FIFE::RenderBackend::popClipArea(), FIFE::RenderBackend::pushClipArea(), FIFE::RenderBackend::renderVertexArrays(), FIFE::RenderBackend::resetLighting(), FIFE::RenderBackend::resetStencilBuffer(), and FIFE::RenderBackend::setLighting().
void FIFE::Camera::resetLightingColor | ( | ) |
Resets lighting color
Definition at line 677 of file camera.cpp.
References FIFE::RenderBackend::resetLighting().
void FIFE::Camera::resetOverlayAnimation | ( | ) |
Resets the animation overlay
Definition at line 739 of file camera.cpp.
References FIFE::SharedPtr< T >::reset().
void FIFE::Camera::resetOverlayColor | ( | ) |
Resets the color overlay
Definition at line 705 of file camera.cpp.
void FIFE::Camera::resetOverlayImage | ( | ) |
Resets the image overlay
Definition at line 723 of file camera.cpp.
void FIFE::Camera::resetRenderers | ( | ) |
resets active layer information on all renderers.
Definition at line 641 of file camera.cpp.
void FIFE::Camera::resetUpdates | ( | ) |
Resets temporary values from last update round, like warped flag
Definition at line 604 of file camera.cpp.
void FIFE::Camera::setCellImageDimensions | ( | uint32_t | width, |
uint32_t | 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 169 of file camera.cpp.
void FIFE::Camera::setEnabled | ( | bool | enabled | ) |
Sets camera enabled / disabled
Definition at line 267 of file camera.cpp.
|
inline |
void FIFE::Camera::setLightingColor | ( | float | red, |
float | green, | ||
float | blue | ||
) |
Sets lighting color
Definition at line 660 of file camera.cpp.
void FIFE::Camera::setLocation | ( | const Location & | location | ) |
Sets the location for camera
location | location (center point) to render |
Definition at line 177 of file camera.cpp.
References toScreenCoordinates().
Referenced by Camera(), and update().
void FIFE::Camera::setOverlayAnimation | ( | AnimationPtr | anim, |
bool | fill = false |
||
) |
Sets a animation as overlay, if fill is true the animation gets the viewport size.
Definition at line 728 of file camera.cpp.
void FIFE::Camera::setOverlayColor | ( | uint8_t | red, |
uint8_t | green, | ||
uint8_t | blue, | ||
uint8_t | alpha | ||
) |
Sets a color as overlay
Definition at line 682 of file camera.cpp.
void FIFE::Camera::setOverlayImage | ( | int32_t | id, |
bool | fill = false |
||
) |
Sets a image as overlay, if fill is true the image gets the viewport size.
Definition at line 709 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 141 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 128 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 259 of file camera.cpp.
void FIFE::Camera::setZoom | ( | double | zoom | ) |
Sets zoom for the camera.
zoom | zoom for the camera |
Definition at line 154 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 324 of file camera.cpp.
References calculateZValue(), and FIFE::intPt2doublePt().
ScreenPoint FIFE::Camera::toScreenCoordinates | ( | const ExactModelCoordinate & | map_coords | ) |
Transforms given point from map coordinates to screen coordinates
Definition at line 331 of file camera.cpp.
References FIFE::doublePt2intPt().
Referenced by calculateZValue(), getZOffset(), FIFE::CellSelectionRenderer::render(), and setLocation().
DoublePoint3D FIFE::Camera::toVirtualScreenCoordinates | ( | const ExactModelCoordinate & | map_coords | ) |
Transforms given point from map coordinates to virtual screen coordinates
Definition at line 336 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 589 of file camera.cpp.
References FIFE::Instance::getLocationRef(), and setLocation().