Unigine::Node Class
Interface for node handling. See also UnigineScript analog.
To use this class, include the UnigineNode.h file.
Unigine::Node Class
Members
virtual ~Node ()
Virtual destructor.virtual void grab () =0
Sets the owner flag to 1 for the pointer. The node should not be handled by the engine after this function is called.virtual void release () =0
Sets the owner flag to 0 for the pointer. The node should be handled by the engine after this function is called.virtual int isOwner () const =0
Returns the owner flag. If the pointer is the owner, on its deletion the object also will be deleted. Use grab() and release() functions to change ownership.Return value
Returns the owner flag.virtual Ptr< Node > getNode () const =0
Returns a node pointer.Return value
Node pointer.virtual int setID (int id) const =0
Sets a unique identifier to the node.Arguments
- int id - Node identifier.
Return value
Returns 1 if the node ID is set successfully; otherwise, 0.virtual int getID () const =0
Returns a unique identifier of the node.Return value
Unique node identifier.virtual int getType () const =0
Returns a type of the node.Return value
Node type identifier.virtual const char * getTypeName () const =0
Returns a name of the node type.Return value
Node type name.virtual int isWorld () const =0
Returns a value indicating if a given node is a world node.Return value
Return 1 if the given node is a world node; otherwise, 0.virtual int isLight () const =0
Returns a value indicating if a given node is a light source.Return value
Return 1 if the given node is a light source; otherwise, 0.virtual int isDecal () const =0
Returns a value indicating if a given node is a decal.Return value
Returns 1 if the given node is a decal; otherwise, 0.virtual int isObject () const =0
Returns a value indicating if a given node is an object node.Return value
Return 1 if the given node is an object node; otherwise, 0.virtual int isPlayer () const =0
Returns a value indicating if a given node is a player.Return value
Returns 1 if the given node is a player; otherwise, 0.virtual int isPhysical () const =0
Returns a value indicating if a given node is a physical node.Return value
Returns 1 if the given node is a physical node; otherwise, 0.virtual int isNavigation () const =0
Returns a value indicating if a given node is a navigation node.Return value
Returns 1 if the given node is a navigation node; otherwise, 0.virtual int isObstacle () const =0
Returns a value indicating if a given node is an obstacle node.Return value
Returns 1 if the given node is an obstacle node; otherwise, 0.virtual int isSound () const =0
Returns a value indicating if a given node is a sound node.Return value
Returns 1 if the given node is a sound node; otherwise, 0.virtual void setEnabled (int enable) const =0
Enables or disables the node.Arguments
- int enable - 1 to enable the node, 0 to disable it.
virtual int isEnabled () const =0
Returns a value indicating if the node and its parent nodes are enabled.Return value
Returns 1 if the node and its parent nodes are enabled; otherwise, 0.virtual int isEnabledSelf () const =0
Returns a value indicating if the node is enabled.Return value
Returns 1 if the node is enabled; otherwise, 0.virtual void setHandled (int handled) const =0
Sets a value indicating if the node handle is visible. This option is valid only for invisible nodes, such as light and sound sources, particle systems and world-managing nodes (WorldSector, WorldPortal, triggers, expressions, etc.).Arguments
- int handled - Positive value to show the handle, 0 to hide it.
virtual int isHandled () const =0
Returns a value indicating if the node handle is currently visible.Return value
Returns 1 if the handle is shown; otherwise, 0.virtual void setCollider (int collider) const =0
Updates a value indicating if collision test enabled for the node.Arguments
- int collider - Positive number to enable collision test, 0 to disable.
virtual int isCollider () const =0
Returns a value indicating if collision test is enabled for the node.Return value
Returns 1 if collision test is enabled for the node; otherwise, 0.virtual void setClutter (int clutter) const =0
Updates a value indicating if the node represents a clutter object.Arguments
- int clutter - Positive number to mark the node as a clutter object; otherwise, 0.
virtual int isClutter () const =0
Returns a value indicating if the node is a clutter object.Return value
Returns 1 if the node is a clutter object; otherwise, 0.virtual void setSpatial (int spatial) const =0
Updates a value indicating if sectors and portals are used for node visibility determination.Arguments
- int spatial - Positive value to consider sectors and portals; otherwise, 0.
virtual int isSpatial () const =0
Returns a value indicating if sectors and portals are used for node visibility determination.Return value
Returns 1 if sectors and portals are considered; otherwise, 0.virtual void setQuery (int query) const =0
Updates a value indicating if occlusion query is used for the node.Arguments
- int query - Positive number to use occlusion query, 0 not to use.
virtual int isQuery () const =0
Returns a value indicating if occlusion query is used for the node. The default is 0 (not used).Return value
Returns 1 if occlusion query is used; otherwise, 0.virtual void setLatest (int latest) const =0
Sets a flag that forces a node to be updated the last of all, after states of all other nodes were updated. For example, a post update flag is useful to draw nodes strictly in front of the camera (after a Player has updated its transformations). By default, this flag is set to 0.Arguments
- int latest - Positive value to update a node last of all; otherwise, 0.
virtual int isLatest () const =0
Checks if a node is forced to be updated the last of all, after states of all other nodes were updated. For example, a post update flag is useful to draw nodes strictly in front of the camera (after a Player has updated its transformations). By default, this flag is set to 0.Return value
Returns 1 if the node is updated last of all; otherwise, 0.virtual void setFolded (int folded) const =0
Shows or minimizes node children in the node tree hierarchy.Arguments
- int folded - Positive number to minimize node children; 0 to expand node hierarchy.
virtual int isFolded () const =0
Returns a value indicating if node children are shown or minimized in the node tree hierarchy.Return value
Return Positive number if node children are hidden in the node tree; otherwise, 0.virtual void setName (const char * name) const =0
Sets a name for the node.Arguments
- const char * name - New name of the node.
virtual const char * getName () const =0
Returns a name of the node.Return value
Name of the node.virtual void setData (const char * data) const =0
Sets user data associated with the node.- If the node was loaded from the *.node file, data is saved directly into the data tag of this file.
- If the node is loaded from the *.world file, data is saved into the Node data tag of the *.world file.
- If the node is loaded from the *.world file as a NodeReference, data will be saved to the NodeReference data tag of the *.world file.
Arguments
- const char * data - New user string data. Data can be an xml formatted string.
virtual const char * getData () const =0
Returns user data associated with the node.- If the node was loaded from the *.node file, data from the data tag of this file is returned.
- If the node is loaded from the *.world file, data from the Node data tag of the *.world file is returned.
- If the node is loaded from the *.world file as a NodeReference, data from the NodeReference data tag of the *.world file is returned.
Return value
User string data. Data can be an xml formatted string.virtual void setParent (const Ptr< Node > & node) const =0
Sets the new parent for the node. Transformations of the current node will be done in the coordinates of the parent.Arguments
- const Ptr< Node > & node - New parent node.
virtual void setWorldParent (const Ptr< Node > & node) const =0
Sets the new parent of the node. Transformations of the current node will be done in the world coordinates.Arguments
- const Ptr< Node > & node - New parent node.
virtual Ptr< Node > getParent () const =0
Returns the parent of the node.Return value
Parent node if exists; otherwise, NULL.virtual void addChild (const Ptr< Node > & node) const =0
Adds a child to the node. Transformations of the new child will be done in the coordinates of the parent.Arguments
- const Ptr< Node > & node - New child node.
virtual void removeChild (const Ptr< Node > & node) const =0
Removes a child node (added by the addChild() method) from the list of children.Arguments
- const Ptr< Node > & node - Child node to remove.
virtual void addWorldChild (const Ptr< Node > & node) const =0
Adds a child to the node. Transformations of the new child will be done in the world coordinates.Arguments
- const Ptr< Node > & node - New child node.
virtual void removeWorldChild (const Ptr< Node > & node) const =0
Removes a child node (added by the addWorldChild() method) from the list of children.Arguments
- const Ptr< Node > & node - Child node to remove.
virtual int isChild (const Ptr< Node > & node) const =0
Checks if a given node is a child of the current node.Arguments
- const Ptr< Node > & node - Node to check.
Return value
Returns 1 if the given node is a child; otherwise, 0.virtual int getNumChilds () const =0
Returns the number of child nodes.The function is deprecated. It is provided to keep your code working until the next release. Please, replace it with getNumChildren().
Return value
Number of child nodes.virtual int getNumChildren () const =0
Returns the number of child nodes.Return value
Number of child nodes.virtual int findChild (const char * name) const =0
Searches for a child node with a given name among all children of the current node.Arguments
- const char * name - Name of the child node.
Return value
Child number, if it is found; otherwise, -1.virtual Ptr< Node > getChild (int num) const =0
Returns the node child by its number.Arguments
- int num - Number of the child.
Return value
Child node.virtual Ptr< Node > getPossessor () const =0
Returns a possessor of the node. The following nodes can be possessors:- NodeReference
- WorldCluster
- WorldClutter
- WorldLayer This function can only be applied to a root node inside a node reference.
Return value
Possessor node, if exists; otherwise, NULL.virtual int setProperty (const char * name) const =0
Sets a given property to the node.Arguments
- const char * name - Name of the property.
Return value
1 if the property is set successfully; otherwise, 0.virtual PropertyPtr getProperty () const =0
Returns the node property smart pointer.Return value
Node property smart pointer, if exists; otherwise, NULL.virtual const char * getPropertyName () const =0
Returns the name of a property associated with the node.Return value
Property name, if exists; otherwise, NULL.virtual void setTransform (const UNIGINE_MAT4 & transform) const =0
Sets the transformation matrix for the node in its parent coordinates.Arguments
- const UNIGINE_MAT4 & transform - New transformation matrix.
virtual UNIGINE_MAT4 getTransform () const =0
Returns the transformation matrix of the node in its parent coordinates.Return value
Transformation matrix.virtual void setWorldTransform (const UNIGINE_MAT4 & transform) const =0
Sets the transformation matrix for the node in the world coordinates.Arguments
- const UNIGINE_MAT4 & transform - Transformation matrix.
virtual UNIGINE_MAT4 getWorldTransform () const =0
Returns the transformation matrix of the node in the world coordinates.Return value
Transformation matrix.virtual UNIGINE_MAT4 getIWorldTransform () const =0
Returns the inverse transformation of the node for transformations in the world coordinates.Return value
Inverse transformation matrix.virtual BoundBox getBoundBox () const =0
Returns the bounding box of the node.virtual BoundSphere getBoundSphere () const =0
Returns the bounding sphere of the node.Return value
Bounding sphere of the node.virtual UNIGINE_BOUND_BOX getWorldBoundBox () const =0
Returns the world bounding box of the node.Return value
World bounding box.virtual UNIGINE_BOUND_SPHERE getWorldBoundSphere () const =0
Returns the world bounding sphere of the node.Return value
World bounding sphere.virtual Ptr< Node > clone () const =0
Clones the current node.Return value
Cloned node.virtual void swap (const Ptr< Node > & node) const =0
Swaps two nodes.Arguments
- const Ptr< Node > & node - Node to swap.
virtual int loadWorld (const XmlPtr & xml) const =0
Loads a node state from the Xml.Arguments
- const XmlPtr & xml - Xml smart pointer.
Return value
1 if the node state is loaded successfully; otherwise, 0.virtual int saveWorld (const XmlPtr & xml) const =0
Saves a node state into the Xml.Arguments
- const XmlPtr & xml - Xml smart pointer.
Return value
1 if the node state is saved successfully; otherwise, 0.virtual int saveState (const StreamPtr & stream) const =0
Saves a node state into the stream.Arguments
- const StreamPtr & stream - Stream smart pointer.
Return value
1 if the node state is saved successfully; otherwise, 0.virtual int restoreState (const StreamPtr & stream) const =0
Restores a node state from the stream.Arguments
- const StreamPtr & stream - Stream smart pointer.
Return value
1 if the node state is restored successfully; otherwise, 0.static Ptr< Node > getNode (int id)
Returns the node pointer by it's unique identifier.Arguments
- int id - Node identifier.
Return value
Node pointer.static int isNode (const Ptr< Node > & node)
Check the node pointer.Arguments
- const Ptr< Node > & node - Node pointer.
Return value
Returns 1 if the node is valid; otherwise, 0.static int isNode (int node)
Check the node unique identifier.Arguments
- int node - Node identifier.
Return value
Returns 1 if the node identifier is valid; otherwise, 0.virtual int isVisible () const =0
Returns a value indicating if the node was shown in the viewport in the previous frame and, therefore, is updated.Return value
1 if the node was visible; otherwise, 0.virtual int isShadow () const =0
Returns a value indicating if the node was a shadow caster in the previous frame and, therefore, is updated.Return value
1 if the node was a shadow caster; otherwise, 0.virtual vec3 getLinearVelocity () const =0
Returns the linear velocity of the node's physical body in the local space.Return value
Linear velocity in the local space.virtual vec3 getAngularVelocity () const =0
Returns the angular velocity of the node's physical body in the local space.Return value
Angular velocity in the local space.virtual vec3 getWorldVelocity (const UNIGINE_VEC3 & point) const =0
Returns linear velocity of a point of the node's physical body in the world space.Arguments
- const UNIGINE_VEC3 & point - A target point.
Return value
Linear velocity in the world space.virtual Ptr < WorldSector > getWorldSector () const =0
Returns a sector, in which the node is located.Return value
World sector.virtual void setNodePosition (const UNIGINE_VEC3 & position) =0
Updates the node position.Arguments
- const UNIGINE_VEC3 & position - New position in the local space.
virtual UNIGINE_VEC3 getNodePosition () const =0
Returns the node position.Return value
The node position in the local space.virtual void setNodeRotation (const quat & rotation, int identity = 0) =0
Updates the node rotation.Arguments
- const quat & rotation - New rotation in the local space.
- int identity - 1 to enable scaling of the node, 0 to disable it.
virtual quat getNodeRotation () const =0
Returns the node rotation.Return value
The node rotation in the local space.virtual void setNodeDirection (const vec3 & direction, const vec3 & up) =0
Updates the direction vector of the node. By default, a direction vector points along -Z axis. This function changes its direction and reorients the node.Arguments
- const vec3 & direction - New direction vector in the local space. The direction vector always has unit length.
- const vec3 & up - New up vector in the local space.
virtual vec3 getNodeDirection () const =0
Returns the normalized direction vector of the node. By default, a direction vector points along the mesh local -Z axis. It always has an unit length.Return value
Normalized direction vector in the local space.virtual void setNodeScale (const vec3 & scale) =0
Updates the node scale.Arguments
- const vec3 & scale - New scale in the local space.
virtual vec3 getNodeScale () const =0
Returns scale of the node.Return value
Scale in the local space.virtual void setNodeWorldPosition (const UNIGINE_VEC3 & position) =0
Updates the node position.Arguments
- const UNIGINE_VEC3 & position - New position in the world space.
virtual UNIGINE_VEC3 getNodeWorldPosition () const =0
Returns the node position.Return value
The node position in the world space.virtual void setNodeWorldRotation (const quat & rotation, int identity = 0) =0
Updates the node rotation.Arguments
- const quat & rotation - New rotation in the world space.
- int identity - 1 to enable scaling of the node, 0 to disable it.
virtual quat getNodeWorldRotation () const =0
Returns the node rotation.Return value
The node rotation in the local space.virtual void setNodeWorldDirection (const vec3 & direction, const vec3 & up) =0
Updates the direction vector of the node. By default, a direction vector points along -Z axis. This function changes its direction and reorients the node.Arguments
- const vec3 & direction - New direction vector in the world space. The direction vector always has unit length.
- const vec3 & up - New up vector in the world space.
virtual vec3 getNodeWorldDirection () const =0
Returns the normalized direction vector of the node. By default, a direction vector points along the mesh local -Z axis and is returned in world space coordinates. It always has the unit length.Return value
Normalized direction vector in the world space.virtual void setNodWorldScale (const vec3 & scale) =0
Updates the node scale.Arguments
- const vec3 & scale - New scale in the local space.
virtual vec3 getNodeWorldScale () const =0
Returns scale of the node.Return value
Scale in the local space.virtual void renderVisualizer () =0
Renders a bounding box / sphere of the object.You should enable the engine visualizer by the show_visualizer 1 console command.
Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)