Nameless Engine
|
#include <PointLightNode.h>
Classes | |
struct | PointLightShaderData |
struct | ShaderData |
Public Member Functions | |
PointLightNode (const std::string &sNodeName) | |
void | setLightColor (const glm::vec3 &color) |
void | setLightIntensity (float intensity) |
void | setLightDistance (float distance) |
glm::vec3 | getLightColor () const |
float | getLightIntensity () const |
float | getLightDistance () const |
std::pair< std::mutex, Sphere > * | getShape () |
Public Member Functions inherited from ne::SpatialNode | |
SpatialNode (const std::string &sNodeName) | |
void | setRelativeLocation (const glm::vec3 &location) |
void | setRelativeRotation (const glm::vec3 &rotation) |
void | setRelativeScale (const glm::vec3 &scale) |
void | setWorldLocation (const glm::vec3 &location) |
void | setWorldRotation (const glm::vec3 &rotation) |
void | setWorldScale (const glm::vec3 &scale) |
glm::vec3 | getRelativeLocation () const |
glm::vec3 | getRelativeRotation () const |
glm::vec3 | getRelativeScale () const |
glm::mat4x4 | getRelativeRotationMatrix () |
glm::vec3 | getWorldLocation () |
glm::vec3 | getWorldRotation () |
glm::quat | getWorldRotationQuaternion () |
glm::vec3 | getWorldScale () |
glm::vec3 | getWorldForwardDirection () |
glm::vec3 | getWorldRightDirection () |
glm::vec3 | getWorldUpDirection () |
glm::mat4x4 | getWorldMatrix () |
std::pair< std::recursive_mutex, sgc::GcPtr< SpatialNode > > * | getClosestSpatialParent () |
Public Member Functions inherited from ne::Node | |
Node () | |
Node (const std::string &sName) | |
Node (const Node &)=delete | |
Node & | operator= (const Node &)=delete |
Node (Node &&)=delete | |
Node & | operator= (Node &&)=delete |
virtual | ~Node () override |
void | setNodeName (const std::string &sName) |
void | detachFromParentAndDespawn () |
void | addChildNode (const sgc::GcPtr< Node > &pNode, AttachmentRule locationRule=AttachmentRule::KEEP_WORLD, AttachmentRule rotationRule=AttachmentRule::KEEP_WORLD, AttachmentRule scaleRule=AttachmentRule::KEEP_WORLD) |
void | setSerialize (bool bSerialize) |
std::optional< Error > | serializeNodeTree (const std::filesystem::path &pathToFile, bool bEnableBackup) |
std::string | getNodeName () const |
sgc::GcPtr< Node > | getWorldRootNode () |
std::pair< std::recursive_mutex, sgc::GcPtr< Node > > * | getParentNode () |
std::pair< std::recursive_mutex, sgc::GcVector< sgc::GcPtr< Node > > > * | getChildNodes () |
template<typename NodeType > requires std::derived_from<NodeType, Node> | |
sgc::GcPtr< NodeType > | getParentNodeOfType (const std::string &sParentNodeName="") |
template<typename NodeType > requires std::derived_from<NodeType, Node> | |
sgc::GcPtr< NodeType > | getChildNodeOfType (const std::string &sChildNodeName="") |
TickGroup | getTickGroup () const |
std::optional< size_t > | getNodeId () const |
bool | isCalledEveryFrame () |
bool | isReceivingInput () |
bool | isSpawned () |
bool | isParentOf (Node *pNode) |
bool | isChildOf (Node *pNode) |
bool | isSerialized () const |
Public Member Functions inherited from ne::Serializable | |
std::optional< Error > | serialize (std::filesystem::path pathToFile, bool bEnableBackup, const std::unordered_map< std::string, std::string > &customAttributes={}) |
std::variant< std::string, Error > | serialize (toml::value &tomlData, const std::string &sEntityId="", const std::unordered_map< std::string, std::string > &customAttributes={}, const std::optional< std::filesystem::path > &optionalPathToFile={}, bool bEnableBackup=false) |
std::variant< std::string, Error > | serialize (toml::value &tomlData, Serializable *pOriginalObject, std::string sEntityId="", const std::unordered_map< std::string, std::string > &customAttributes={}, const std::optional< std::filesystem::path > &optionalPathToFile={}, bool bEnableBackup=false) |
std::optional< std::pair< std::string, std::string > > | getPathDeserializedFromRelativeToRes () const |
Protected Member Functions | |
virtual void | onAfterDeserialized () override |
virtual void | onSpawning () override |
virtual void | onDespawning () override |
virtual void | onWorldLocationRotationScaleChanged () override |
Protected Member Functions inherited from ne::SpatialNode | |
virtual void | onAfterDeserialized () override |
virtual void | onSpawning () override |
virtual void | onAfterAttachedToNewParent (bool bThisNodeBeingAttached) override |
virtual void | onWorldLocationRotationScaleChanged () |
Protected Member Functions inherited from ne::Node | |
void | setIsCalledEveryFrame (bool bEnable) |
void | setTickGroup (TickGroup tickGroup) |
void | setIsReceivingInput (bool bEnable) |
Timer * | createTimer (const std::string &sTimerName) |
template<typename FunctionType > | |
NodeNotificationBroadcaster< FunctionType > * | createNotificationBroadcaster () |
std::pair< std::recursive_mutex, std::unordered_map< unsigned int, std::function< void(KeyboardModifiers, bool)> > > * | getActionEventBindings () |
std::pair< std::recursive_mutex, std::unordered_map< unsigned int, std::function< void(KeyboardModifiers, float)> > > * | getAxisEventBindings () |
std::recursive_mutex * | getSpawnDespawnMutex () |
virtual void | onMouseMove (double xOffset, double yOffset) |
virtual void | onMouseScrollMove (int iOffset) |
virtual void | onBeforeNewFrame (float timeSincePrevFrameInSec) |
virtual void | onSpawning () |
virtual void | onChildNodesSpawned () |
virtual void | onDespawning () |
virtual void | onBeforeDetachedFromParent (bool bThisNodeBeingDetached) |
virtual void | onAfterAttachedToNewParent (bool bThisNodeBeingAttached) |
virtual void | onAfterDeserialized () |
Private Member Functions | |
ShadowMapHandle * | getShadowMapHandle () const |
unsigned int | getIndexIntoShadowPassInfoShaderArray (size_t iCubemapFaceIndex=0) |
void * | onStartedUpdatingShaderData () |
void | onFinishedUpdatingShaderData () |
void * | onStartedUpdatingShadowPassData (size_t iCubemapFaceIndex) |
void | onFinishedUpdatingShadowPassData () |
void | markShaderDataToBeCopiedToGpu () |
void | markShadowPassDataToBeCopiedToGpu () |
void | onShadowMapArrayIndexChanged (unsigned int iNewIndexIntoArray) |
void | recalculateShadowPassShaderData () |
void | recalculateShape () |
Private Attributes | |
std::pair< std::recursive_mutex, ShaderData > | mtxShaderData |
std::pair< std::mutex, Sphere > | mtxShape |
std::unique_ptr< ShadowMapHandle > | pShadowMapHandle |
glm::vec3 | color = glm::vec3(1.0F, 1.0F, 1.0F) |
float | intensity = 1.0F |
float | distance = 10.0F |
Friends | |
class | Renderer |
Additional Inherited Members | |
Public Types inherited from ne::Node | |
enum class | AttachmentRule { RESET_RELATIVE , KEEP_RELATIVE , KEEP_WORLD } |
Static Public Member Functions inherited from ne::Node | |
static size_t | getAliveNodeCount () |
static std::variant< sgc::GcPtr< Node >, Error > | deserializeNodeTree (const std::filesystem::path &pathToFile) |
static GameInstance * | getGameInstance () |
Static Public Member Functions inherited from ne::Serializable | |
static std::variant< std::pair< std::set< std::string >, toml::value >, Error > | getIdsFromFile (std::filesystem::path pathToFile) |
static std::optional< Error > | serializeMultiple (std::filesystem::path pathToFile, std::vector< SerializableObjectInformation > vObjects, bool bEnableBackup) |
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type> requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>) | |
static std::variant< SmartPointer, Error > | deserialize (const std::filesystem::path &pathToFile) |
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type> requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>) | |
static std::variant< SmartPointer, Error > | deserialize (const std::filesystem::path &pathToFile, std::unordered_map< std::string, std::string > &customAttributes) |
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type> requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>) | |
static std::variant< SmartPointer, Error > | deserialize (std::filesystem::path pathToFile, std::unordered_map< std::string, std::string > &customAttributes, const std::string &sEntityId) |
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type> requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>) | |
static std::variant< SmartPointer, Error > | deserialize (const std::filesystem::path &pathToFile, const std::string &sEntityId) |
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type> requires std::same_as<SmartPointer, sgc::GcPtr<Serializable>> || std::same_as<SmartPointer, std::unique_ptr<Serializable>> | |
static std::variant< std::vector< DeserializedObjectInformation< SmartPointer > >, Error > | deserializeMultiple (std::filesystem::path pathToFile) |
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type> requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>) | |
static std::variant< SmartPointer, Error > | deserialize (const toml::value &tomlData, std::unordered_map< std::string, std::string > &customAttributes, std::string sEntityId="", const std::optional< std::filesystem::path > &optionalPathToFile={}) |
Represents a point light source in world.
ne::PointLightNode::PointLightNode | ( | const std::string & | sNodeName | ) |
Creates a new node with the specified name.
sNodeName | Name of this node. |
|
private |
Used by renderer and returns the current index (because it may change later) into the shader array that stores shadow pass info of spawned lights.
iCubemapFaceIndex | Index of the cubemap face to get info for. |
glm::vec3 ne::PointLightNode::getLightColor | ( | ) | const |
Returns color of this light source.
float ne::PointLightNode::getLightDistance | ( | ) | const |
Returns lit distance.
float ne::PointLightNode::getLightIntensity | ( | ) | const |
Returns intensity of this light source.
|
private |
Used by renderer and returns handle to shadow map texture that this light source uses.
nullptr
if node is not spawned, otherwise valid pointer. std::pair< std::mutex, Sphere > * ne::PointLightNode::getShape | ( | ) |
Returns shape of this light source in world space.
|
private |
Marks array slot at mtxShaderData as "needs update" (if the slot is created) to later be copied to the GPU resource.
nullptr
.
|
private |
Marks array slots at mtxShaderData for shadow pass data as "needs update" (if the slots were created) to later be copied to the GPU resource.
nullptr
.
|
overrideprotectedvirtual |
Called after the object was successfully deserialized. Used to execute post-deserialization logic.
Reimplemented from ne::SpatialNode.
|
overrideprotectedvirtual |
Called before this node is despawned from the world to execute custom despawn logic.
Reimplemented from ne::Node.
|
private |
Called after onStartedUpdatingShaderData to notify this node that the renderer has finished copying the data to the GPU resource.
|
private |
Called after onStartedUpdatingShadowPassData to notify this node that the renderer has finished copying the data to the GPU resource.
|
private |
Called after the index into a descriptor array of pShadowMapHandle was initialized/changed.
iNewIndexIntoArray | New index to use. |
|
overrideprotectedvirtual |
Called when this node was not spawned previously and it was either attached to a parent node that is spawned or set as world's root node to execute custom spawn logic.
Reimplemented from ne::SpatialNode.
|
private |
Callback that will be called by the renderer when it's ready to copy new (updated) mtxShaderData to the GPU resource.
|
private |
Callback that will be called by the renderer when it's ready to copy new (updated) shadow pass data of the light source to the GPU resource.
iCubemapFaceIndex | Index of the cubemap face to copy the data. |
|
overrideprotectedvirtual |
Called after node's world location/rotation/scale was changed.
Reimplemented from ne::SpatialNode.
|
private |
(Re)calculates data used in shadow pass.
|
private |
Recalculates mtxShaderData according to the current parameters (state).
void ne::PointLightNode::setLightColor | ( | const glm::vec3 & | color | ) |
Sets light's color.
color | Color in RGB format in range [0.0; 1.0]. |
void ne::PointLightNode::setLightDistance | ( | float | distance | ) |
Sets lit distance (i.e. attenuation radius).
distance | Lit distance. |
void ne::PointLightNode::setLightIntensity | ( | float | intensity | ) |
Sets light's intensity.
intensity | Intensity in range [0.0; 1.0] (will be clamped if outside of the range). |
|
private |
Color of the light source.
|
private |
Lit distance.
|
private |
Light intensity, valid values range is [0.0F; 1.0F].
|
private |
Only valid while spawned. Up to date data that will be copied to the GPU.
|
private |
Stores up-to-date sphere shape (in world space) that represents the point light.
|
private |
References shadow map of the light source.