NWengine 0.9
Loading...
Searching...
No Matches
Camera Class Reference

The Camera class represents a camera in the game world. More...

#include <Camera.h>

Inheritance diagram for Camera:
GameComponent Serialized

Public Member Functions

 Camera ()=default
 Default constructor for the Camera class.
 
 Camera (GameObject *go)
 Constructor for the Camera class.
 
 ~Camera ()
 Destructor for the Camera class.
 
void Capture ()
 Captures the camera.
 
void Update ()
 Updates the camera.
 
void ChangeOrtho (float sizeX, float sizeY)
 Changes the orthographic size of the camera.
 
void MoveTo (Vector2< int > target, float interpolationTime)
 Moves the camera to the target position with interpolation.
 
void Use ()
 Uses the camera.
 
int Serialize (std::fstream *data, int offset) override
 Serialize the object and write it to the file.
 
int Deserialize (std::fstream *data, int offset) override
 Deserialize the object from the file.
 
- Public Member Functions inherited from GameComponent
virtual void Start ()
 Start the game component.
 
virtual void SetGameObject (void *go)
 Set the GameObject associated with the game component.
 
virtual voidGetGameObject ()
 Get the GameObject associated with the game component.
 
virtual ~GameComponent ()
 Destructor for the game component.
 
- Public Member Functions inherited from Serialized
 Serialized ()
 Default constructor for Serialized class.
 

Static Public Member Functions

static std::string GetType ()
 Gets the type of the camera.
 
static void UpdateActiveCamera ()
 Updates the active camera.
 
- Static Public Member Functions inherited from GameComponent
static std::string GetType ()
 Get the type of the game component.
 

Public Attributes

Matrix4< floatprojectionMatrix
 
Matrix4< floatviewMatrix = Matrix4<float>(1.0f)
 
fVec2 size
 
fVec2 viewPortSize
 
fVec3 clearColor = fVec3(0.0,0.0, 0.0)
 
float alpha = 1.0f
 
bool isActive = 0
 
GameObjectattachedObj = nullptr
 
fVec2 position = fVec2(0.0f,0.0f)
 
float rotation = 0.0f
 
float zoom = 1.0
 
FrameBuffer fbo
 

Static Public Attributes

static CameraActiveCamera = nullptr
 

Detailed Description

The Camera class represents a camera in the game world.

Represents a camera component that can be attached to a game object.

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( GameObject * go)

Constructor for the Camera class.

Parameters
goThe game object to attach the camera to.

Member Function Documentation

◆ Capture()

void Camera::Capture ( )

Captures the camera.

Captures current scene (see currentScene variable in Scene class)

◆ ChangeOrtho()

void Camera::ChangeOrtho ( float sizeX,
float sizeY )

Changes the orthographic size of the camera.

Parameters
sizeXThe new size along the X-axis.
sizeYThe new size along the Y-axis.

◆ Deserialize()

int Camera::Deserialize ( std::fstream * data,
int offset )
overridevirtual

Deserialize the object from the file.

Parameters
dataThe file stream to read the serialized data from.
offsetThe offset in the file to start reading the serialized data.
Returns
The number of bytes read from the file, or -1 if an error occurred.

Reimplemented from Serialized.

◆ GetType()

static std::string Camera::GetType ( )
inlinestatic

Gets the type of the camera.

Returns
The type of the camera.

◆ MoveTo()

void Camera::MoveTo ( Vector2< int > target,
float interpolationTime )

Moves the camera to the target position with interpolation.

Parameters
targetThe target position to move the camera to.
interpolationTimeThe time taken for the interpolation.

◆ Serialize()

int Camera::Serialize ( std::fstream * data,
int offset )
overridevirtual

Serialize the object and write it to the file.

Parameters
dataThe file stream to write the serialized data to.
offsetThe offset in the file to start writing the serialized data.
Returns
The number of bytes written to the file, or -1 if an error occurred.

Reimplemented from Serialized.

◆ Update()

void Camera::Update ( )
virtual

Updates the camera.

Reimplemented from GameComponent.

◆ UpdateActiveCamera()

void Camera::UpdateActiveCamera ( )
static

Updates the active camera.

This static method calls capture on ActiveCamera if not null.

Member Data Documentation

◆ ActiveCamera

Camera * Camera::ActiveCamera = nullptr
static

The active camera.

◆ alpha

float Camera::alpha = 1.0f

The alpha value of the camera.

◆ attachedObj

GameObject* Camera::attachedObj = nullptr

The attached game object of the camera.

◆ clearColor

fVec3 Camera::clearColor = fVec3(0.0,0.0, 0.0)

The clear color of the camera.

◆ fbo

FrameBuffer Camera::fbo

The frame buffer object of the camera.

◆ isActive

bool Camera::isActive = 0

Indicates whether the camera is active or not.

◆ position

fVec2 Camera::position = fVec2(0.0f,0.0f)

The position of the camera.

◆ projectionMatrix

Matrix4<float> Camera::projectionMatrix

The projection matrix of the camera.

◆ rotation

float Camera::rotation = 0.0f

The rotation of the camera.

◆ size

fVec2 Camera::size

The size of the camera.

◆ viewMatrix

Matrix4<float> Camera::viewMatrix = Matrix4<float>(1.0f)

The view matrix of the camera.

◆ viewPortSize

fVec2 Camera::viewPortSize

The viewport size of the camera.

◆ zoom

float Camera::zoom = 1.0

The zoom level of the camera.


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