ArnieBoids  1.0.0
JOINT AI PROJECT
Camera Class Reference

Camera class. Camera that can follow target a ship. Zoom and Independent movement also possible. Handles drawing of HUD, only if a ship is targeted. More...

#include <Camera.hpp>

Inheritance diagram for Camera:
Collaboration diagram for Camera:

Public Member Functions

 Camera (sf::RenderTarget &target)
 
void setTarget (Ship *target)
 
ShipgetTarget ()
 
void clearTarget (bool savexf)
 Clears the camera's target, can keep camera on target's last position or reset. More...
 
void loadFont (std::string filename)
 Loads a font, required for drawing HUD. More...
 
void update ()
 Updates camera's center to where the target is. More...
 
void move (sf::Vector2f xf)
 Move controls for the camera. More...
 
void moveReset ()
 
void zoomIn ()
 Zoom controls for camera. More...
 
void zoomOut ()
 
void zoomSet (float mult)
 
void zoomReset ()
 
void drawHUD ()
 HUD Drawing controls, both of these change render target for their duration. More...
 
void drawRadar (std::list< Ship * > &objList, sf::Vector2f centre, float radius)
 
float getZoomPercent () const
 Returns zoom factor as a percentage. More...
 

Private Member Functions

void drawText (std::string info, sf::Vector2f pos, sf::Color color)
 
void drawRadarObj (sf::ConvexShape *shape)
 Draws a color text at pos to HUD, called by drawHUD() More...
 
sf::Vector2f worldToRadar (sf::Vector2f const &worldPos)
 Converts a vector from world space down through range and into radar on-screen space. More...
 
sf::Vector2f translateVector (sf::Vector2f pos, sf::FloatRect src, sf::FloatRect dest)
 Translates pos in coordinate space src to equivalent in coord space dest. More...
 

Private Attributes

Shiptarget_
 The target followed ship. More...
 
sf::Vector2f screenSize_
 Keep a record of the screen size for resets. More...
 
float zoomFactor_
 The internal factor of the zoom. More...
 
float zoomStep_
 Zoom step [0.25 == 25%]. More...
 
sf::Vector2f move_
 Translation Vector of camera. More...
 
sf::Font * font_
 Font to draw HUD with. More...
 
sf::Text text_
 HUD is drawn with a single text. More...
 
sf::RenderTarget & rentrg_
 HUD is drawn to this target. More...
 
int radarSize_
 Radar size within HUD. More...
 
sf::Vector2f radarPos_
 Radar position within HUD. More...
 

Detailed Description

Camera class. Camera that can follow target a ship. Zoom and Independent movement also possible. Handles drawing of HUD, only if a ship is targeted.

Remarks
I,J,K,L moves the camera. I and O zoom in and out respectively.

Constructor & Destructor Documentation

Camera::Camera ( sf::RenderTarget &  target)

Member Function Documentation

void Camera::clearTarget ( bool  savexf)

Clears the camera's target, can keep camera on target's last position or reset.

Here is the caller graph for this function:

void Camera::drawHUD ( )

HUD Drawing controls, both of these change render target for their duration.

Here is the call graph for this function:

Here is the caller graph for this function:

void Camera::drawRadar ( std::list< Ship * > &  objList,
sf::Vector2f  centre,
float  radius 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Camera::drawRadarObj ( sf::ConvexShape *  shape)
private

Draws a color text at pos to HUD, called by drawHUD()

Draws a single radar object to radar, called by drawRadar()

Here is the call graph for this function:

Here is the caller graph for this function:

void Camera::drawText ( std::string  info,
sf::Vector2f  pos = sf::Vector2f(0, 0),
sf::Color  color = sf::Color::White 
)
private

Here is the caller graph for this function:

Ship * Camera::getTarget ( )

Here is the caller graph for this function:

float Camera::getZoomPercent ( ) const

Returns zoom factor as a percentage.

Here is the caller graph for this function:

void Camera::loadFont ( std::string  filename)

Loads a font, required for drawing HUD.

Here is the caller graph for this function:

void Camera::move ( sf::Vector2f  xf)

Move controls for the camera.

Here is the caller graph for this function:

void Camera::moveReset ( )

Here is the caller graph for this function:

void Camera::setTarget ( Ship target)

Here is the caller graph for this function:

sf::Vector2f Camera::translateVector ( sf::Vector2f  pos,
sf::FloatRect  src,
sf::FloatRect  dest 
)
private

Translates pos in coordinate space src to equivalent in coord space dest.

Here is the caller graph for this function:

void Camera::update ( )

Updates camera's center to where the target is.

Here is the caller graph for this function:

sf::Vector2f Camera::worldToRadar ( sf::Vector2f const &  worldPos)
private

Converts a vector from world space down through range and into radar on-screen space.

Here is the call graph for this function:

Here is the caller graph for this function:

void Camera::zoomIn ( )

Zoom controls for camera.

Here is the caller graph for this function:

void Camera::zoomOut ( )

Here is the caller graph for this function:

void Camera::zoomReset ( )

Here is the caller graph for this function:

void Camera::zoomSet ( float  mult)

Member Data Documentation

sf::Font* Camera::font_
private

Font to draw HUD with.

sf::Vector2f Camera::move_
private

Translation Vector of camera.

sf::Vector2f Camera::radarPos_
private

Radar position within HUD.

int Camera::radarSize_
private

Radar size within HUD.

sf::RenderTarget& Camera::rentrg_
private

HUD is drawn to this target.

sf::Vector2f Camera::screenSize_
private

Keep a record of the screen size for resets.

Ship* Camera::target_
private

The target followed ship.

sf::Text Camera::text_
private

HUD is drawn with a single text.

float Camera::zoomFactor_
private

The internal factor of the zoom.

float Camera::zoomStep_
private

Zoom step [0.25 == 25%].


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