|
VisuTwin Canvas
C++ 3D Engine — Metal Backend
|
Hierarchical scene graph node with local/world transforms and parent-child relationships. More...
#include <scene/graphNode.h>
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. | |
| GraphNode * | findByName (const std::string &name) |
| GraphNode (const std::string &name="Untitled") | |
| bool | isDescendantOf (const GraphNode *node) const |
| const Vector3 & | localPosition () const |
| const Quaternion & | localRotation () const |
| const Vector3 & | localScale () const |
| const std::string & | name () const |
| GraphNode * | parent () 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 Matrix4 & | worldTransform () |
| virtual | ~GraphNode () |
| Public Member Functions inherited from visutwin::canvas::EventHandler | |
| template<typename... Args> | |
| EventHandler * | fire (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>) | |
| EventHandler * | off (const std::string &name, Callback &&callback, void *scope=nullptr) |
| EventHandler * | off (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr) |
| EventHandler * | offByHandle (EventHandle *handle) |
| template<typename Callback> requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>) | |
| EventHandle * | on (const std::string &name, Callback &&callback, void *scope=nullptr) |
| EventHandle * | on (const std::string &name, HandleEventCallback callback, void *scope=nullptr) |
| template<typename Callback> requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>) | |
| EventHandle * | once (const std::string &name, Callback &&callback, void *scope=nullptr) |
| EventHandle * | once (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 | |
| EventHandle * | addCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false) |
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.
|
inlineexplicit |
Definition at line 30 of file graphNode.h.
References name().
Referenced by addChild(), find(), findByName(), isDescendantOf(), notifyHierarchyStateChanged(), parent(), and removeChild().
|
virtual |
Definition at line 12 of file graphNode.cpp.
|
inline |
Definition at line 117 of file graphNode.h.
| void visutwin::canvas::GraphNode::addChild | ( | GraphNode * | node | ) |
Definition at line 203 of file graphNode.cpp.
References GraphNode().
|
inline |
Definition at line 79 of file graphNode.h.
Referenced by visutwin::canvas::Entity::clone().
|
inline |
Definition at line 97 of file graphNode.h.
Referenced by notifyHierarchyStateChanged(), visutwin::canvas::Entity::onHierarchyStateChanged(), onHierarchyStateChanged(), visutwin::canvas::ElementInput::renderElements(), visutwin::canvas::shouldRenderShadowMeshInstance(), visutwin::canvas::shouldRenderShadowRenderComponent(), and visutwin::canvas::ElementInput::syncTextElements().
|
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().
| 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().
| 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().
| bool visutwin::canvas::GraphNode::isDescendantOf | ( | const GraphNode * | node | ) | const |
Definition at line 210 of file graphNode.cpp.
References GraphNode(), and parent().
|
inline |
Definition at line 44 of file graphNode.h.
Referenced by visutwin::canvas::Entity::clone().
|
inline |
Definition at line 45 of file graphNode.h.
Referenced by visutwin::canvas::Entity::clone().
|
inline |
Definition at line 46 of file graphNode.h.
Referenced by visutwin::canvas::Entity::clone().
|
inline |
Definition at line 35 of file graphNode.h.
Referenced by visutwin::canvas::Entity::clone(), findByName(), GraphNode(), and setName().
|
protected |
Definition at line 282 of file graphNode.cpp.
References enabled(), GraphNode(), notifyHierarchyStateChanged(), and onHierarchyStateChanged().
Referenced by notifyHierarchyStateChanged(), and setEnabled().
|
protectedvirtual |
Reimplemented in visutwin::canvas::Entity.
Definition at line 307 of file graphNode.cpp.
References enabled().
Referenced by notifyHierarchyStateChanged(), and visutwin::canvas::Entity::onHierarchyStateChanged().
|
inline |
Definition at line 88 of file graphNode.h.
References GraphNode().
Referenced by visutwin::canvas::Entity::findEngine(), and isDescendantOf().
| 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().
| void visutwin::canvas::GraphNode::remove | ( | ) |
Remove graph node from current parent
Definition at line 222 of file graphNode.cpp.
| void visutwin::canvas::GraphNode::removeChild | ( | GraphNode * | child | ) |
Definition at line 229 of file graphNode.cpp.
References visutwin::canvas::EventHandler::fire(), and GraphNode().
| 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().
| Quaternion visutwin::canvas::GraphNode::rotation | ( | ) |
Definition at line 60 of file graphNode.cpp.
References visutwin::canvas::Quaternion::fromMatrix4(), and worldTransform().
Referenced by visutwin::canvas::ShadowRendererDirectional::cull(), visutwin::canvas::ShadowRendererLocal::cullLocalLights(), rotateLocal(), setLocalRotation(), and setRotation().
| 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().
|
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.
| void visutwin::canvas::GraphNode::setLocalEulerAngles | ( | float | x, |
| float | y, | ||
| float | z ) |
Definition at line 172 of file graphNode.cpp.
References visutwin::canvas::Quaternion::fromEulerAngles().
| void visutwin::canvas::GraphNode::setLocalPosition | ( | const Vector3 & | position | ) |
Definition at line 333 of file graphNode.cpp.
References position(), and setLocalPosition().
| void visutwin::canvas::GraphNode::setLocalPosition | ( | float | x, |
| float | y, | ||
| float | z ) |
Definition at line 324 of file graphNode.cpp.
Referenced by setLocalPosition(), visutwin::canvas::AnimEvaluator::update(), and visutwin::canvas::Skeleton::updateGraph().
| void visutwin::canvas::GraphNode::setLocalRotation | ( | const Quaternion & | rotation | ) |
Definition at line 77 of file graphNode.cpp.
References rotation().
Referenced by visutwin::canvas::AnimEvaluator::update(), and visutwin::canvas::Skeleton::updateGraph().
| void visutwin::canvas::GraphNode::setLocalScale | ( | const Vector3 & | scale | ) |
Definition at line 343 of file graphNode.cpp.
| void visutwin::canvas::GraphNode::setLocalScale | ( | float | x, |
| float | y, | ||
| float | z ) |
Definition at line 338 of file graphNode.cpp.
References setLocalScale().
Referenced by setLocalScale(), visutwin::canvas::AnimEvaluator::update(), and visutwin::canvas::Skeleton::updateGraph().
|
inline |
Definition at line 36 of file graphNode.h.
References name().
| void visutwin::canvas::GraphNode::setPosition | ( | const Vector3 & | position | ) |
Definition at line 363 of file graphNode.cpp.
References visutwin::canvas::Matrix4::inverse(), position(), and visutwin::canvas::Matrix4::transformPoint().
| void visutwin::canvas::GraphNode::setPosition | ( | float | x, |
| float | y, | ||
| float | z ) |
Definition at line 358 of file graphNode.cpp.
References setPosition().
Referenced by setPosition().
| void visutwin::canvas::GraphNode::setRotation | ( | const Quaternion & | rotation | ) |
Definition at line 65 of file graphNode.cpp.
References rotation().
| 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.
| float visutwin::canvas::GraphNode::worldScaleSign | ( | ) |
Definition at line 99 of file graphNode.cpp.
References worldTransform().
| const Matrix4 & visutwin::canvas::GraphNode::worldTransform | ( | ) |
Definition at line 86 of file graphNode.cpp.
Referenced by visutwin::canvas::ShadowRendererDirectional::cull(), visutwin::canvas::isVisibleInCameraFrustum(), position(), rotation(), and worldScaleSign().