OpenGL-utility/include/lighting/point.hpp

90 lines
2.3 KiB
C++
Raw Normal View History

2021-01-29 16:28:48 +00:00
/*****************************************************************//**
* @file point.hpp
* @brief Anything related to point light sources
*
* @author Lauchmelder
* @date January 2021
*********************************************************************/
2021-01-26 15:03:41 +00:00
#ifndef POINT_HPP
#define POINT_HPP
#include <core.hpp>
#include <color.hpp>
#include <glm/glm.hpp>
namespace oglu
{
class Transformable;
2021-01-29 16:28:48 +00:00
/**
* @brief A class containing things related to point lighting.
*/
2021-01-26 15:03:41 +00:00
class OGLU_API PointLight
{
public:
2021-01-29 16:28:48 +00:00
/**
* @brief Create a default point light.
*
* By default the diffusion and specular components are white and
* the light is positioned at the world origin
*/
2021-01-26 15:03:41 +00:00
PointLight();
2021-01-29 16:28:48 +00:00
/**
* @brief Create a new point light.
*
* @param position Position of the light
* @param diffusionColor Color of the diffusion component
* @param specularColor Color of the specular component
*/
2021-01-28 00:07:19 +00:00
PointLight(const glm::vec3& position, const Color& diffusionColor = Color::White, const Color& specularColor = Color::White);
2021-01-29 16:28:48 +00:00
/**
* @brief Copy from another point light.
*
* @param other The point light to copy from
*/
2021-01-26 15:03:41 +00:00
PointLight(const PointLight& other);
~PointLight();
2021-01-29 16:28:48 +00:00
/**
* @brief Link the lights position to a Transformable.
*
* It is possible to link the positions of a Transformable and
* a PointLight. This means that these two objects will always
* have the same position, until they are unlinked. Deleting a
* Transformable before unlinking any linked PointLight causes
* undefined behaviour.
*
* @param link The Transformable to link to
*/
2021-01-26 15:03:41 +00:00
void LinkPositionToTransformable(Transformable& link);
2021-01-29 16:28:48 +00:00
/**
* @brief Unlink a Transformable.
*
* This breaks the link between the two objects.
*/
2021-01-26 15:03:41 +00:00
void UnlinkPositionFromTransformable();
2021-01-29 16:28:48 +00:00
/**
* Get the lights position.
*
* @returns A pointer to the lights position
*/
2021-01-26 15:03:41 +00:00
float* GetPositionPointer();
public:
2021-01-29 16:28:48 +00:00
// TODO: Does this split make sense? I'll keep it for now
Color diffusionColor; ///< Diffusion color of the light
Color specularColor; ///< Specular color of the light
2021-01-26 15:03:41 +00:00
2021-01-27 21:42:47 +00:00
2021-01-26 15:03:41 +00:00
private:
2021-01-29 16:28:48 +00:00
glm::vec3* position; ///< Position of the light
bool isLinked; ///< Wether the position is linked to an object or not
2021-01-26 15:03:41 +00:00
};
}
#endif