SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | 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_SPECTATOR_SOCCER , CM_SPECTATOR_TOP_VIEW , CM_SIMPLE_REPLAY , CM_FALLING
}
 

Public Member Functions

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

Static Public Member Functions

static CameracreateCamera (AbstractKart *kart, const int index)
 Creates a new camera and adds it to the list of all cameras.
 
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.
 
static CameraType getDefaultCameraType ()
 Returns the default type for each camera that will be created.
 
static unsigned int getNumCameras ()
 Returns the number of cameras used.
 
static CameragetCamera (unsigned int n)
 Returns a camera.
 
static CameragetActiveCamera ()
 Returns the currently active camera.
 
static void removeAllCameras ()
 Remove all cameras.
 

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.
 

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.
 

Protected Attributes

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

Private Attributes

core::matrix4 m_previous_pv_matrix
 The project-view matrix of the previous frame, used for the blur shader.
 
Mode m_mode
 Camera's mode.
 
Mode m_previous_mode
 
CameraType m_type
 The type of the camera.
 
unsigned int m_index
 The index of this camera which is the index of the kart it is attached to.
 
video::SColor m_ambient_light
 Current ambient light for this camera.
 
AbstractKartm_original_kart
 A pointer to the original kart the camera was pointing at when it was created.
 
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.
 
float m_fov
 Field of view for the camera.
 
float m_aspect
 Aspect ratio for camera.
 

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.
 
static std::vector< Camera * > m_all_cameras
 List of all cameras.
 

Detailed Description

This is the base class for all cameras.

It also includes some static functions 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

CM_SPECTATOR_SOCCER 

for spectator (in soccer mode)

CM_SPECTATOR_TOP_VIEW 

for spectator (top view on ball if soccer or top view on kart)

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

◆ createCamera() [2/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.

Parameters
indexIndex this camera has in the list of all cameras.
typeThe camera type of the camera to create.
kartTo which kart the camera is attached (NULL if a free camera).

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

◆ getMode()

Camera::Mode Camera::getMode ( )

Set the camera to the given mode.

Returns the current mode of the camera.

◆ 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

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

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

◆ 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 CameraDebug, CameraEnd, CameraFPS, and CameraNormal.

Member Data Documentation

◆ 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_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_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).


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