Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Graphics::Camera Class Reference

Class for camera. More...

#include <camera.h>

Inheritance diagram for Graphics::Camera:
Component Events::Subject Events::Observer

Public Member Functions

 Camera ()=delete
 
 Camera (const std::shared_ptr< ShaderManager > shader_manager)
 Constructor for Camera. More...
 
 Camera (const std::shared_ptr< ShaderManager > shader_manager, const float viewport_width, const float viewport_height, const float near=0.1, const float far=1.0)
 Constructor for Camera. More...
 
virtual void onStart () override
 Called when the engine starts and when a new scene is loaded. More...
 
virtual bool onUpdate (const double delta) override
 Called every engine loop. More...
 
virtual void onDestroy () override
 Called when the engine is shutting down. More...
 
void setScreenPaddingInTiles (const int padding) noexcept
 Sets the screen padding in tiles. More...
 
int getScreenPaddingInTiles () const noexcept
 Gets the screen padding in tiles. More...
 
void setWidth (const float width) noexcept
 Sets the width. More...
 
float getWidth () const noexcept
 Gets the width. More...
 
void setHeight (const float height) noexcept
 Sets the height. More...
 
float getHeight () const noexcept
 Gets the height. More...
 
void setNear (const float near) noexcept
 Sets the near z plane. More...
 
float getNear () const noexcept
 Gets the near z plane. More...
 
void setFar (const float far) noexcept
 Sets the far z plane. More...
 
float getFar () const noexcept
 Gets the far z plane. More...
 
void setFreeCameraSpeed (const float speed) noexcept
 Sets the free camera speed when in free camera mode. More...
 
float getFreeCameraSpeed () const noexcept
 Gets the free camera speed when in free camera mode. More...
 
glm::mat4 getProjectionMatrix () const noexcept
 Gets the projection matrix. More...
 
bool isComponentWithin (const Component &component) const
 Determines if component within. More...
 
virtual std::string className () const noexceptoverride
 Returns a string representing the class name. More...
 
virtual unsigned long long getValueForSorting () const noexceptoverride
 Gets the value for sorting. More...
 
virtual void onNotifyNow (std::shared_ptr< Events::Event > event) override
 When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More...
 
virtual void handleQueuedEvent (std::shared_ptr< Events::Event > event) override
 HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More...
 
virtual void log (el::base::type::ostream_t &os) const override
 
- Public Member Functions inherited from Component
 Component ()
 Component constructor. More...
 
void setTransform (std::shared_ptr< Transform > transform)
 Sets the transform. More...
 
std::shared_ptr< TransformgetTransform () const noexcept
 Gets the transform. More...
 
void setActive (const bool active) noexcept
 Sets the component active or inactive. More...
 
bool isActive () const noexcept
 Determines if active. More...
 
unsigned int getId () const noexcept
 Gets the identifier. More...
 
virtual std::string to_string () const noexcept
 Returns a string representation of the object. More...
 
bool operator< (Component &other) noexcept
 Operator < using getValueForSorting. More...
 
virtual ~Component ()
 Destroys the object. More...
 
- Public Member Functions inherited from Events::Subject
virtual ~Subject ()=default
 
virtual void notify (std::shared_ptr< Event > event)
 notify is used to tell observers of an event. More...
 
virtual void notifyNow (std::shared_ptr< Event > event)
 notifyNow is used to tell observers of an event as an interrupt. More...
 
virtual void addObserver (std::shared_ptr< Observer > observer)
 Adds an observer. More...
 
virtual void removeObserver (std::shared_ptr< Observer > observer)
 Removes an observer. More...
 
- Public Member Functions inherited from Events::Observer
virtual ~Observer ()
 
void onNotify (std::shared_ptr< Event > event)
 When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More...
 
void processEventQueue ()
 This should be called once ever loop for every Observer to properly use queued events. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Events::Observer
std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 
- Protected Attributes inherited from Component
std::weak_ptr< Entityentity
 
std::shared_ptr< Transformtransform
 
bool active
 
unsigned int id
 
- Static Protected Attributes inherited from Component
static unsigned int next_id = 0
 

Detailed Description

Class for camera.

Constructor & Destructor Documentation

Graphics::Camera::Camera ( )
delete
Graphics::Camera::Camera ( const std::shared_ptr< ShaderManager shader_manager)

Constructor for Camera.

Parameters
[in]shader_managerThe shader manager
Graphics::Camera::Camera ( const std::shared_ptr< ShaderManager shader_manager,
const float  viewport_width,
const float  viewport_height,
const float  near = 0.1,
const float  far = 1.0 
)

Constructor for Camera.

Parameters
[in]shader_managerThe shader manager
[in]viewport_widthThe viewport width
[in]viewport_heightThe viewport height
[in]nearThe near plane z value
[in]farThe far plane z value

Member Function Documentation

std::string Graphics::Camera::className ( ) const
overridevirtualnoexcept

Returns a string representing the class name.

Returns
The class name

Reimplemented from Component.

Referenced by generated::getCameraModule().

float Graphics::Camera::getFar ( ) const
noexcept

Gets the far z plane.

Returns
The far.

Referenced by generated::getCameraModule().

float Graphics::Camera::getFreeCameraSpeed ( ) const
noexcept

Gets the free camera speed when in free camera mode.

Returns
The free camera speed.

Referenced by generated::getCameraModule().

float Graphics::Camera::getHeight ( ) const
noexcept

Gets the height.

Returns
The height.

Referenced by generated::getCameraModule().

float Graphics::Camera::getNear ( ) const
noexcept

Gets the near z plane.

Returns
The near.

Referenced by generated::getCameraModule().

glm::mat4 Graphics::Camera::getProjectionMatrix ( ) const
noexcept

Gets the projection matrix.

Returns
The projection matrix.

Referenced by generated::getCameraModule(), and Engine::setup().

int Graphics::Camera::getScreenPaddingInTiles ( ) const
noexcept

Gets the screen padding in tiles.

Returns
The screen padding in tiles.

Referenced by generated::getCameraModule().

unsigned long long Graphics::Camera::getValueForSorting ( ) const
overridevirtualnoexcept

Gets the value for sorting.

Returns
The value for sorting.

Implements Component.

References Component::getId().

float Graphics::Camera::getWidth ( ) const
noexcept

Gets the width.

Returns
The width.

Referenced by generated::getCameraModule().

void Graphics::Camera::handleQueuedEvent ( std::shared_ptr< Events::Event event)
overridevirtual

HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.

Parameters
[in]eventThe event

Reimplemented from Component.

References Component::getTransform(), Component::handleQueuedEvent(), Events::KEY_DOWN, Events::KEY_REPEAT, Events::KEY_UP, and Events::SPRITE_MOVE.

Referenced by onNotifyNow().

bool Graphics::Camera::isComponentWithin ( const Component component) const

Determines if component within.

Parameters
[in]componentThe component
Returns
True if component within, False otherwise.

References Component::getTransform().

Referenced by generated::getCameraModule().

void Graphics::Camera::log ( el::base::type::ostream_t &  os) const
overridevirtual

Reimplemented from Component.

References Component::log().

void Graphics::Camera::onDestroy ( )
overridevirtual

Called when the engine is shutting down.

Implements Component.

void Graphics::Camera::onNotifyNow ( std::shared_ptr< Events::Event event)
overridevirtual

When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.

Parameters
[in]eventThe event

Reimplemented from Component.

References handleQueuedEvent().

void Graphics::Camera::onStart ( )
overridevirtual

Called when the engine starts and when a new scene is loaded.

Implements Component.

References Graphics::UI::ChangeTextEvent::create(), Transform::getAbsoluteTransformationMatrix(), Component::getTransform(), and Events::Subject::notify().

bool Graphics::Camera::onUpdate ( const double  delta)
overridevirtual

Called every engine loop.

Parameters
[in]deltaThe delta
Returns
true if active

Implements Component.

References Component::active, Graphics::UI::ChangeTextEvent::create(), Transform::getAbsoluteTransformationMatrix(), Component::getTransform(), and Events::Subject::notify().

void Graphics::Camera::setFar ( const float  far)
noexcept

Sets the far z plane.

Parameters
[in]farThe far

Referenced by generated::getCameraModule().

void Graphics::Camera::setFreeCameraSpeed ( const float  speed)
noexcept

Sets the free camera speed when in free camera mode.

Parameters
[in]speedThe speed

Referenced by generated::getCameraModule().

void Graphics::Camera::setHeight ( const float  height)
noexcept

Sets the height.

Parameters
[in]heightThe height

Referenced by generated::getCameraModule().

void Graphics::Camera::setNear ( const float  near)
noexcept

Sets the near z plane.

Parameters
[in]nearThe near

Referenced by generated::getCameraModule().

void Graphics::Camera::setScreenPaddingInTiles ( const int  padding)
noexcept

Sets the screen padding in tiles.

Parameters
[in]paddingThe padding

Referenced by generated::getCameraModule().

void Graphics::Camera::setWidth ( const float  width)
noexcept

Sets the width.

Parameters
[in]widthThe width

Referenced by generated::getCameraModule().


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