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

Class for light. More...

#include <light.h>

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

Public Types

enum  Type : unsigned int { POINT, SPOT }
 Light type enum. More...
 

Public Member Functions

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...
 
 Light (const Light::Type &type=Type::POINT)
 Light constructor. More...
 
 ~Light ()
 Destroys the object. More...
 
void setColor (const glm::vec3 color) noexcept
 Sets the color. More...
 
glm::vec3 getColor () const noexcept
 Gets the color. More...
 
void setIntensity (const float intensity) noexcept
 Sets the intensity. More...
 
float getIntensity () const noexcept
 Gets the intensity. More...
 
void setLinearAttenuation (const float linear) noexcept
 Sets the linear attenuation. More...
 
float getLinearAttenuation () const noexcept
 Gets the linear attenuation. More...
 
void setQuadraticAttenuation (const float quadratic) noexcept
 Sets the quadratic attenuation. More...
 
float getQuadraticAttenuation () const noexcept
 Gets the quadratic attenuation. More...
 
bool castsQuantizedBands () const noexcept
 Function to see if lights cast quantized bands or are smooth. More...
 
void setNumberOfQuantizedBands (const int bands) noexcept
 Sets the number of quantized bands. More...
 
int getNumberOfQuantizedBands () const noexcept
 Gets the number of quantized bands. More...
 
void setConeAngle (const float angle) noexcept
 Sets the cone angle. More...
 
float getConeAngle () const noexcept
 Gets the cone angle. More...
 
void setConeDirection (const glm::vec3 direction) noexcept
 Sets the cone direction. More...
 
glm::vec3 getConeDirection () const noexcept
 Gets the cone direction. More...
 
Light::Type getType () const noexcept
 Gets the type. More...
 
float influenceOnComponent (const Component &component) const
 Calculates a light's influence on a given component. 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 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 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 ~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...
 

Static Public Member Functions

static const Light::Type stringToType (const std::string &str)
 
static const std::string typeToString (const Light::Type &type)
 

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

Member Enumeration Documentation

enum Graphics::Light::Type : unsigned int

Light type enum.

Enumerator
POINT 
SPOT 

Constructor & Destructor Documentation

Graphics::Light::Light ( const Light::Type type = Type::POINT)

Light constructor.

Parameters
[in]typeThe type
Graphics::Light::~Light ( )

Destroys the object.

Member Function Documentation

bool Graphics::Light::castsQuantizedBands ( ) const
noexcept

Function to see if lights cast quantized bands or are smooth.

Returns
True if lights cast quantized bands

Referenced by generated::getLightModule().

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

Returns a string representing the class name.

Returns
The class name

Reimplemented from Component.

Referenced by generated::getLightModule().

glm::vec3 Graphics::Light::getColor ( ) const
noexcept

Gets the color.

Returns
The color.

Referenced by generated::getLightModule().

float Graphics::Light::getConeAngle ( ) const
noexcept

Gets the cone angle.

Returns
The cone angle.

Referenced by generated::getLightModule().

glm::vec3 Graphics::Light::getConeDirection ( ) const
noexcept

Gets the cone direction.

Returns
The cone direction.

Referenced by generated::getLightModule().

float Graphics::Light::getIntensity ( ) const
noexcept

Gets the intensity.

Returns
The intensity.

Referenced by generated::getLightModule().

float Graphics::Light::getLinearAttenuation ( ) const
noexcept

Gets the linear attenuation.

Returns
The linear attenuation.

Referenced by generated::getLightModule().

int Graphics::Light::getNumberOfQuantizedBands ( ) const
noexcept

Gets the number of quantized bands.

Returns
The number of quantized bands.

Referenced by generated::getLightModule().

float Graphics::Light::getQuadraticAttenuation ( ) const
noexcept

Gets the quadratic attenuation.

Returns
The quadratic attenuation.

Referenced by generated::getLightModule().

Light::Type Graphics::Light::getType ( ) const
noexcept

Gets the type.

Returns
The type.

Referenced by generated::getLightModule().

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

Gets the value for sorting.

Returns
The value for sorting.

Implements Component.

References Component::getId().

float Graphics::Light::influenceOnComponent ( const Component component) const

Calculates a light's influence on a given component.

Parameters
[in]componentThe component
Returns
Influence amount clamped 0.0, 1.0, on the given component

References Component::getTransform().

Referenced by generated::getLightModule().

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

Reimplemented from Component.

References Component::getTransform(), and typeToString().

void Graphics::Light::onDestroy ( )
overridevirtual

Called when the engine is shutting down.

Implements Component.

void Graphics::Light::onStart ( )
overridevirtual

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

Implements Component.

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

Called every engine loop.

Parameters
[in]deltaThe delta
Returns
true if active

Implements Component.

void Graphics::Light::setColor ( const glm::vec3  color)
noexcept

Sets the color.

Parameters
[in]colorThe color

Referenced by generated::getLightModule().

void Graphics::Light::setConeAngle ( const float  angle)
noexcept

Sets the cone angle.

Parameters
[in]angleThe angle

Referenced by generated::getLightModule().

void Graphics::Light::setConeDirection ( const glm::vec3  direction)
noexcept

Sets the cone direction.

Parameters
[in]directionThe direction

Referenced by generated::getLightModule().

void Graphics::Light::setIntensity ( const float  intensity)
noexcept

Sets the intensity.

Parameters
[in]intensityThe intensity

Referenced by generated::getLightModule().

void Graphics::Light::setLinearAttenuation ( const float  linear)
noexcept

Sets the linear attenuation.

Parameters
[in]linearThe linear

Referenced by generated::getLightModule().

void Graphics::Light::setNumberOfQuantizedBands ( const int  bands)
noexcept

Sets the number of quantized bands.

Parameters
[in]bandsThe bands

Referenced by generated::getLightModule().

void Graphics::Light::setQuadraticAttenuation ( const float  quadratic)
noexcept

Sets the quadratic attenuation.

Parameters
[in]quadraticThe quadratic

Referenced by generated::getLightModule().

static const Light::Type Graphics::Light::stringToType ( const std::string &  str)
inlinestatic
static const std::string Graphics::Light::typeToString ( const Light::Type type)
inlinestatic

Referenced by log().


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