Creating and using the IonCamera class. More...

Collaboration diagram for Ion Camera:

Detailed Description

Creating and using the IonCamera class.

The user is able to create and load their own custom Cameras via the IonCamera class. This base class acts as a wrapper for the Camera class and allows the user to set up code to be executed every frame via the IonCamera::Update() function. This class contains:

For example implementation, lets make a simple Ion Camera class that rotates around a given point on creation:

RotateCam.h:

#include ".\Ion Engine\IonCamera.h"
class RotateCam : public IonCamera
{
...
public:
...
virtual void Update() override;
...
}

RotateCam.cpp:

RotateCam::RotateCam(const Vect& pos)
{
//position = pos;
pCamera = new Camera(Camera::Type::PERSPECTIVE_3D);
pCamera->setViewport(0, 0, IonEngine::GetWindowWidth(), IonEngine::GetWindowHeight());
pCamera->setPerspective(60.0f, float(IonEngine::GetWindowWidth()) / float(IonEngine::GetWindowHeight()), 1.0f, 5000.0f);
// Orient Camera
up3DCam = Vect(0.0f, 1.0f, 0.0f);
pos3DCam = pos + Vect(50, 40, 30);
lookAt3DCam = pos;
pCamera->setOrientAndPosition(up3DCam, lookAt3DCam, pos3DCam);
pCamera->updateCamera();
}
...
void RotateCam::Update()
{
pos3DCam *= Matrix(ROT_Y, 0.01f);
pCamera->setOrientAndPosition(up3DCam, lookAt3DCam, pos3DCam);
pCamera->updateCamera();
}

UserScene.cpp:

void UserScene::Initialize()
{
...
rotCam = new RotateCam( Vect(10,1,10) );
this->SetCamera(rotCam);
...
}

This IonCamera is given a Vector to look at, sets up the pCamera Orientation and Position, then updates its position every frame in the IonCamera::Update() function.

To enable the IonCamera, the user creates a new RotateCam in their Scene and uses the Scene::SetCamera() function.

Classes

class  IonCamera
 Camera wrapper base class for making custom cameras. More...