App::ICameraManager class

This manager handles the cameras in the game.

A camera is represented by the class ICamera, and is responsible of setting the view transformations necessary for the game to render. The manager can only have one active camera at a time; this active camera receives the user input (mouse and keyboard) and updates the view transformations used for rendering. The cameras are mapped by ID and, optionally, by a name.

The manager also contains a map of camera types. An ID is mapped to a factory function that creates an ICamera of the appropiate type; when a camera .prop file is readed, the camera will be created with the appropiate factory according to its 'cameraType' property. On initialization, the manager reads all the cameras in the 0x40410100 (camera_properties~) folder.

This manager is different from most managers, that have a Get() method to get the current instance. ICameraManager depends on the mode manager, and therefore the method IGameModeManager::GetCameraManager() must be used.

Base classes

class IMessageListener
An interface that can receive messages sent through the app.

Derived classes

class cCameraManager
The implementation of ICameraManager; this should only be used for extending and detouring.

Constructors, destructors, conversion operators

~ICameraManager() virtual

Public functions

auto Initialize(const char* pCheatName) -> bool pure virtual
auto Dispose() -> bool pure virtual
void SetViewer(cViewer* pViewer) pure virtual
Sets the Viewer that will receive the results of the camera in this camera manager.
auto GetViewer() -> cViewer* pure virtual
Gets the Viewer that will receive the results of the camera in this camera manager.
void AddCameraType(uint32_t typeID, CameraFactoryFunction_t function) pure virtual
Adds a new camera type.
void PutCamera(uint32_t cameraID, ICamera* pCamera, const char16_t* pName = nullptr) pure virtual
Adds a new camera into this manager.
void ParseCameras() pure virtual
Reads and stores in this manager all the cameras in the 0x40410100 (camera_properties~) folder.
void Update(int nDeltaTime) pure virtual
A method called every game loop that updates the active camera.
auto SetActiveCameraByKey(const char16_t* pKeyString) -> bool pure virtual
Sets the active camera to the one that matches the given key string.
auto SetActiveCameraByID(uint32_t cameraID) -> bool pure virtual
Sets the active camera to the one mapped to the given ID.
auto GetActiveCamera() -> ICamera* pure virtual
Returns the currently active camera, or nullptr if there is no active camera.
auto GetActiveCameraID() -> uint32_t pure virtual
Returns the ID mapped to the currently active camera, or 0 if there is no active camera.
auto GetCamera(uint32_t cameraID) -> ICamera* pure virtual
Returns the ICamera mapped to the given ID, or nullptr if there is no camera mapped to that ID.
auto GetCameraID(const char* pName) -> uint32_t pure virtual
Returns the ID of the camera mapped to the given name, or 0 if there is no ID mapped to that name.
auto GetCamerasCount() -> size_t pure virtual
Returns the number of cameras contained in this manager.
auto GetCameraAt(int nIndex) -> ICamera* pure virtual
Returns the ICamera at the given index, or nullptr if the index is not valid.
auto GetCameraIDAt(int nIndex) -> uint32_t pure virtual
Returns the camera ID at the given index, or nullptr if the index is not valid.
auto SetActiveCamera(int nIndex) -> bool pure virtual
Sets the active camera of this manager, which will be used to calculate all the view transformations used for rendering, and that will receive all the input events.
auto GetActiveCameraIndex() -> int pure virtual
Returns the index of the currently active camera, or -1 if there is no active camera.
void RemoveCameras() pure virtual
Removes all the cameras and their mappings from this manager.

Function documentation

void App::ICameraManager::SetViewer(cViewer* pViewer) pure virtual

Sets the Viewer that will receive the results of the camera in this camera manager.

Parameters
pViewer The new Viewer.

void App::ICameraManager::AddCameraType(uint32_t typeID, CameraFactoryFunction_t function) pure virtual

Adds a new camera type.

Parameters
typeID The ID that identifies this type of camera.
function A function that takes a App::PropertyList* parameter and returns an ICamera*.

When a camera settings .prop file uses the 'cameraType' property with this typeID value, the given factory function will be called to create a new ICamera.

void App::ICameraManager::PutCamera(uint32_t cameraID, ICamera* pCamera, const char16_t* pName = nullptr) pure virtual

Adds a new camera into this manager.

Parameters
cameraID The ID that uniquely identifices the camera.
pCamera The new ICamera.
pName [Optional] A string that identifies the camera.

The camera will be mapped to the given cameraID and ICamera::OnAttach(ICameraManager*) will be called. If another camera is already mapped to that ID, ICamera::OnDeattach() will be called on it. Additionally, if the camera replaced is the active one, ICamera::OnExit() will be called, and the new camera will be the active.

A name can also be optionally specified.

void App::ICameraManager::Update(int nDeltaTime) pure virtual

A method called every game loop that updates the active camera.

Parameters
nDeltaTime The time ellapsed since the last call, in milliseconds.

This will call the ICamera::Update() method on the active camera, passing the manager Viewer as a parameter.

bool App::ICameraManager::SetActiveCameraByKey(const char16_t* pKeyString) pure virtual

Sets the active camera to the one that matches the given key string.

Parameters
pKeyString The string representation of a ResourceKey.
Returns True if the active camera was changed, false otherwise.

Only the instance ID will be used, the rest will be ignored. The string will be parsed using ResourceKey::Parse(). This will call SetActiveCameraByID(uint32_t).

bool App::ICameraManager::SetActiveCameraByID(uint32_t cameraID) pure virtual

Sets the active camera to the one mapped to the given ID.

Parameters
cameraID The ID of the new active camera.
Returns True if the active camera was changed, false otherwise.

If the ID is not mapped, nothing will happen. This will call SetActiveCamera(size_t)

ICamera* App::ICameraManager::GetCamera(uint32_t cameraID) pure virtual

Returns the ICamera mapped to the given ID, or nullptr if there is no camera mapped to that ID.

Parameters
cameraID The ID of the camera.

uint32_t App::ICameraManager::GetCameraID(const char* pName) pure virtual

Returns the ID of the camera mapped to the given name, or 0 if there is no ID mapped to that name.

Parameters
pName A char c-string.

ICamera* App::ICameraManager::GetCameraAt(int nIndex) pure virtual

Returns the ICamera at the given index, or nullptr if the index is not valid.

Parameters
nIndex

uint32_t App::ICameraManager::GetCameraIDAt(int nIndex) pure virtual

Returns the camera ID at the given index, or nullptr if the index is not valid.

Parameters
nIndex

bool App::ICameraManager::SetActiveCamera(int nIndex) pure virtual

Sets the active camera of this manager, which will be used to calculate all the view transformations used for rendering, and that will receive all the input events.

Parameters
nIndex The index of the new active camera.
Returns True if the active camera changed, false otherwise.

ICamera::OnEnter() will be called on the new active camera, and ICamera::OnExit() will be caleld on the old active camera.