Nameless Engine
Loading...
Searching...
No Matches
ne::CameraNode Class Reference

#include <CameraNode.h>

Inheritance diagram for ne::CameraNode:
ne::SpatialNode ne::Node ne::Serializable ne::EditorCameraNode

Public Member Functions

 CameraNode (const std::string &sNodeName)
 
void makeActive ()
 
void setCameraMode (CameraMode mode)
 
void setOrbitalTargetLocation (const glm::vec3 &targetPointLocation)
 
void clearOrbitalTargetLocation ()
 
void setOrbitalRotation (float phi, float theta)
 
void setOrbitalDistanceToTarget (float distanceToTarget)
 
glm::vec3 getOrbitalTargetLocation ()
 
CameraPropertiesgetCameraProperties ()
 
- 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
 
Nodeoperator= (const Node &)=delete
 
 Node (Node &&)=delete
 
Nodeoperator= (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< ErrorserializeNodeTree (const std::filesystem::path &pathToFile, bool bEnableBackup)
 
std::string getNodeName () const
 
sgc::GcPtr< NodegetWorldRootNode ()
 
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< Errorserialize (std::filesystem::path pathToFile, bool bEnableBackup, const std::unordered_map< std::string, std::string > &customAttributes={})
 
std::variant< std::string, Errorserialize (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, Errorserialize (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 onWorldLocationRotationScaleChanged () override
 
virtual void onDespawning () 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)
 
TimercreateTimer (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

void updateCameraProperties ()
 

Private Attributes

CameraProperties cameraProperties
 
std::optional< glm::vec3 > orbitalCameraTargetInWorldSpace = {}
 
glm::vec3 localSpaceOriginInWorldSpace = glm::vec3(0.0F, 0.0F, 0.0F)
 
std::pair< std::recursive_mutex, bool > mtxIsActive
 

Static Private Attributes

static constexpr float rotationDelta = 0.0001F
 

Friends

class CameraManager
 

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 >, ErrordeserializeNodeTree (const std::filesystem::path &pathToFile)
 
static GameInstancegetGameInstance ()
 
- Static Public Member Functions inherited from ne::Serializable
static std::optional< ErrorserializeMultiple (std::filesystem::path pathToFile, std::vector< SerializableObjectInformation > vObjects, bool bEnableBackup)
 
static std::variant< std::set< std::string >, ErrorgetIdsFromFile (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, Errordeserialize (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, Errordeserialize (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, Errordeserialize (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, Errordeserialize (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 > >, ErrordeserializeMultiple (std::filesystem::path pathToFile, const std::set< std::string > &ids)
 
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, Errordeserialize (const toml::value &tomlData, std::unordered_map< std::string, std::string > &customAttributes, std::string sEntityId="", std::optional< std::filesystem::path > optionalPathToFile={})
 

Detailed Description

Represents a camera in 3D space.

Constructor & Destructor Documentation

◆ CameraNode()

ne::CameraNode::CameraNode ( const std::string &  sNodeName)

Creates a new node with the specified name.

Parameters
sNodeNameName of this node.

Member Function Documentation

◆ clearOrbitalTargetLocation()

void ne::CameraNode::clearOrbitalTargetLocation ( )

Resets target point specified in setOrbitalTargetLocation so that orbital camera will look at node's local space origin.

Remarks
Only works if the current camera mode is orbital (see setCameraMode), otherwise logs a warning.

◆ getCameraProperties()

CameraProperties * ne::CameraNode::getCameraProperties ( )

Returns camera properties.

Warning
Do not delete returned pointer.
Returns
Camera properties.

◆ getOrbitalTargetLocation()

glm::vec3 ne::CameraNode::getOrbitalTargetLocation ( )

Returns location in world space to where the orbital camera looks at (also see setOrbitalTargetLocation).

Remarks
Only works if the current camera mode is orbital (see setCameraMode), otherwise logs a warning.
Returns
Location in world space.

◆ makeActive()

void ne::CameraNode::makeActive ( )

Makes the camera of this node to be the primary camera and you will see what this camera sees on the game window.

Remarks
Only spawned camera nodes can be primary (active), otherwise an error will be shown.
Previously active camera (if there was one) will become inactive.

◆ onDespawning()

void ne::CameraNode::onDespawning ( )
overrideprotectedvirtual

Called before this node is despawned from the world to execute custom despawn logic.

Remarks
This node will be marked as despawned after this function is called.
This function is called after all child nodes were despawned.
Warning
If overriding you must call the parent's version of this function first (before executing your login) to execute parent's logic.

Reimplemented from ne::Node.

◆ onWorldLocationRotationScaleChanged()

void ne::CameraNode::onWorldLocationRotationScaleChanged ( )
overrideprotectedvirtual

Called after node's world location/rotation/scale was changed.

Warning
If overriding you must call the parent's version of this function first (before executing your login) to execute parent's logic.

Reimplemented from ne::SpatialNode.

◆ setCameraMode()

void ne::CameraNode::setCameraMode ( CameraMode  mode)

Sets how the camera can move and rotate.

Parameters
modeNew mode.

◆ setOrbitalDistanceToTarget()

void ne::CameraNode::setOrbitalDistanceToTarget ( float  distanceToTarget)

Sets orbital camera's radial distance or distance from camera to camera's target point (see setOrbitalTargetLocation).

Remarks
Only works if the current camera mode is orbital (see setCameraMode), otherwise logs a warning.
Parameters
distanceToTargetRadial distance or distance from camera to camera's target point.

◆ setOrbitalRotation()

void ne::CameraNode::setOrbitalRotation ( float  phi,
float  theta 
)

Sets orbital camera's rotation by specifying tilt and rotation around camera's target point (see setOrbitalTargetLocation).

Remarks
Only works if the current camera mode is orbital (see setCameraMode), otherwise logs a warning.
Parameters
phiAzimuthal angle (in degrees).
thetaPolar angle (in degrees).

◆ setOrbitalTargetLocation()

void ne::CameraNode::setOrbitalTargetLocation ( const glm::vec3 &  targetPointLocation)

Sets a location in world space that orbital camera should look at (when not set, orbital camera looks at the node's local space origin, see clearOrbitalTargetLocation).

Remarks
Only works if the current camera mode is orbital (see setCameraMode), otherwise logs a warning.
Parameters
targetPointLocationLocation in world space to look at.

◆ updateCameraProperties()

void ne::CameraNode::updateCameraProperties ( )
private

Applies current location/rotation to camera properties based on the current camera mode.

Member Data Documentation

◆ cameraProperties

CameraProperties ne::CameraNode::cameraProperties
private

Camera properties.

◆ localSpaceOriginInWorldSpace

glm::vec3 ne::CameraNode::localSpaceOriginInWorldSpace = glm::vec3(0.0F, 0.0F, 0.0F)
private

(0.0F, 0.0F, 0.0F) in local space converted to world space.

◆ mtxIsActive

std::pair<std::recursive_mutex, bool> ne::CameraNode::mtxIsActive
private

Whether this camera is used by the camera manager or not.

Warning
Only camera manager can change this value.

◆ orbitalCameraTargetInWorldSpace

std::optional<glm::vec3> ne::CameraNode::orbitalCameraTargetInWorldSpace = {}
private

If not empty used instead of localSpaceOriginInWorldSpace.

◆ rotationDelta

constexpr float ne::CameraNode::rotationDelta = 0.0001F
inlinestaticconstexprprivate

Delta to compare rotations.


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