SuperTuxKart
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Camera Class Reference

This is the base class for all cameras. More...

#include <camera.hpp>

Inheritance diagram for Camera:
Inheritance graph
[legend]

Public Types

enum  CameraType { CM_TYPE_NORMAL, CM_TYPE_DEBUG, CM_TYPE_FPS, CM_TYPE_END }
 The different camera types that can be used. More...
 
enum  Mode {
  CM_NORMAL, CM_CLOSEUP, CM_REVERSE, CM_LEADER_MODE,
  CM_SIMPLE_REPLAY, CM_FALLING
}
 

Public Member Functions

void setMode (Mode mode)
 Sets the mode of the camera. More...
 
Mode getMode ()
 Set the camera to the given mode. More...
 
void setKart (AbstractKart *new_kart)
 Changes the owner of this camera to the new kart. More...
 
virtual void setInitialTransform ()
 Saves the current kart position as initial starting position for the camera.
 
virtual void activate (bool alsoActivateInIrrlicht=true)
 Sets viewport etc. More...
 
virtual void update (float dt)
 Called once per time frame to move the camera to the right position. More...
 
CameraType getType ()
 Returns the type of this camera. More...
 
void setFoV ()
 Sets the field of view for the irrlicht camera. More...
 
int getIndex () const
 Returns the camera index (or player kart index, which is the same). More...
 
core::matrix4 getPreviousPVMatrix () const
 Returns the project-view matrix of the previous frame. More...
 
void setPreviousPVMatrix (core::matrix4 mat)
 Returns the project-view matrix of the previous frame. More...
 
const AbstractKartgetKart () const
 Returns the kart to which this camera is attached. More...
 
AbstractKartgetKart ()
 Returns the kart to which this camera is attached. More...
 
void setAmbientLight (const video::SColor &color)
 Sets the ambient light for this camera. More...
 
const video::SColor & getAmbientLight () const
 Returns the current ambient light. More...
 
const core::recti & getViewport () const
 Returns the viewport of this camera. More...
 
const core::vector2df & getScaling () const
 Returns the scaling in x/y direction for this camera. More...
 
scene::ICameraSceneNode * getCameraSceneNode ()
 Returns the camera scene node. More...
 
Vec3 getXYZ ()
 Returs the absolute position of the camera. More...
 

Static Public Member Functions

static CameracreateCamera (AbstractKart *kart, const int index)
 Creates a new camera and adds it to the list of all cameras. More...
 
static void resetAllCameras ()
 
static void changeCamera (unsigned int camera_index, CameraType type)
 
static void setDefaultCameraType (CameraType type)
 Sets the default type for each camera that will be created. More...
 
static CameraType getDefaultCameraType ()
 Returns the default type for each camera that will be created. More...
 
static unsigned int getNumCameras ()
 Returns the number of cameras used. More...
 
static CameragetCamera (unsigned int n)
 Returns a camera. More...
 
static CameragetActiveCamera ()
 Returns the currently active camera. More...
 
static void removeAllCameras ()
 Remove all cameras. More...
 

Protected Member Functions

 Camera (CameraType type, int camera_index, AbstractKart *kart)
 
virtual ~Camera ()
 Removes the camera scene node from the scene.
 
virtual void reset ()
 Reset is called when a new race starts. More...
 

Static Protected Member Functions

static CameracreateCamera (unsigned int index, CameraType type, AbstractKart *kart)
 Creates a camera of the specified type, but does not add it to the list of all cameras. More...
 

Protected Attributes

scene::ICameraSceneNode * m_camera
 The camera scene node. More...
 
AbstractKartm_kart
 The kart that the camera follows. More...
 

Private Member Functions

void setupCamera ()
 Sets up the viewport, aspect ratio, field of view, and scaling for this camera.
 

Private Attributes

core::matrix4 m_previous_pv_matrix
 The project-view matrix of the previous frame, used for the blur shader. More...
 
Mode m_mode
 Camera's mode. More...
 
CameraType m_type
 The type of the camera. More...
 
unsigned int m_index
 The index of this camera which is the index of the kart it is attached to. More...
 
video::SColor m_ambient_light
 Current ambient light for this camera. More...
 
AbstractKartm_original_kart
 A pointer to the original kart the camera was pointing at when it was created. More...
 
core::recti m_viewport
 The viewport for this camera (portion of the game window covered by this camera)
 
core::vector2df m_scaling
 The scaling necessary for each axis. More...
 
float m_fov
 Field of view for the camera. More...
 
float m_aspect
 Aspect ratio for camera. More...
 

Static Private Attributes

static Cameras_active_camera = NULL
 
static CameraType m_default_type = Camera::CM_TYPE_NORMAL
 The default type for any newly created camera. More...
 
static std::vector< Camera * > m_all_cameras
 List of all cameras. More...
 

Detailed Description

This is the base class for all cameras.

It also includes some static functios to keep track of all cameras (e.g. a static function to create a camera, get a camera with a specified index).

Member Enumeration Documentation

◆ CameraType

The different camera types that can be used.

Enumerator
CM_TYPE_DEBUG 

A debug camera.

CM_TYPE_FPS 

FPS Camera.

CM_TYPE_END 

End camera.

◆ Mode

Enumerator
CM_NORMAL 

Normal camera mode.

CM_CLOSEUP 

Closer to kart.

CM_REVERSE 

Looking backwards.

CM_LEADER_MODE 

for deleted player karts in follow the leader

Member Function Documentation

◆ activate()

void Camera::activate ( bool  alsoActivateInIrrlicht = true)
virtual

Sets viewport etc.

for this camera. Called from irr_driver just before rendering the view for this kart.

◆ createCamera() [1/2]

Camera * Camera::createCamera ( unsigned int  index,
CameraType  type,
AbstractKart kart 
)
staticprotected

Creates a camera of the specified type, but does not add it to the list of all cameras.

This is a helper function for other static functions. \paran index Index this camera has in the list of all cameras.

Parameters
typeThe camera type of the camera to create.
kartTo which kart the camera is attached (NULL if a free camera).

◆ createCamera() [2/2]

Camera * Camera::createCamera ( AbstractKart kart,
const int  index 
)
static

Creates a new camera and adds it to the list of all cameras.

Also the camera index (which determines which viewport to use in split screen) is set.

◆ getActiveCamera()

static Camera* Camera::getActiveCamera ( )
inlinestatic

Returns the currently active camera.

◆ getAmbientLight()

const video::SColor& Camera::getAmbientLight ( ) const
inline

Returns the current ambient light.

◆ getCamera()

static Camera* Camera::getCamera ( unsigned int  n)
inlinestatic

Returns a camera.

◆ getCameraSceneNode()

scene::ICameraSceneNode* Camera::getCameraSceneNode ( )
inline

Returns the camera scene node.

◆ getDefaultCameraType()

static CameraType Camera::getDefaultCameraType ( )
inlinestatic

Returns the default type for each camera that will be created.

Used for command line parameters to select a debug etc camera.

◆ getIndex()

int Camera::getIndex ( ) const
inline

Returns the camera index (or player kart index, which is the same).

◆ getKart() [1/2]

const AbstractKart* Camera::getKart ( ) const
inline

Returns the kart to which this camera is attached.

◆ getKart() [2/2]

AbstractKart* Camera::getKart ( )
inline

Returns the kart to which this camera is attached.

◆ getMode()

Camera::Mode Camera::getMode ( )

Set the camera to the given mode.

Returns the current mode of the camera.

◆ getNumCameras()

static unsigned int Camera::getNumCameras ( )
inlinestatic

Returns the number of cameras used.

◆ getPreviousPVMatrix()

core::matrix4 Camera::getPreviousPVMatrix ( ) const
inline

Returns the project-view matrix of the previous frame.

◆ getScaling()

const core::vector2df& Camera::getScaling ( ) const
inline

Returns the scaling in x/y direction for this camera.

◆ getType()

CameraType Camera::getType ( )
inline

Returns the type of this camera.

◆ getViewport()

const core::recti& Camera::getViewport ( ) const
inline

Returns the viewport of this camera.

◆ getXYZ()

Vec3 Camera::getXYZ ( )
inline

Returs the absolute position of the camera.

◆ removeAllCameras()

static void Camera::removeAllCameras ( )
inlinestatic

Remove all cameras.

◆ reset()

void Camera::reset ( )
protectedvirtual

Reset is called when a new race starts.

Make sure that the camera is aligned neutral, and not like in the previous race

◆ setAmbientLight()

void Camera::setAmbientLight ( const video::SColor &  color)
inline

Sets the ambient light for this camera.

◆ setDefaultCameraType()

static void Camera::setDefaultCameraType ( CameraType  type)
inlinestatic

Sets the default type for each camera that will be created.

Used for command line parameters to select a debug etc camera.

◆ setFoV()

void Camera::setFoV ( )
inline

Sets the field of view for the irrlicht camera.

◆ setKart()

void Camera::setKart ( AbstractKart new_kart)

Changes the owner of this camera to the new kart.

Parameters
new_kartThe new kart to use this camera.

◆ setMode()

void Camera::setMode ( Mode  mode)

Sets the mode of the camera.

Parameters
modeMode the camera should be switched to.

◆ setPreviousPVMatrix()

void Camera::setPreviousPVMatrix ( core::matrix4  mat)
inline

Returns the project-view matrix of the previous frame.

◆ update()

void Camera::update ( float  dt)
virtual

Called once per time frame to move the camera to the right position.

Parameters
dtTime step.

Reimplemented in CameraEnd, CameraFPS, CameraNormal, and CameraDebug.

Member Data Documentation

◆ m_all_cameras

std::vector< Camera * > Camera::m_all_cameras
staticprivate

List of all cameras.

◆ m_ambient_light

video::SColor Camera::m_ambient_light
private

Current ambient light for this camera.

◆ m_aspect

float Camera::m_aspect
private

Aspect ratio for camera.

◆ m_camera

scene::ICameraSceneNode* Camera::m_camera
protected

The camera scene node.

◆ m_default_type

Camera::CameraType Camera::m_default_type = Camera::CM_TYPE_NORMAL
staticprivate

The default type for any newly created camera.

Used to store command line parameters.

◆ m_fov

float Camera::m_fov
private

Field of view for the camera.

◆ m_index

unsigned int Camera::m_index
private

The index of this camera which is the index of the kart it is attached to.

◆ m_kart

AbstractKart* Camera::m_kart
protected

The kart that the camera follows.

It can't be const, since in profile mode the camera might change its owner. May be NULL (example: cutscene camera)

◆ m_mode

Mode Camera::m_mode
private

Camera's mode.

◆ m_original_kart

AbstractKart* Camera::m_original_kart
private

A pointer to the original kart the camera was pointing at when it was created.

Used when restarting a race (since the camera might get attached to another kart if a kart is elimiated).

◆ m_previous_pv_matrix

core::matrix4 Camera::m_previous_pv_matrix
private

The project-view matrix of the previous frame, used for the blur shader.

◆ m_scaling

core::vector2df Camera::m_scaling
private

The scaling necessary for each axis.

◆ m_type

CameraType Camera::m_type
private

The type of the camera.


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