FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::Camera Class Reference

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. More...

#include <camera.h>

+ Inheritance diagram for FIFE::Camera:
+ Collaboration diagram for FIFE::Camera:

Public Types

enum  TransformType {
  NoneTransform = 0x00, TiltTransform = 0x01, RotationTransform = 0x02, ZoomTransform = 0x04,
  PositionTransform = 0x08, ZTransform = 0x10
}
 
typedef uint32_t Transform
 

Public Member Functions

 Camera (const std::string &id, Map *map, const Rect &viewport, RenderBackend *renderbackend)
 Constructor Camera needs to be added to the view. More...
 
virtual ~Camera ()
 Destructor. More...
 
const std::string & getId () const
 Gets the identifier for this camera. More...
 
void setId (const std::string &id)
 Sets the identifier for this camera. More...
 
MapgetMap ()
 Gets the map where camera is bound. More...
 
void setTilt (double tilt)
 Sets tilt for the camera. More...
 
double getTilt () const
 Gets camera tilt. More...
 
void setRotation (double rotation)
 Sets rotation for the camera. More...
 
double getRotation () const
 Gets camera rotation. More...
 
void setZoom (double zoom)
 Sets zoom for the camera. More...
 
double getZoom () const
 Gets camera zoom. More...
 
double getOriginalZToY () const
 Gets original zToY transformation value. More...
 
void setZToY (double zToY)
 Sets zToY value for the camera and enables their use. More...
 
double getZToY () const
 Gets zToY value. More...
 
void setZToYEnabled (bool enabled)
 Sets z to y manipulation enabled / disabled. More...
 
bool isZToYEnabled () const
 Gets if z to y manipulation is enabled / disabled. More...
 
void setCellImageDimensions (uint32_t width, uint32_t height)
 Sets screen cell image dimensions. More...
 
Point getCellImageDimensions ()
 Gets screen cell image dimensions. More...
 
Point getCellImageDimensions (Layer *layer)
 Gets screen cell image dimensions for given layer. More...
 
double getReferenceScaleX () const
 Gets x reference scale for cell image dimensions. More...
 
double getReferenceScaleY () const
 Gets y reference scale for cell image dimensions. More...
 
void setLocation (const Location &location)
 Sets the location for camera. More...
 
Location getLocation ()
 Gets the location camera is rendering. More...
 
void setPosition (const ExactModelCoordinate &position)
 Sets map point for the camera. More...
 
ExactModelCoordinate getPosition () const
 Gets map point of the camera. More...
 
Point3D getOrigin () const
 Gets screen point of the camera. More...
 
void attach (Instance *instance)
 Attaches the camera to an instance. More...
 
void detach ()
 Detaches the camera from an instance. More...
 
InstancegetAttached () const
 Returns instance where camera is attached. More...
 
void setViewPort (const Rect &viewport)
 Sets the viewport for camera viewport is rectangle inside the view where camera renders. More...
 
const RectgetViewPort () const
 Gets the viewport for camera in pixel coordinates. More...
 
const RectgetMapViewPort ()
 Gets the viewport for camera in map coordinates. More...
 
Rect getLayerViewPort (Layer *layer)
 Gets the viewport for camera in layer coordinates. More...
 
ExactModelCoordinate toMapCoordinates (ScreenPoint screen_coords, bool z_calculated=true)
 Transforms given point from screen coordinates to map coordinates. More...
 
ScreenPoint toScreenCoordinates (const ExactModelCoordinate &map_coords)
 Transforms given point from map coordinates to screen coordinates. More...
 
DoublePoint3D toVirtualScreenCoordinates (const ExactModelCoordinate &map_coords)
 Transforms given point from map coordinates to virtual screen coordinates. More...
 
ScreenPoint virtualScreenToScreen (const DoublePoint3D &p)
 Transforms given point from virtual screen coordinates to screen coordinates. More...
 
DoublePoint3D screenToVirtualScreen (const ScreenPoint &p)
 Transforms given point from screen coordinates to virtual screen coordinates. More...
 
void setEnabled (bool enabled)
 Sets camera enabled / disabled. More...
 
bool isEnabled ()
 Gets if camera is enabled / disabled. More...
 
RenderListgetRenderListRef (Layer *layer)
 Returns reference to RenderList. More...
 
void getMatchingInstances (ScreenPoint screen_coords, Layer &layer, std::list< Instance *> &instances, uint8_t alpha=0)
 Returns instances that match given screen coordinate. More...
 
void getMatchingInstances (Rect screen_rect, Layer &layer, std::list< Instance *> &instances, uint8_t alpha=0)
 Returns instances that match given screen coordinate. More...
 
void getMatchingInstances (Location &loc, std::list< Instance *> &instances, bool use_exactcoordinates=false)
 Returns instances that match given location. More...
 
void update ()
 General update routine. More...
 
void refresh ()
 Refreshes camera view in case e.g. More...
 
void resetUpdates ()
 Resets temporary values from last update round, like warped flag. More...
 
bool isUpdated ()
 Returns true if camera view has been updated, otherwise false. More...
 
void addRenderer (RendererBase *renderer)
 Adds new renderer on the view. More...
 
RendererBasegetRenderer (const std::string &name)
 Gets renderer with given name. More...
 
void resetRenderers ()
 resets active layer information on all renderers. More...
 
void calculateZValue (DoublePoint3D &screen_coords)
 calculates z-value for given screenpoint More...
 
void onRendererPipelinePositionChanged (RendererBase *renderer)
 Renderer's pipeline position has been changed. More...
 
void onRendererEnabledChanged (RendererBase *renderer)
 Renderer is enabled / disabled. More...
 
void setLightingColor (float red, float green, float blue)
 Sets lighting color. More...
 
void resetLightingColor ()
 Resets lighting color. More...
 
std::vector< float > getLightingColor ()
 Returns a vector that contain the light color. More...
 
void setOverlayColor (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
 Sets a color as overlay. More...
 
std::vector< uint8_t > getOverlayColor ()
 Returns a vector that contain the overlay color. More...
 
void resetOverlayColor ()
 Resets the color overlay. More...
 
void setOverlayImage (int32_t id, bool fill=false)
 Sets a image as overlay, if fill is true the image gets the viewport size. More...
 
int32_t getOverlayImage ()
 Returns the pool id of the overlay image. More...
 
void resetOverlayImage ()
 Resets the image overlay. More...
 
void setOverlayAnimation (AnimationPtr anim, bool fill=false)
 Sets a animation as overlay, if fill is true the animation gets the viewport size. More...
 
AnimationPtr getOverlayAnimation ()
 Returns an AnimationPtr to the overlay animation. More...
 
void resetOverlayAnimation ()
 Resets the animation overlay. More...
 
void render ()
 Renders camera. More...
 
- Public Member Functions inherited from FIFE::IRendererListener
virtual ~IRendererListener ()
 
- Public Member Functions inherited from FIFE::IRendererContainer
virtual ~IRendererContainer ()
 

Private Member Functions

void addLayer (Layer *layer)
 
void removeLayer (Layer *layer)
 
void init ()
 
void updateMatrices ()
 Updates the camera transformation matrix T with requested values. More...
 
void updateReferenceScale ()
 Updates camera reference scale Reference scale is in a sense an internal zooming factor, which adjusts cell dimensions in logical space to ones shown on screen. More...
 
void updateRenderLists ()
 Updates camera RenderLists. More...
 
DoublePoint getLogicalCellDimensions (Layer *layer)
 Gets logical cell image dimensions for given layer. More...
 
DoublePoint getLogicalCellDimensions ()
 Gets logical cell image dimensions and ignores the layer and cellgrid. More...
 
void renderOverlay ()
 Renders the overlay(color, image, animation) for the camera. More...
 
void renderStaticLayer (Layer *layer, bool update)
 Renders the layer part that is on screen as one image. More...
 

Private Attributes

std::string m_id
 
Mapm_map
 
Rect m_viewport
 
RenderBackendm_renderbackend
 
ExactModelCoordinate m_position
 
DoubleMatrix m_matrix
 
DoubleMatrix m_inverse_matrix
 
DoubleMatrix m_vs_matrix
 
DoubleMatrix m_vs_inverse_matrix
 
DoubleMatrix m_vscreen_2_screen
 
DoubleMatrix m_screen_2_vscreen
 
double m_tilt
 
double m_rotation
 
double m_zoom
 
double m_zToY
 
bool m_enabledZToY
 
Location m_location
 
ScreenPoint m_curOrigin
 
Rect m_mapViewPort
 
bool m_mapViewPortUpdated
 
uint32_t m_screenCellWidth
 
uint32_t m_screenCellHeight
 
double m_referenceScaleX
 
double m_referenceScaleY
 
bool m_enabled
 
Instancem_attachedTo
 
Transform m_transform
 
std::map< std::string, RendererBase * > m_renderers
 
std::list< RendererBase * > m_pipeline
 
bool m_updated
 
t_layer_to_instances m_layerToInstances
 
std::map< Layer *, LayerCache * > m_cache
 
MapObserverm_map_observer
 
bool m_lighting
 
std::vector< float > m_light_colors
 
bool m_col_overlay
 
bool m_img_overlay
 
bool m_ani_overlay
 
SDL_Color m_overlay_color
 
int32_t m_img_id
 
AnimationPtr m_ani_ptr
 
bool m_img_fill
 
bool m_ani_fill
 
uint32_t m_start_time
 

Friends

class MapObserver
 

Detailed Description

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 59 of file camera.h.

Member Typedef Documentation

◆ Transform

typedef uint32_t FIFE::Camera::Transform

Definition at line 69 of file camera.h.

Member Enumeration Documentation

◆ TransformType

Enumerator
NoneTransform 
TiltTransform 
RotationTransform 
ZoomTransform 
PositionTransform 
ZTransform 

Definition at line 61 of file camera.h.

Constructor & Destructor Documentation

◆ Camera()

FIFE::Camera::Camera ( const std::string &  id,
Map map,
const Rect viewport,
RenderBackend renderbackend 
)

Constructor Camera needs to be added to the view.

If not done so, it is not rendered.

Parameters
ididentifier for the camera
mapmap where camera is bound
viewportused viewport for the camera. Viewport is measured in pixels in relation to game main screen
renderbackendto use with rendering

Definition at line 80 of file camera.cpp.

References init(), m_map_observer, and MapObserver.

◆ ~Camera()

FIFE::Camera::~Camera ( )
virtual

Member Function Documentation

◆ addLayer()

void FIFE::Camera::addLayer ( Layer layer)
private

Definition at line 747 of file camera.cpp.

References m_cache, m_layerToInstances, and refresh().

Referenced by init(), FIFE::MapObserver::onLayerCreate(), and updateRenderLists().

+ Here is the caller graph for this function:

◆ addRenderer()

void FIFE::Camera::addRenderer ( RendererBase renderer)

Adds new renderer on the view.

Ownership is transferred to the camera.

Definition at line 712 of file camera.cpp.

References FIFE::RendererBase::getName(), FIFE::RendererBase::isEnabled(), m_pipeline, m_renderers, FIFE::pipelineSort(), and FIFE::RendererBase::setRendererListener().

Referenced by FIFE::Map::addCamera(), and isUpdated().

+ Here is the caller graph for this function:

◆ attach()

void FIFE::Camera::attach ( Instance instance)

Attaches the camera to an instance.

Parameters
instanceInstance to which the camera shall be attached
Note
The camera can only be attached to an instance at the same layer!

Definition at line 669 of file camera.cpp.

References m_attachedTo.

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ calculateZValue()

void FIFE::Camera::calculateZValue ( DoublePoint3D screen_coords)

calculates z-value for given screenpoint

Definition at line 410 of file camera.cpp.

References m_position, m_tilt, FIFE::Math< T >::pi(), FIFE::Math< T >::Tan(), toScreenCoordinates(), FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.

Referenced by isUpdated(), and toMapCoordinates().

+ Here is the caller graph for this function:

◆ detach()

void FIFE::Camera::detach ( )

Detaches the camera from an instance.

Definition at line 675 of file camera.cpp.

References m_attachedTo.

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ getAttached()

◆ getCellImageDimensions() [1/2]

Point FIFE::Camera::getCellImageDimensions ( )

Gets screen cell image dimensions.

See also
setCellImageDimensions
Returns
Point containing x=width and y=height

Definition at line 259 of file camera.cpp.

References m_screenCellHeight, and m_screenCellWidth.

Referenced by getMap().

+ Here is the caller graph for this function:

◆ getCellImageDimensions() [2/2]

Point FIFE::Camera::getCellImageDimensions ( Layer layer)

Gets screen cell image dimensions for given layer.

Returns
Point containing x=width and y=height

Definition at line 263 of file camera.cpp.

References getLogicalCellDimensions(), m_referenceScaleX, m_referenceScaleY, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.

◆ getId()

const std::string& FIFE::Camera::getId ( ) const
inline

Gets the identifier for this camera.

Definition at line 86 of file camera.h.

References m_id.

◆ getLayerViewPort()

Rect FIFE::Camera::getLayerViewPort ( Layer layer)

Gets the viewport for camera in layer coordinates.

Parameters
layerA pointer to the layer whose geometry is used for the conversion
Returns
camera viewport

Definition at line 326 of file camera.cpp.

References ABS, FIFE::Location::getLayerCoordinates(), getMapViewPort(), FIFE::RectType< T >::h, FIFE::Location::setMapCoordinates(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, FIFE::PointType3D< T >::x, FIFE::RectType< T >::y, and FIFE::PointType3D< T >::y.

Referenced by getAttached(), and FIFE::CellRenderer::render().

+ Here is the caller graph for this function:

◆ getLightingColor()

std::vector< float > FIFE::Camera::getLightingColor ( )

Returns a vector that contain the light color.

Definition at line 772 of file camera.cpp.

References m_light_colors.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ getLocation()

Location FIFE::Camera::getLocation ( )

Gets the location camera is rendering.

If no location was set, the camera creates a location. The top layer of the map together with current camera position are used for that.

Returns
camera location

Definition at line 271 of file camera.cpp.

References FIFE::Location::getLayer(), FIFE::Map::getLayerCount(), FIFE::Map::getLayers(), m_location, m_map, m_position, FIFE::Location::setLayer(), and FIFE::Location::setMapCoordinates().

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ getLogicalCellDimensions() [1/2]

DoublePoint FIFE::Camera::getLogicalCellDimensions ( Layer layer)
private

◆ getLogicalCellDimensions() [2/2]

DoublePoint FIFE::Camera::getLogicalCellDimensions ( )
private

Gets logical cell image dimensions and ignores the layer and cellgrid.

Definition at line 475 of file camera.cpp.

References FIFE::Matrix< T >::applyRotate(), FIFE::Matrix< T >::loadRotate(), m_rotation, and m_tilt.

Referenced by getCellImageDimensions(), and updateReferenceScale().

+ Here is the caller graph for this function:

◆ getMap()

Map* FIFE::Camera::getMap ( )
inline

Gets the map where camera is bound.

Returns
The associated map for this camera.

Definition at line 95 of file camera.h.

References getCellImageDimensions(), getOriginalZToY(), getRotation(), getTilt(), getZoom(), getZToY(), isZToYEnabled(), m_map, setCellImageDimensions(), setRotation(), setTilt(), setZoom(), setZToY(), and setZToYEnabled().

◆ getMapViewPort()

const Rect & FIFE::Camera::getMapViewPort ( )

Gets the viewport for camera in map coordinates.

Returns
camera viewport

Definition at line 293 of file camera.cpp.

References ABS, FIFE::RectType< T >::h, m_mapViewPort, m_mapViewPortUpdated, m_viewport, toMapCoordinates(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, FIFE::PointType3D< T >::x, FIFE::RectType< T >::y, and FIFE::PointType3D< T >::y.

Referenced by getAttached(), and getLayerViewPort().

+ Here is the caller graph for this function:

◆ getMatchingInstances() [1/3]

void FIFE::Camera::getMatchingInstances ( ScreenPoint  screen_coords,
Layer layer,
std::list< Instance *> &  instances,
uint8_t  alpha = 0 
)

Returns instances that match given screen coordinate.

Parameters
screen_coordsscreen coordinates to be used for hit search
layerlayer to use for search
instanceslist of instances that is filled based on hit test results
alphathe alpha to use to filter the matching instances. Pixels that have an alpha value higher than what is specified here are considered a hit.

Definition at line 524 of file camera.cpp.

References FIFE::RectType< T >::contains(), FIFE::RenderItem::dimensions, FIFE::Math< T >::Equal(), FIFE::Image::forceLoadInternal(), FIFE::RenderItem::getAnimationOverlay(), FIFE::Image::getHeight(), FIFE::Image::getPixelRGBA(), FIFE::Image::getWidth(), FIFE::RectType< T >::h, FIFE::RenderItem::image, FIFE::Image::isSharedImage(), m_layerToInstances, m_zoom, FIFE::RectType< T >::w, FIFE::RectType< T >::x, FIFE::PointType3D< T >::x, FIFE::RectType< T >::y, and FIFE::PointType3D< T >::y.

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ getMatchingInstances() [2/3]

void FIFE::Camera::getMatchingInstances ( Rect  screen_rect,
Layer layer,
std::list< Instance *> &  instances,
uint8_t  alpha = 0 
)

Returns instances that match given screen coordinate.

Parameters
screen_rectrect that contains screen coordinates to be used for search
layerlayer to use for search
instanceslist of instances that is filled based on hit test results
alphathe alpha to use to filter the matching instances. Pixels that have an alpha value higher than what is specified here are considered a hit.

Definition at line 579 of file camera.cpp.

References FIFE::RectType< T >::bottom(), FIFE::RenderItem::dimensions, FIFE::Math< T >::Equal(), FIFE::Image::forceLoadInternal(), FIFE::RenderItem::getAnimationOverlay(), FIFE::Image::getHeight(), FIFE::Image::getPixelRGBA(), FIFE::Image::getWidth(), FIFE::RectType< T >::h, FIFE::RenderItem::image, FIFE::RectType< T >::intersects(), FIFE::Image::isSharedImage(), m_layerToInstances, m_zoom, FIFE::RectType< T >::right(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.

◆ getMatchingInstances() [3/3]

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

Parameters
loclocation where to fetch instances from
instanceslist of instances that is filled based on hit test results
use_exactcoordinatesif true, comparison is done using exact coordinates. if not, cell coordinates are used

Definition at line 645 of file camera.cpp.

References FIFE::Location::getExactLayerCoordinatesRef(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::Instance::getLocationRef(), and m_layerToInstances.

◆ getOrigin()

Point3D FIFE::Camera::getOrigin ( ) const

Gets screen point of the camera.

Returns
camera screen point

Definition at line 364 of file camera.cpp.

References m_curOrigin.

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ getOriginalZToY()

double FIFE::Camera::getOriginalZToY ( ) const

◆ getOverlayAnimation()

AnimationPtr FIFE::Camera::getOverlayAnimation ( )

Returns an AnimationPtr to the overlay animation.

Definition at line 839 of file camera.cpp.

References m_ani_ptr.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ getOverlayColor()

std::vector< uint8_t > FIFE::Camera::getOverlayColor ( )

Returns a vector that contain the overlay color.

Definition at line 794 of file camera.cpp.

References m_col_overlay, and m_overlay_color.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ getOverlayImage()

int32_t FIFE::Camera::getOverlayImage ( )

Returns the pool id of the overlay image.

Definition at line 819 of file camera.cpp.

References m_img_id, and m_img_overlay.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ getPosition()

ExactModelCoordinate FIFE::Camera::getPosition ( ) const

Gets map point of the camera.

Returns
The camera position on the map

Definition at line 360 of file camera.cpp.

References m_position.

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ getReferenceScaleX()

double FIFE::Camera::getReferenceScaleX ( ) const
inline

Gets x reference scale for cell image dimensions.

Definition at line 177 of file camera.h.

References m_referenceScaleX.

◆ getReferenceScaleY()

double FIFE::Camera::getReferenceScaleY ( ) const
inline

Gets y reference scale for cell image dimensions.

Definition at line 181 of file camera.h.

References attach(), detach(), getLocation(), getOrigin(), getPosition(), m_referenceScaleY, setLocation(), and setPosition().

◆ getRenderer()

RendererBase * FIFE::Camera::getRenderer ( const std::string &  name)
virtual

Gets renderer with given name.

Implements FIFE::IRendererContainer.

Definition at line 736 of file camera.cpp.

References m_renderers.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ getRenderListRef()

RenderList & FIFE::Camera::getRenderListRef ( Layer layer)

Returns reference to RenderList.

Definition at line 520 of file camera.cpp.

References m_layerToInstances.

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ getRotation()

double FIFE::Camera::getRotation ( ) const

Gets camera rotation.

Returns
rotation of the camera

Definition at line 173 of file camera.cpp.

References m_rotation.

Referenced by getMap().

+ Here is the caller graph for this function:

◆ getTilt()

double FIFE::Camera::getTilt ( ) const

Gets camera tilt.

Returns
tilt of camera

Definition at line 160 of file camera.cpp.

References m_tilt.

Referenced by getMap().

+ Here is the caller graph for this function:

◆ getViewPort()

◆ getZoom()

◆ getZToY()

double FIFE::Camera::getZToY ( ) const

Gets zToY value.

Returns
zToY value of the camera.

Definition at line 216 of file camera.cpp.

References m_zToY.

Referenced by getMap().

+ Here is the caller graph for this function:

◆ init()

void FIFE::Camera::init ( )
private

Definition at line 137 of file camera.cpp.

References FIFE::Map::addChangeListener(), addLayer(), FIFE::Map::getLayers(), m_curOrigin, m_map, m_map_observer, m_position, m_transform, PositionTransform, toScreenCoordinates(), and updateMatrices().

Referenced by Camera().

+ Here is the caller graph for this function:

◆ isEnabled()

bool FIFE::Camera::isEnabled ( )

Gets if camera is enabled / disabled.

Definition at line 346 of file camera.cpp.

References m_enabled.

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ isUpdated()

◆ isZToYEnabled()

bool FIFE::Camera::isZToYEnabled ( ) const

Gets if z to y manipulation is enabled / disabled.

Returns
true if z to y manipulation is enabled, otherwise false.

Definition at line 224 of file camera.cpp.

References m_enabledZToY.

Referenced by getMap().

+ Here is the caller graph for this function:

◆ onRendererEnabledChanged()

void FIFE::Camera::onRendererEnabledChanged ( RendererBase renderer)
virtual

Renderer is enabled / disabled.

Implements FIFE::IRendererListener.

Definition at line 725 of file camera.cpp.

References FIFE::_log, FL_LOG, FIFE::RendererBase::getName(), FIFE::RendererBase::isEnabled(), m_pipeline, m_renderers, and FIFE::pipelineSort().

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ onRendererPipelinePositionChanged()

void FIFE::Camera::onRendererPipelinePositionChanged ( RendererBase renderer)
virtual

Renderer's pipeline position has been changed.

Implements FIFE::IRendererListener.

Definition at line 721 of file camera.cpp.

References m_pipeline, and FIFE::pipelineSort().

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ refresh()

void FIFE::Camera::refresh ( )

Refreshes camera view in case e.g.

location is updated directly (not via setLocation)

Note
calling this function marks camera as "warped", therefore it causes all instance positions to be recalculated. If you constantly call this, you end up with pixel wobbling effect when camera is moved.

Definition at line 693 of file camera.cpp.

References m_curOrigin, m_position, m_transform, RotationTransform, toScreenCoordinates(), and updateMatrices().

Referenced by addLayer(), getAttached(), removeLayer(), and setViewPort().

+ Here is the caller graph for this function:

◆ removeLayer()

void FIFE::Camera::removeLayer ( Layer layer)
private

Definition at line 754 of file camera.cpp.

References FIFE::Location::getLayer(), m_cache, m_layerToInstances, m_location, refresh(), and FIFE::Location::reset().

Referenced by FIFE::MapObserver::onLayerDelete(), and ~Camera().

+ Here is the caller graph for this function:

◆ render()

◆ renderOverlay()

◆ renderStaticLayer()

◆ resetLightingColor()

void FIFE::Camera::resetLightingColor ( )

Resets lighting color.

Definition at line 781 of file camera.cpp.

References m_lighting, m_renderbackend, and FIFE::RenderBackend::resetLighting().

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ resetOverlayAnimation()

void FIFE::Camera::resetOverlayAnimation ( )

Resets the animation overlay.

Definition at line 843 of file camera.cpp.

References m_ani_overlay, m_ani_ptr, and FIFE::SharedPtr< T >::reset().

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ resetOverlayColor()

void FIFE::Camera::resetOverlayColor ( )

Resets the color overlay.

Definition at line 809 of file camera.cpp.

References m_col_overlay.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ resetOverlayImage()

void FIFE::Camera::resetOverlayImage ( )

Resets the image overlay.

Definition at line 827 of file camera.cpp.

References m_img_id, and m_img_overlay.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ resetRenderers()

void FIFE::Camera::resetRenderers ( )

resets active layer information on all renderers.

Definition at line 740 of file camera.cpp.

References m_renderers.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ resetUpdates()

void FIFE::Camera::resetUpdates ( )

Resets temporary values from last update round, like warped flag.

Definition at line 699 of file camera.cpp.

References m_transform, m_updated, and NoneTransform.

Referenced by getAttached(), and updateRenderLists().

+ Here is the caller graph for this function:

◆ screenToVirtualScreen()

DoublePoint3D FIFE::Camera::screenToVirtualScreen ( const ScreenPoint p)

Transforms given point from screen coordinates to virtual screen coordinates.

Returns
point in virtual screen coordinates

Definition at line 437 of file camera.cpp.

References FIFE::intPt2doublePt(), and m_screen_2_vscreen.

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ setCellImageDimensions()

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

Returns
Point Point containing x=width and y=height

Definition at line 228 of file camera.cpp.

References m_screenCellHeight, m_screenCellWidth, m_transform, PositionTransform, updateMatrices(), and updateReferenceScale().

Referenced by getMap(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ setEnabled()

void FIFE::Camera::setEnabled ( bool  enabled)

Sets camera enabled / disabled.

Definition at line 342 of file camera.cpp.

References m_enabled.

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ setId()

void FIFE::Camera::setId ( const std::string &  id)
inline

Sets the identifier for this camera.

Definition at line 90 of file camera.h.

References m_id.

◆ setLightingColor()

void FIFE::Camera::setLightingColor ( float  red,
float  green,
float  blue 
)

Sets lighting color.

Definition at line 764 of file camera.cpp.

References m_light_colors, and m_lighting.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ setLocation()

void FIFE::Camera::setLocation ( const Location location)

Sets the location for camera.

Parameters
locationlocation (center point) to render

Definition at line 236 of file camera.cpp.

References FIFE::Layer::getCellGrid(), FIFE::Location::getLayer(), FIFE::Location::getMapCoordinates(), m_curOrigin, m_location, m_position, m_transform, PositionTransform, toScreenCoordinates(), and updateMatrices().

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ setOverlayAnimation()

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 832 of file camera.cpp.

References m_ani_fill, m_ani_overlay, m_ani_ptr, and m_start_time.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ setOverlayColor()

void FIFE::Camera::setOverlayColor ( uint8_t  red,
uint8_t  green,
uint8_t  blue,
uint8_t  alpha 
)

Sets a color as overlay.

Definition at line 786 of file camera.cpp.

References m_col_overlay, and m_overlay_color.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ setOverlayImage()

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 813 of file camera.cpp.

References m_img_fill, m_img_id, and m_img_overlay.

Referenced by isUpdated().

+ Here is the caller graph for this function:

◆ setPosition()

void FIFE::Camera::setPosition ( const ExactModelCoordinate position)

Sets map point for the camera.

Parameters
positionThe camera position on the map

Definition at line 350 of file camera.cpp.

References FIFE::Math< T >::Equal(), m_curOrigin, m_position, m_transform, PositionTransform, toScreenCoordinates(), updateMatrices(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

Referenced by getReferenceScaleY().

+ Here is the caller graph for this function:

◆ setRotation()

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

Parameters
rotationrotation for the camera

Definition at line 164 of file camera.cpp.

References FIFE::Math< T >::Equal(), m_rotation, m_transform, RotationTransform, updateMatrices(), and updateReferenceScale().

Referenced by getMap(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ setTilt()

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

Parameters
tilttilt for the camera

Definition at line 151 of file camera.cpp.

References FIFE::Math< T >::Equal(), m_tilt, m_transform, TiltTransform, updateMatrices(), and updateReferenceScale().

Referenced by getMap(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ setViewPort()

void FIFE::Camera::setViewPort ( const Rect viewport)

Sets the viewport for camera viewport is rectangle inside the view where camera renders.

Parameters
viewportarea for camera render

Definition at line 284 of file camera.cpp.

References m_viewport, and refresh().

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ setZoom()

void FIFE::Camera::setZoom ( double  zoom)

Sets zoom for the camera.

Parameters
zoomzoom for the camera

Definition at line 177 of file camera.cpp.

References FIFE::Math< T >::Equal(), m_transform, m_zoom, updateMatrices(), and ZoomTransform.

Referenced by getMap(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ setZToY()

void FIFE::Camera::setZToY ( double  zToY)

Sets zToY value for the camera and enables their use.

This means the factor which influenced the z to y transformation, so if you set zToY=32 then 1z corresponds to 32 pixels in y direction.

Parameters
zToYinfluenced the z to y transformation of the camera.

Definition at line 207 of file camera.cpp.

References FIFE::Math< T >::Equal(), m_enabledZToY, m_transform, m_zToY, updateMatrices(), and ZTransform.

Referenced by getMap(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ setZToYEnabled()

void FIFE::Camera::setZToYEnabled ( bool  enabled)

Sets z to y manipulation enabled / disabled.

Parameters
enabledIf true then the zToY value is used instead of the original matrix value.

Definition at line 220 of file camera.cpp.

References m_enabledZToY.

Referenced by getMap().

+ Here is the caller graph for this function:

◆ toMapCoordinates()

ExactModelCoordinate FIFE::Camera::toMapCoordinates ( ScreenPoint  screen_coords,
bool  z_calculated = true 
)

Transforms given point from screen coordinates to map coordinates.

Parameters
screen_coordsscreen coordinates to transform
z_calculatedif true, z-value (depth cut point) is pre-calculated. If false, camera calculates it
Returns
point in map coordinates

Definition at line 415 of file camera.cpp.

References calculateZValue(), FIFE::intPt2doublePt(), and m_inverse_matrix.

Referenced by getAttached(), getMapViewPort(), and FIFE::CoordinateRenderer::render().

+ Here is the caller graph for this function:

◆ toScreenCoordinates()

ScreenPoint FIFE::Camera::toScreenCoordinates ( const ExactModelCoordinate map_coords)

◆ toVirtualScreenCoordinates()

DoublePoint3D FIFE::Camera::toVirtualScreenCoordinates ( const ExactModelCoordinate map_coords)

Transforms given point from map coordinates to virtual screen coordinates.

Returns
point in virtual screen coordinates

Definition at line 428 of file camera.cpp.

References m_vs_matrix.

Referenced by getAttached(), FIFE::InstanceRenderer::renderAlreadySorted(), and FIFE::InstanceRenderer::renderUnsorted().

+ Here is the caller graph for this function:

◆ update()

void FIFE::Camera::update ( )

General update routine.

In this function, the camera's position gets updated when its attached to another instance.

Note
call this only once in engine update cycle, so that tracking between current position and previous position keeps in sync. This information is used e.g. by view to fix the pixel wobbling problem

Definition at line 679 of file camera.cpp.

References FIFE::Math< T >::Equal(), FIFE::Instance::getLocationRef(), FIFE::Location::getMapCoordinates(), m_attachedTo, m_curOrigin, m_position, m_transform, PositionTransform, toScreenCoordinates(), updateMatrices(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

Referenced by getAttached().

+ Here is the caller graph for this function:

◆ updateMatrices()

◆ updateReferenceScale()

void FIFE::Camera::updateReferenceScale ( )
private

Updates camera reference scale Reference scale is in a sense an internal zooming factor, which adjusts cell dimensions in logical space to ones shown on screen.

Calculation is based on current camera properties (e.g. rotation)

Definition at line 507 of file camera.cpp.

References FIFE::_log, FL_DBG, getLogicalCellDimensions(), m_referenceScaleX, m_referenceScaleY, m_rotation, m_screenCellHeight, m_screenCellWidth, m_tilt, FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.

Referenced by setCellImageDimensions(), setRotation(), and setTilt().

+ Here is the caller graph for this function:

◆ updateRenderLists()

void FIFE::Camera::updateRenderLists ( )
private

Updates camera RenderLists.

Definition at line 957 of file camera.cpp.

References FIFE::_log, addLayer(), FL_ERR, FIFE::Map::getLayers(), m_cache, m_layerToInstances, m_map, m_transform, NoneTransform, resetUpdates(), and FIFE::LayerCache::update().

Referenced by render().

+ Here is the caller graph for this function:

◆ virtualScreenToScreen()

ScreenPoint FIFE::Camera::virtualScreenToScreen ( const DoublePoint3D p)

Transforms given point from virtual screen coordinates to screen coordinates.

Returns
point in screen coordinates

Definition at line 433 of file camera.cpp.

References FIFE::doublePt2intPt(), and m_vscreen_2_screen.

Referenced by getAttached().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ MapObserver

friend class MapObserver
friend

Definition at line 411 of file camera.h.

Referenced by Camera().

Member Data Documentation

◆ m_ani_fill

bool FIFE::Camera::m_ani_fill
private

Definition at line 511 of file camera.h.

Referenced by renderOverlay(), and setOverlayAnimation().

◆ m_ani_overlay

bool FIFE::Camera::m_ani_overlay
private

Definition at line 506 of file camera.h.

Referenced by renderOverlay(), resetOverlayAnimation(), and setOverlayAnimation().

◆ m_ani_ptr

AnimationPtr FIFE::Camera::m_ani_ptr
private

◆ m_attachedTo

Instance* FIFE::Camera::m_attachedTo
private

Definition at line 481 of file camera.h.

Referenced by attach(), detach(), getAttached(), and update().

◆ m_cache

std::map<Layer*,LayerCache*> FIFE::Camera::m_cache
private

Definition at line 495 of file camera.h.

Referenced by addLayer(), removeLayer(), render(), renderStaticLayer(), and updateRenderLists().

◆ m_col_overlay

bool FIFE::Camera::m_col_overlay
private

Definition at line 504 of file camera.h.

Referenced by getOverlayColor(), renderOverlay(), resetOverlayColor(), and setOverlayColor().

◆ m_curOrigin

ScreenPoint FIFE::Camera::m_curOrigin
private

Definition at line 472 of file camera.h.

Referenced by getOrigin(), init(), refresh(), setLocation(), setPosition(), and update().

◆ m_enabled

bool FIFE::Camera::m_enabled
private

Definition at line 480 of file camera.h.

Referenced by isEnabled(), and setEnabled().

◆ m_enabledZToY

bool FIFE::Camera::m_enabledZToY
private

Definition at line 470 of file camera.h.

Referenced by isZToYEnabled(), setZToY(), setZToYEnabled(), and updateMatrices().

◆ m_id

std::string FIFE::Camera::m_id
private

Definition at line 416 of file camera.h.

Referenced by getId(), renderStaticLayer(), and setId().

◆ m_img_fill

bool FIFE::Camera::m_img_fill
private

Definition at line 510 of file camera.h.

Referenced by renderOverlay(), and setOverlayImage().

◆ m_img_id

int32_t FIFE::Camera::m_img_id
private

Definition at line 508 of file camera.h.

Referenced by getOverlayImage(), renderOverlay(), resetOverlayImage(), and setOverlayImage().

◆ m_img_overlay

bool FIFE::Camera::m_img_overlay
private

Definition at line 505 of file camera.h.

Referenced by getOverlayImage(), renderOverlay(), resetOverlayImage(), and setOverlayImage().

◆ m_inverse_matrix

DoubleMatrix FIFE::Camera::m_inverse_matrix
private

Definition at line 459 of file camera.h.

Referenced by toMapCoordinates(), and updateMatrices().

◆ m_layerToInstances

t_layer_to_instances FIFE::Camera::m_layerToInstances
private

◆ m_light_colors

std::vector<float> FIFE::Camera::m_light_colors
private

Definition at line 501 of file camera.h.

Referenced by getLightingColor(), render(), and setLightingColor().

◆ m_lighting

bool FIFE::Camera::m_lighting
private

Definition at line 499 of file camera.h.

Referenced by render(), resetLightingColor(), and setLightingColor().

◆ m_location

Location FIFE::Camera::m_location
private

Definition at line 471 of file camera.h.

Referenced by getLocation(), getOriginalZToY(), removeLayer(), and setLocation().

◆ m_map

Map* FIFE::Camera::m_map
private

Definition at line 417 of file camera.h.

Referenced by getLocation(), getMap(), init(), render(), updateRenderLists(), and ~Camera().

◆ m_map_observer

MapObserver* FIFE::Camera::m_map_observer
private

Definition at line 496 of file camera.h.

Referenced by Camera(), init(), and ~Camera().

◆ m_mapViewPort

Rect FIFE::Camera::m_mapViewPort
private

Definition at line 474 of file camera.h.

Referenced by getMapViewPort().

◆ m_mapViewPortUpdated

bool FIFE::Camera::m_mapViewPortUpdated
private

Definition at line 475 of file camera.h.

Referenced by getMapViewPort(), and updateMatrices().

◆ m_matrix

DoubleMatrix FIFE::Camera::m_matrix
private

Definition at line 458 of file camera.h.

Referenced by toScreenCoordinates(), and updateMatrices().

◆ m_overlay_color

SDL_Color FIFE::Camera::m_overlay_color
private

Definition at line 507 of file camera.h.

Referenced by getOverlayColor(), renderOverlay(), and setOverlayColor().

◆ m_pipeline

std::list<RendererBase*> FIFE::Camera::m_pipeline
private

◆ m_position

ExactModelCoordinate FIFE::Camera::m_position
private

◆ m_referenceScaleX

double FIFE::Camera::m_referenceScaleX
private

◆ m_referenceScaleY

double FIFE::Camera::m_referenceScaleY
private

◆ m_renderbackend

RenderBackend* FIFE::Camera::m_renderbackend
private

Definition at line 419 of file camera.h.

Referenced by render(), renderOverlay(), renderStaticLayer(), and resetLightingColor().

◆ m_renderers

std::map<std::string, RendererBase*> FIFE::Camera::m_renderers
private

Definition at line 487 of file camera.h.

Referenced by addRenderer(), getRenderer(), onRendererEnabledChanged(), resetRenderers(), and ~Camera().

◆ m_rotation

double FIFE::Camera::m_rotation
private

◆ m_screen_2_vscreen

DoubleMatrix FIFE::Camera::m_screen_2_vscreen
private

Definition at line 464 of file camera.h.

Referenced by screenToVirtualScreen(), and updateMatrices().

◆ m_screenCellHeight

uint32_t FIFE::Camera::m_screenCellHeight
private

Definition at line 477 of file camera.h.

Referenced by getCellImageDimensions(), setCellImageDimensions(), and updateReferenceScale().

◆ m_screenCellWidth

uint32_t FIFE::Camera::m_screenCellWidth
private

Definition at line 476 of file camera.h.

Referenced by getCellImageDimensions(), setCellImageDimensions(), and updateReferenceScale().

◆ m_start_time

uint32_t FIFE::Camera::m_start_time
private

Definition at line 512 of file camera.h.

Referenced by renderOverlay(), and setOverlayAnimation().

◆ m_tilt

double FIFE::Camera::m_tilt
private

◆ m_transform

◆ m_updated

bool FIFE::Camera::m_updated
private

Definition at line 490 of file camera.h.

Referenced by isUpdated(), render(), and resetUpdates().

◆ m_viewport

Rect FIFE::Camera::m_viewport
private

◆ m_vs_inverse_matrix

DoubleMatrix FIFE::Camera::m_vs_inverse_matrix
private

Definition at line 462 of file camera.h.

Referenced by updateMatrices().

◆ m_vs_matrix

DoubleMatrix FIFE::Camera::m_vs_matrix
private

Definition at line 461 of file camera.h.

Referenced by toVirtualScreenCoordinates(), and updateMatrices().

◆ m_vscreen_2_screen

DoubleMatrix FIFE::Camera::m_vscreen_2_screen
private

Definition at line 463 of file camera.h.

Referenced by updateMatrices(), and virtualScreenToScreen().

◆ m_zoom

double FIFE::Camera::m_zoom
private

Definition at line 468 of file camera.h.

Referenced by getMatchingInstances(), getZoom(), setZoom(), and updateMatrices().

◆ m_zToY

double FIFE::Camera::m_zToY
private

Definition at line 469 of file camera.h.

Referenced by getZToY(), setZToY(), and updateMatrices().


The documentation for this class was generated from the following files: