VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
visutwin::canvas::GraphNode Class Reference

Hierarchical scene graph node with local/world transforms and parent-child relationships. More...

#include <scene/graphNode.h>

Inheritance diagram for visutwin::canvas::GraphNode:
[legend]

Public Member Functions

int aabbVer () const
void addChild (GraphNode *node)
const std::vector< GraphNode * > & children () const
bool enabled () const
bool enabledLocal () const
std::vector< GraphNode * > find (const std::function< bool(GraphNode *)> &predicate)
 Find all descendants (and self) matching a predicate.
GraphNodefindByName (const std::string &name)
 GraphNode (const std::string &name="Untitled")
bool isDescendantOf (const GraphNode *node) const
const Vector3localPosition () const
const QuaternionlocalRotation () const
const Vector3localScale () const
const std::string & name () const
GraphNodeparent () const
const Vector3 position ()
void remove ()
void removeChild (GraphNode *child)
void rotateLocal (float x, float y, float z)
Quaternion rotation ()
void setEnabled (bool value)
void setEnabledInHierarchy (bool value)
void setLocalEulerAngles (float x, float y, float z)
void setLocalPosition (const Vector3 &position)
void setLocalPosition (float x, float y, float z)
void setLocalRotation (const Quaternion &rotation)
void setLocalScale (const Vector3 &scale)
void setLocalScale (float x, float y, float z)
void setName (const std::string &name)
void setPosition (const Vector3 &position)
void setPosition (float x, float y, float z)
void setRotation (const Quaternion &rotation)
void translateLocal (float x, float y, float z)
float worldScaleSign ()
const Matrix4worldTransform ()
virtual ~GraphNode ()
Public Member Functions inherited from visutwin::canvas::EventHandler
template<typename... Args>
EventHandlerfire (const std::string &name, Args &&... args)
bool hasEvent (const std::string &name) const
void initEventHandler ()
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleroff (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleroff (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr)
EventHandleroffByHandle (EventHandle *handle)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleon (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleon (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleonce (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleonce (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
virtual ~EventHandler ()=default

Protected Member Functions

void notifyHierarchyStateChanged (GraphNode *node, bool enabled)
virtual void onHierarchyStateChanged (bool enabled)
Protected Member Functions inherited from visutwin::canvas::EventHandler
EventHandleaddCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false)

Detailed Description

Hierarchical scene graph node with local/world transforms and parent-child relationships.

GraphNode is the base class for all objects in the scene hierarchy. Each node maintains a local position, rotation, and scale that are composed with its parent's world transform to produce a world transformation matrix. The engine synchronizes the entire hierarchy each frame. Entity extends GraphNode to add component hosting.

Definition at line 27 of file graphNode.h.

Constructor & Destructor Documentation

◆ GraphNode()

visutwin::canvas::GraphNode::GraphNode ( const std::string & name = "Untitled")
inlineexplicit

Definition at line 30 of file graphNode.h.

References name().

Referenced by addChild(), find(), findByName(), isDescendantOf(), notifyHierarchyStateChanged(), parent(), and removeChild().

◆ ~GraphNode()

visutwin::canvas::GraphNode::~GraphNode ( )
virtual

Definition at line 12 of file graphNode.cpp.

Member Function Documentation

◆ aabbVer()

int visutwin::canvas::GraphNode::aabbVer ( ) const
inline

Definition at line 117 of file graphNode.h.

◆ addChild()

void visutwin::canvas::GraphNode::addChild ( GraphNode * node)

Definition at line 203 of file graphNode.cpp.

References GraphNode().

◆ children()

const std::vector< GraphNode * > & visutwin::canvas::GraphNode::children ( ) const
inline

Definition at line 79 of file graphNode.h.

Referenced by visutwin::canvas::Entity::clone().

◆ enabled()

◆ enabledLocal()

bool visutwin::canvas::GraphNode::enabledLocal ( ) const
inline

Returns the local enabled flag (without hierarchy consideration). (used by _cloneInternal).

Definition at line 103 of file graphNode.h.

Referenced by visutwin::canvas::Entity::clone().

◆ find()

std::vector< GraphNode * > visutwin::canvas::GraphNode::find ( const std::function< bool(GraphNode *)> & predicate)

Find all descendants (and self) matching a predicate.

Definition at line 396 of file graphNode.cpp.

References GraphNode().

Referenced by visutwin::canvas::AnimationComponent::getAnimation(), visutwin::canvas::DefaultAnimBinder::resolve(), and visutwin::canvas::AnimEvaluator::update().

◆ findByName()

GraphNode * visutwin::canvas::GraphNode::findByName ( const std::string & name)

Definition at line 377 of file graphNode.cpp.

References GraphNode(), and name().

Referenced by visutwin::canvas::DefaultAnimBinder::resolve().

◆ isDescendantOf()

bool visutwin::canvas::GraphNode::isDescendantOf ( const GraphNode * node) const

Definition at line 210 of file graphNode.cpp.

References GraphNode(), and parent().

◆ localPosition()

const Vector3 & visutwin::canvas::GraphNode::localPosition ( ) const
inline

Definition at line 44 of file graphNode.h.

Referenced by visutwin::canvas::Entity::clone().

◆ localRotation()

const Quaternion & visutwin::canvas::GraphNode::localRotation ( ) const
inline

Definition at line 45 of file graphNode.h.

Referenced by visutwin::canvas::Entity::clone().

◆ localScale()

const Vector3 & visutwin::canvas::GraphNode::localScale ( ) const
inline

Definition at line 46 of file graphNode.h.

Referenced by visutwin::canvas::Entity::clone().

◆ name()

const std::string & visutwin::canvas::GraphNode::name ( ) const
inline

Definition at line 35 of file graphNode.h.

Referenced by visutwin::canvas::Entity::clone(), findByName(), GraphNode(), and setName().

◆ notifyHierarchyStateChanged()

void visutwin::canvas::GraphNode::notifyHierarchyStateChanged ( GraphNode * node,
bool enabled )
protected

◆ onHierarchyStateChanged()

void visutwin::canvas::GraphNode::onHierarchyStateChanged ( bool enabled)
protectedvirtual

◆ parent()

GraphNode * visutwin::canvas::GraphNode::parent ( ) const
inline

Definition at line 88 of file graphNode.h.

References GraphNode().

Referenced by visutwin::canvas::Entity::findEngine(), and isDescendantOf().

◆ position()

const Vector3 visutwin::canvas::GraphNode::position ( )

Get the world space position for the specified GraphNode. The position is returned as a Vector3. The value returned by this function should be considered read-only. To set the world space position of the graph node, use setPosition.

Definition at line 352 of file graphNode.cpp.

References visutwin::canvas::Matrix4::getTranslation(), and worldTransform().

Referenced by visutwin::canvas::ShadowRendererLocal::cullLocalLights(), setLocalPosition(), setPosition(), and visutwin::canvas::ElementInput::syncTextElements().

◆ remove()

void visutwin::canvas::GraphNode::remove ( )

Remove graph node from current parent

Definition at line 222 of file graphNode.cpp.

◆ removeChild()

void visutwin::canvas::GraphNode::removeChild ( GraphNode * child)

Definition at line 229 of file graphNode.cpp.

References visutwin::canvas::EventHandler::fire(), and GraphNode().

◆ rotateLocal()

void visutwin::canvas::GraphNode::rotateLocal ( float x,
float y,
float z )

Rotates the graph node in local space by the specified Euler angles. Eulers are specified in degrees in XYZ order.

Definition at line 193 of file graphNode.cpp.

References visutwin::canvas::Quaternion::fromEulerAngles(), and rotation().

◆ rotation()

◆ setEnabled()

void visutwin::canvas::GraphNode::setEnabled ( bool value)

Set the enabled flag and propagate hierarchy state to children. Mirrors upstream set enabled(value).

Definition at line 293 of file graphNode.cpp.

References notifyHierarchyStateChanged().

◆ setEnabledInHierarchy()

void visutwin::canvas::GraphNode::setEnabledInHierarchy ( bool value)
inline

Directly set the _enabledInHierarchy flag. Used for root nodes that have no parent. Mirrors upstream root._enabledInHierarchy = true.

Definition at line 115 of file graphNode.h.

◆ setLocalEulerAngles()

void visutwin::canvas::GraphNode::setLocalEulerAngles ( float x,
float y,
float z )

Definition at line 172 of file graphNode.cpp.

References visutwin::canvas::Quaternion::fromEulerAngles().

◆ setLocalPosition() [1/2]

void visutwin::canvas::GraphNode::setLocalPosition ( const Vector3 & position)

Definition at line 333 of file graphNode.cpp.

References position(), and setLocalPosition().

◆ setLocalPosition() [2/2]

void visutwin::canvas::GraphNode::setLocalPosition ( float x,
float y,
float z )

◆ setLocalRotation()

void visutwin::canvas::GraphNode::setLocalRotation ( const Quaternion & rotation)

◆ setLocalScale() [1/2]

void visutwin::canvas::GraphNode::setLocalScale ( const Vector3 & scale)

Definition at line 343 of file graphNode.cpp.

◆ setLocalScale() [2/2]

void visutwin::canvas::GraphNode::setLocalScale ( float x,
float y,
float z )

◆ setName()

void visutwin::canvas::GraphNode::setName ( const std::string & name)
inline

Definition at line 36 of file graphNode.h.

References name().

◆ setPosition() [1/2]

void visutwin::canvas::GraphNode::setPosition ( const Vector3 & position)

◆ setPosition() [2/2]

void visutwin::canvas::GraphNode::setPosition ( float x,
float y,
float z )

Definition at line 358 of file graphNode.cpp.

References setPosition().

Referenced by setPosition().

◆ setRotation()

void visutwin::canvas::GraphNode::setRotation ( const Quaternion & rotation)

Definition at line 65 of file graphNode.cpp.

References rotation().

◆ translateLocal()

void visutwin::canvas::GraphNode::translateLocal ( float x,
float y,
float z )

Translates the graph node in local space by the specified amounts.

Definition at line 181 of file graphNode.cpp.

◆ worldScaleSign()

float visutwin::canvas::GraphNode::worldScaleSign ( )

Definition at line 99 of file graphNode.cpp.

References worldTransform().

◆ worldTransform()

const Matrix4 & visutwin::canvas::GraphNode::worldTransform ( )

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