UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

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 setImmovable (int immovable) const =0

Updates a value indicating if the node is immovable. Immovable nodes use dynamic lights optimization, that consists in rendering only those polygons, which are illuminated by the light source. However, remember that both the light and the object being lit should be immovable.

Arguments

  • int immovable - Positive number to make the node immovable, 0 not to make.

virtual int isImmovable () const =0

Returns a value indicating if the node is immovable. Immovable nodes use dynamic lights optimization, that consists in rendering only those polygons, which are illuminated by the light source. However, remember that both the light and the object being lit should be immovable.

Return value

Returns 1 if the node is immovable; 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 from the list of children. World position of the removed child is preserved, and its transformations will be done in the world coordinates.

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 from the list of children. World position of the removed child is preserved, and its transformations will be done in the world coordinates.

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.

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 void setProperty (const char * name) const =0

Sets a given property to the node.

Arguments

  • const char * name - Name of the property.

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

Returns 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

Returns 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

Returns 1 if the node state is saved successfully; otherwise, 0.

virtual int restoreState (const StreamPtr & stream) const =0

Restore a node state from the stream.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

Return value

Returns 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.
Last update: 2017-07-03