![]() |
Lysa Nodes
0.0
Lysa Nodes — Scene Graph for the Lysa Engine
|
Base class for all 3D nodes
Inheritance diagram for Node:Public Types | |
| enum | Type { ANIMATION_PLAYER, CAMERA, CHARACTER, COLLISION_AREA, COLLISION_OBJECT, DIRECTIONAL_LIGHT, ENVIRONMENT, KINEMATIC_BODY, LIGHT, MESH_INSTANCE, NODE, OMNI_LIGHT, PHYSICS_BODY, RAYCAST, RIGID_BODY, SKYBOX, SPOT_LIGHT, STATIC_BODY, VIEWPORT } |
| Node type. More... | |
Public Member Functions | |
| Node (const Node &node) | |
| Node (const std::string &name=TypeNames[NODE], Type type=NODE) | |
| virtual | ~Node () = default |
| auto | getId () const |
| virtual void | onReady () |
| virtual void | onEnterScene () |
| virtual void | onExitScene () |
| virtual void | onProcess (const float alpha) |
| virtual void | onPhysicsProcess (const float delta) |
| virtual bool | onInput (const InputEvent &inputEvent) |
| const float4x4 & | getTransform () const |
| void | setTransform (const float4x4 &transform) |
| const float4x4 & | getTransformGlobal () const |
| virtual void | setPosition (const float3 &position) |
| virtual void | setPosition (const float x, const float y, const float z) |
| float3 | getPosition () const |
| void | translate (const float3 &localOffset) |
| void | translate (const float x, const float y, const float z) |
| virtual void | setPositionGlobal (const float3 &position) |
| virtual void | setPositionGlobal (const float x, const float y, const float z) |
| float3 | getPositionGlobal () const |
| void | rotate (const quaternion &quaternion) |
| void | rotateX (float angle) |
| void | rotateY (float angle) |
| void | rotateZ (float angle) |
| void | rotateGlobalX (float angle) |
| void | rotateGlobalY (float angle) |
| void | rotateGlobalZ (float angle) |
| quaternion | getRotation () const |
| quaternion | getRotationGlobal () const |
| float3 | getRotationEulerAngles () const |
| float3 | getRotationEulerAnglesGlobal () const |
| virtual void | scale (float scale) |
| void | setScale (const float3 &scale) |
| void | setRotation (const quaternion &quat) |
| void | setRotationGlobal (const quaternion &quat) |
| void | setRotation (const float3 &rot) |
| void | setRotationX (float angle) |
| void | setRotationY (float angle) |
| void | setRotationZ (float angle) |
| float | getRotationX () const |
| float | getRotationY () const |
| float | getRotationZ () const |
| float | getRotationGlobalX () const |
| float | getRotationGlobalY () const |
| float | getRotationGlobalZ () const |
| void | setRotationGlobalX (float angle) |
| void | setRotationGlobalY (float angle) |
| void | setRotationGlobalZ (float angle) |
| float3 | getScale () const |
| float3 | getScaleGlobal () const |
| template<typename T = Node> | |
| const std::shared_ptr< T > & | addChild (const std::shared_ptr< T > &child, bool async=false) |
| template<typename T = Node> | |
| bool | removeChild (const std::shared_ptr< T > &child) |
| void | removeAllChildren (bool async=false) |
| void | lookAt (const float3 &target) |
| template<typename T = Node> | |
| std::list< std::shared_ptr< T > > | findAllChildrenByGroup (const std::string &groupName, const bool recursive=true) const |
| const std::list< std::string > & | getGroups () const |
| void | addToGroup (const std::string &group) |
| void | removeFromGroup (const std::string &group) |
| virtual bool | isVisible () const |
| virtual void | setVisible (bool visible=true) |
| bool | isInGroup (const std::string &group) const |
| void | setProcessMode (const ProcessMode mode) |
| bool | isProcessed () const |
| auto | getType () const |
| std::string | getPath () const |
| virtual void | setProperty (const std::string &property, const std::string &value) |
| void | printTree (int tab=0) const |
| std::shared_ptr< Node > | duplicate (bool recursiveFilter=false) const |
| float3 | toGlobal (const float3 &local) const |
| float3 | toLocal (const float3 &global) const |
| float3 | getRightVector () const |
| float3 | getLeftVector () const |
| float3 | getFrontVector () const |
| float3 | getBackVector () const |
| float3 | getUpVector () const |
| float3 | getDownVector () const |
| template<typename T > | |
| bool | haveChild (const std::shared_ptr< T > &child, const bool recursive=true) const |
| template<typename T = Node> | |
| std::shared_ptr< T > | getChild (const std::string &name) const |
| template<typename T = Node> | |
| std::shared_ptr< T > | getChildByPath (const std::string &path) const |
| template<typename T = Node> | |
| std::string | getRelativePath (const std::shared_ptr< T > &root) const |
| template<typename T = Node> | |
| std::shared_ptr< T > | findFirstChild (const std::string &name) const |
| template<typename T > | |
| std::shared_ptr< T > | findFirstChild (const bool recursive=true) const |
| template<typename T > | |
| std::list< std::shared_ptr< T > > | findAllChildren (const bool recursive=true) const |
| template<typename T = Node> | |
| std::list< std::shared_ptr< T > > | findAllChildren (const std::string &name, const bool recursive=true) const |
| const std::list< std::shared_ptr< Node > > & | getChildren () |
| const std::list< std::shared_ptr< Node > > & | getChildren () const |
| void | setName (const std::string &nodeName) |
| template<typename T = Node> | |
| std::shared_ptr< T > | getSharedPtr () |
| const std::string & | getName () const |
| template<typename T = Scene> | |
| T * | getScene () const |
| const auto & | getParent () const |
| bool | haveParent () const |
| virtual std::shared_ptr< Node > | copy () const |
| void | setLuaThis () override |
Static Public Member Functions | |
| static std::string | sanitizeName (const std::string &name) |
Static Public Attributes | |
| static constexpr auto | TypeNames |
| Display names for each node Type value, indexed by the Type enum. More... | |
Protected Member Functions | |
| virtual void | updateGlobalTransform () |
Protected Attributes | |
| float4x4 | localTransform {} |
| float4x4 | globalTransform {} |
| Scene * | scene {nullptr} |
| enum Type |
Node type.
| Node | ( | const Node & | node | ) |
Creates a node by copying the transforms, process mode, type and name
| Node | ( | const std::string & | name = TypeNames[NODE], |
| Type | type = NODE |
||
| ) |
Creates a new node at (0.0, 0.0, 0.0) without a parent
|
virtualdefault |
|
inline |
Adds a child node.
Nodes can have any number of children, but a child can have only one parent.
The node will be added to the scene at the start of the next frame.
| child | the node to add |
| async | if true and the node has children all the nodes will be added in batch mode. Be careful to set the visibility of the nodes to falseor they will appear slowly in the scene. |
|
inline |
Adds the node to the group. Groups can be helpful to organize a subset of nodes, for example "enemies" or "stairs".
|
virtual |
Returns a deep copy of this node and its subtree.
Reimplemented in lysa::nodes::MeshInstance::copy(), lysa::nodes::Viewport::copy(), lysa::nodes::Environment::copy()
| std::shared_ptr<Node> duplicate | ( | bool | recursiveFilter = false | ) | const |
Duplicates a node. Warning: not implemented on all node types, check documentation for the node type before using it.
|
inline |
Finds all children by type
|
inline |
Finds all children by name
|
inline |
Finds all children by group
|
inline |
Finds the first child by is type.
|
inline |
Finds the first child by is name.
|
inline |
Returns the normalized back vector
|
inline |
Returns the child node by is name. Not recursive
|
inline |
Returns the child node by its relative path (does not start with '/')
|
inline |
Returns the immutable list of children nodes
|
inline |
Returns the immutable list of children nodes
|
inline |
Returns the normalized down vector
|
inline |
Returns the normalized front vector
|
inline |
Returns an immutable list of group names that the node has been added to.
|
inline |
Returns the unique id of the node
|
inline |
Returns the normalized left vector
|
inline |
Returns the node's display name.
|
inline |
Returns the node's parent in the scene tree
| std::string getPath | ( | ) | const |
Returns the absolute node path
|
inline |
Returns the local space position (relative to parent)
|
inline |
Returns the world space position
|
inline |
|
inline |
Returns the normalized right vector
| quaternion getRotation | ( | ) | const |
Returns the rotation of the local transformation
|
inline |
Returns the rotation of the local transformation, in euler angles in radians
|
inline |
Returns the rotation of the world transformation, in euler angles in radians
| quaternion getRotationGlobal | ( | ) | const |
Returns the rotation of the world transformation
| float getRotationGlobalX | ( | ) | const |
Returns the X axis rotation of the global transformation
| float getRotationGlobalY | ( | ) | const |
Returns the Y axis rotation of the global transformation
| float getRotationGlobalZ | ( | ) | const |
Returns the Z axis rotation of the global transformation
| float getRotationX | ( | ) | const |
Returns the X axis rotation of the local transformation
| float getRotationY | ( | ) | const |
Returns the Y axis rotation of the local transformation
| float getRotationZ | ( | ) | const |
Returns the Z axis rotation of the local transformation
| float3 getScale | ( | ) | const |
Returns the scale part of the local transformation.
| float3 getScaleGlobal | ( | ) | const |
Returns the scale part of the global transformation.
|
inline |
Returns the scene this node belongs to, cast to type T, or nullptr if not in a scene.
|
inline |
Returns a shared_ptr to this node, optionally cast to type T.
|
inline |
Returns the local space transformation matrix
|
inline |
Returns the world space transformation matrix
|
inline |
Returns the node type
|
inline |
Returns the normalized up vector
|
inline |
Returns true if the node has this child
|
inline |
Returns true if this node has a parent in the scene tree.
|
inline |
Returns true if this node has been added to the given group
| bool isProcessed | ( | ) | const |
Returns true if the node is processed and receive input callbacks
|
inlinevirtual |
Returns the visibility of the node.
| void lookAt | ( | const float3 & | target | ) |
Rotate the node toward the target
|
inlinevirtual |
Called when a node is added to the scene
|
inlinevirtual |
Called when a node is removed from the scene
|
inlinevirtual |
Called on a keyboard, mouse, or gamepad event
|
inlinevirtual |
Called just after the physics system has been updated (can be called multiple times if we have free time between frames)
|
inlinevirtual |
Called each frame after the physics have been updated and just before drawing the frame
|
inlinevirtual |
Called when a node is ready to initialize, before being added to the scene
| void printTree | ( | int | tab = 0 | ) | const |
Recursively prints the node tree in the log system
| void removeAllChildren | ( | bool | async = false | ) |
Removes all children nodes. The nodes, along with their children can be deleted depending on their reference counters. The nodes will be removed from the scene at the start of the next frame.
| async | if true and the nodes will be removed in batch mode. Be careful to set the visibility of the nodes to false or they will disappear slowly from the scene. |
|
inline |
Removes a child node. The node, along with its children can be deleted depending on their reference counter.
Use the iterator version in a for-each loop.
The node will be removed from the scene at the start of the next frame.
| child | the node to remove |
| async | if true and the node have children all the nodes will be removed in batch mode. Be careful to set the visibility of the nodes to false or they will disappear slowly from the scene. |
|
inline |
Removes the node from the given group. Does nothing if the node is not in the group
| void rotate | ( | const quaternion & | quaternion | ) |
Rotates the local transformation
| void rotateGlobalX | ( | float | angle | ) |
Rotates the global transformation around the X axis by angle in radians.
| void rotateGlobalY | ( | float | angle | ) |
Rotates the global transformation around the Y axis by angle in radians.
| void rotateGlobalZ | ( | float | angle | ) |
Rotates the global transformation around the Z axis by angle in radians.
| void rotateX | ( | float | angle | ) |
Interpolate the local transformation
Rotates the local transformation around the X axis by angle in radians.
| void rotateY | ( | float | angle | ) |
Rotates the local transformation around the Y axis by angle in radians.
| void rotateZ | ( | float | angle | ) |
Rotates the local transformation around the Z axis by angle in radians.
|
static |
Returns a sanitized copy of name with characters that are invalid in node identifiers replaced or removed.
|
virtual |
Scale the local transformation
|
override |
|
inline |
Sets the node name (purely informative)
|
inlinevirtual |
Sets the local space position (relative to parent)
|
virtual |
Sets the local space position (relative to parent)
|
inlinevirtual |
Sets the world space position
|
virtual |
Sets the world space position
|
inline |
Changes the node's processing behavior.
|
virtual |
Sets a property by its name and value. Currently, not all properties in all node classes are supported.
Reimplemented in lysa::nodes::MeshInstance::setProperty(), lysa::nodes::Environment::setProperty()
| void setRotation | ( | const float3 & | rot | ) |
Sets the local rotation
| void setRotation | ( | const quaternion & | quat | ) |
Sets the local rotation
| void setRotationGlobal | ( | const quaternion & | quat | ) |
Sets the world rotation
| void setRotationGlobalX | ( | float | angle | ) |
Sets the X axis rotation of the global transformation by angle in radians.
| void setRotationGlobalY | ( | float | angle | ) |
Sets the Y axis rotation of the global transformation by angle in radians.
| void setRotationGlobalZ | ( | float | angle | ) |
Sets the Z axis rotation of the global transformation by angle in radians.
| void setRotationX | ( | float | angle | ) |
Sets the X axis rotation of the local transformation by angle in radians.
| void setRotationY | ( | float | angle | ) |
Sets the Y axis rotation of the local transformation by angle in radians.
| void setRotationZ | ( | float | angle | ) |
Sets the Z axis rotation of the local transformation by angle in radians.
| void setScale | ( | const float3 & | scale | ) |
Sets the local scale
| void setTransform | ( | const float4x4 & | transform | ) |
Sets the local transformation matrix
|
virtual |
Changes the visibility of the node.
The node stays in the scene tree and the data in VRAM.
Reimplemented in lysa::nodes::MeshInstance::setVisible()
| float3 toGlobal | ( | const float3 & | local | ) | const |
Transforms a local vector from this node's local space to world space.
| float3 toLocal | ( | const float3 & | global | ) | const |
Transforms a world space vector to this node's local space.
|
inline |
Changes the node's position by the given offset vector in local space.
| void translate | ( | const float3 & | localOffset | ) |
Changes the node's position by the given offset vector in local space.
|
protectedvirtual |
Reimplemented in lysa::nodes::MeshInstance::updateGlobalTransform()
|
protected |
|
protected |
|
protected |
|
staticconstexpr |
Display names for each node Type value, indexed by the Type enum.