This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Node Class

Warning
UnigineScript is deprecated and will be removed in future releases. Please consider using C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt is not guaranteed, as the current level of support assumes only fixing critical issues.

In terms of Unigine, all of the objects added into the scene are called nodes. Nodes can be of different types, determining their visual representation and behavior.

The node is created and stored in the world. All changes are saved into the .world file.

The node can be also saved into an external .node file and then imported into the world when necessary. Also it is possible to create a reference to the exported node.

You can associate any string data (written directly into a *.node or a *.world file) or an arbitrary user variable with a node.

See Also#

Creating a Node#

The Node class doesn't provide creating of a node. You can create an instance of any class inherited from the Node class and then operate it as it is an instance of the Node class.

Notice
Only UnigineScript provides such option. For C++ and C#, see the corresponding version of the article.

For example:

  1. Create a box mesh by using the Mesh class.
  2. Use the box mesh to create an instance of the ObjectMeshStatic class. This class is inherited from the Node class.
  3. Operate the ObjectMeshStatic instance as a node.
Source code (UnigineScript)
// unigine_project.cpp

#include <core/unigine.h>

int init() {

	// create a mesh
	Mesh mesh = new Mesh();
	mesh.addBoxSurface("box_0", vec3(1.0f));
	// create an instance of any class inherited from the Node class (e.g. ObjectMeshStatic)
	ObjectMeshStatic object_mesh = new ObjectMeshStatic(mesh);

	// operate the ObjectMeshStatic as a node

	return 1;
}

Editing a Node and Saving Changes#

The Node class contains common settings of the node. Also each node has special settings, which vary depending on the type of the node.

Notice
The special settings of a node can be found in the article on the corresponding class.

Editing the node also includes editing materials and properties assigned to the node.

For the edited node to be saved in the .world file, you should enable the corresponding option via the setSaveToWorldEnabled() method.

Notice
The node shall be saved to a *.world file only if this option is enabled for all of its ancestors as well.

For example:

  1. Create a box mesh by using the Mesh class.
  2. Save the mesh on the disk. It is required as the node we are going to export need to reference to a mesh stored on the disk.
  3. Use the saved .mesh file to create an instance of the ObjectMeshStatic class. This class is inherited from the Node class.
  4. Release script ownership of the ObjectMeshStatic instance.
  5. Pass node ownership to the editor by adding it the node to it.
  6. Edit the node and then save the world by calling the world_saveconsole command.
Source code (UnigineScript)
// unigine_project.cpp

#include <core/unigine.h>

int init() {

	// create a mesh
	Mesh mesh = new Mesh();
	mesh.addBoxSurface("box_0", vec3(1.0f));
	// save a mesh into a file on the disk
	mesh.save("unigine_project/meshes/my_mesh.mesh");
	// create an instance of any class inherited from the Node class (e.g. ObjectMeshStatic)
	ObjectMeshStatic object_mesh = new ObjectMeshStatic("unigine_project/meshes/my_mesh.mesh");
	// assign a material to the mesh
	object_mesh.setMaterial("mesh_base","*");

	// change the node name
	object_mesh.setName("my_node");
	// change node transformation
	object_mesh.setWorldTransform(translate(Vec3(0.0f, 0.0f, 2.0f)));

	// save node changes in the .world file
	engine.console.run("world_save");
	
	return 1;
}

Exporting and Importing a Node#

To export a node stored in the world into the external .node file, you should pass it to the saveNode() method of the World class.

To import the existing node stored in the .node file to the world, you should call the loadNode() method of the World class.

For example:

  1. Create a box mesh by using the Mesh class.
  2. Save the mesh on the disk. It is required as the node we are going to export need to reference to a mesh stored on the disk.
  3. Use the saved .mesh file to create an instance of the ObjectMeshStatic class. This class is inherited from the Node class.
  4. Release script ownership of the ObjectMeshStatic instance.
  5. Pass node ownership to the editor by adding it the node to it.
  6. Export the node to an external .node file.
  7. Import the previously exported node and add it to the editor to check the result.
    Notice
    The node imported via loadNode() is orphan, so you don't need to release script ownership.
Source code (UnigineScript)
// unigine_project.cpp

#include <core/unigine.h>

int init() {

	// create a mesh
	Mesh mesh = new Mesh();
	mesh.addBoxSurface("box_0", vec3(1.0f));
	// save a mesh into a file on the disk
	mesh.save("unigine_project/meshes/my_mesh.mesh");
	// create an instance of any class inherited from the Node class (e.g. ObjectMeshStatic)
	ObjectMeshStatic object_mesh = new ObjectMeshStatic("unigine_project/meshes/my_mesh.mesh");
	// assign a material to the mesh
	object_mesh.setMaterial("mesh_base","*");

	// export the node into a .node file
	engine.world.saveNode("unigine_project/nodes/my_node.node",object_mesh);
	// import the exported node to check the result
	Node imported_node = engine.world.loadNode("unigine_project/nodes/my_node.node");

	// set a position of the node
	imported_node.setPosition(Vec3(4.0f, 0.0f, 1.0f));
	
	return 1;
}

Deleting a Node#

By default each new node's lifetime matches the lifetime of the World (i.e. such node shall be deleted when the world is closed). But you can also choose node's lifetime to be managed:

  • by the Engine - is this case the node shall be deleted automatically on Engine shutdown.
  • manually - is this case the node should be deleted manually by the user.

To delete a node you can use the following two methods:

  • deleteLater() - performs delayed deletion, in this case the object will be deleted during the next swap stage of the main loop (rendering of the object ceases immediately, but it still exists in memory for a while, so you can get it from its parent, for example). This method simplifies object deletion from a secondary thread, so you can call it and forget about the details, letting the Engine take control over the process of deletion, which can be used for future optimizations.
  • deleteForce() - performs immediate deletion, which might be necessary in some cases. Calling this method for main-loop-dependent objects (e.g., nodes) is safe only when performed from the Main thread.
Source code (UnigineScript)
// unigine_project.cpp

#include <core/unigine.h>

int init() {
	
	// create a mesh
	Mesh mesh = new Mesh();
	mesh.addBoxSurface("box_0", vec3(1.0f));
	// create an instance of any class inherited from the Node class (e.g. ObjectMeshStatic)
	ObjectMeshStatic object_mesh = new ObjectMeshStatic(mesh);
	// assign a material to the mesh
	object_mesh.setMaterial("mesh_base", "*");

	// do something with the node
	// ...

	// delete the node from the editor
	engine.editor.removeNode(object_mesh);

	return 1;
}

Node Class

Members


Node getAncestor ( int num ) #

Returns a node ancestor by its number.

Arguments

  • int num - Ancestor ID.

Return value

Ancestor node.

vec3 getBodyAngularVelocity ( ) #

Returns the angular velocity of the node's physical body in the local space.

Return value

Angular velocity in the local space.

BoundBox getBoundBox ( ) #

Returns the bounding box of the node.
Notice
The coordinates of the bounding box are in the node's local coordinate system. To get the bounding box in world coordinates, use the getWorldBoundBox() method.

Return value

Bounding box of the node.

BoundSphere getBoundSphere ( ) #

Returns the bounding sphere of the node.
Notice
The coordinates of the bounding sphere are in the node's local coordinate system. To get the bounding sphere in world coordinates, use the getWorldBoundSphere() method.

Return value

Bounding sphere of the node.

Node getChild ( int num ) #

Returns a node child by its number.

Arguments

  • int num - Child ID.

Return value

Child node.

int isChild ( Node n ) #

Checks if a given node is a child of the node.

Arguments

  • Node n - Node to check.

Return value

1 if the given node is a child; otherwise, 0.

void setChildIndex ( Node n, int index ) #

Sets the index for a given child node of the node.

Arguments

  • Node n - Child node.
  • int index - Node index.

int getChildIndex ( Node n ) #

Returns the index of a given child node of the node.

Arguments

  • Node n - Child node.

Return value

Node index.

void setImmovable ( int immovable ) #

Sets a value indicating if the node represents an immovable (clutter) object, which means it is moved to a separate spatial tree for immovable (static) objects optimizing node management.

Arguments

  • int immovable - 1 to mark the node as an immovable object; otherwise, 0.

int isImmovable ( ) #

Returns a value indicating if the node is an immovable (clutter) object, which means it is moved to a separate spatial tree for immovable (static) objects optimizing node management.

Return value

1 if the node is a clutter object; otherwise, 0.

void setClutterInteractionEnabled ( int enabled ) #

Sets a value indicating if interaction with World Clutters and Mesh Clutters is enabled for the node.
Notice
It is recommended to disable this option for better performance, when cutting node out of clutters is not necessary. Especially when the world contains a significant number of such nodes.

Arguments

int isClutterInteractionEnabled ( ) #

Returns a value indicating if interaction with World Clutters and Mesh Clutters is enabled for the node.
Notice
It is recommended to disable this option for better performance, when cutting node out of clutters is not necessary. Especially when the world contains a significant number of such nodes.

Return value

1 if interaction with World Clutters and Mesh Clutters is enabled; otherwise, 0.

void setGrassInteractionEnabled ( int enabled ) #

Sets a value indicating if interaction with Grass nodes is enabled for the node.
Notice
It is recommended to disable this option for better performance, when cutting node out of grass is not necessary. Especially when the world contains a significant number of such nodes.

Arguments

  • int enabled - 1 to enable interaction with Grass nodes, 0 to disable it.

int isGrassInteractionEnabled ( ) #

Returns a value indicating if interaction with Grass nodes is enabled for the node.
Notice
It is recommended to disable this option for better performance, when cutting node out of grass is not necessary. Especially when the world contains a significant number of such nodes.

Return value

1 if interaction with Grass nodes is enabled; otherwise, 0.

void setTriggerInteractionEnabled ( int enabled ) #

Sets a value indicating if interaction with WorldTrigger nodes is enabled for the node.
Notice
It is recommended to disable this option for better performance, when node interaction with World Triggers is not necessary. Especially when the world contains a significant number of such nodes.

Arguments

  • int enabled - true to enable interaction with World Triggers, false to disable it.

int isTriggerInteractionEnabled ( ) #

Returns a value indicating if interaction with WorldTrigger nodes is enabled for the node.
Notice
It is recommended to disable this option for better performance, when node interaction with World Triggers is not necessary. Especially when the world contains a significant number of such nodes.

Return value

1 if interaction with WorldTrigger nodes is enabled; otherwise, 0.

void setData ( string data ) #

Updates 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

  • string data - New user data. Data can contain an XML formatted string.

string getData ( ) #

Returns user string 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.
Notice
You can also use setVariable() to associate an arbitrary user variable with a node.

Return value

User string data. Data can contain an XML formatted string.

int isDecal ( ) #

Returns a value indicating if the node is a decal node (its type is NODE_DECAL_*).

Return value

1 if the node is a decal node; otherwise, 0.

void setEnabled ( int enabled ) #

Enables or disables the node.

Arguments

  • int enabled - 1 to enable the node, 0 to disable it.

void updateEnabled ( ) #

Updates node's internal state according to the current "enabled" state.

int isEnabled ( ) #

Returns a value indicating if the node and its parent nodes are enabled.

Return value

1 if the node and its parent nodes are enabled; otherwise, 0.

int isEnabledSelf ( ) #

Returns a value indicating if the node is enabled.

Return value

1 if the node is enabled; otherwise, 0.

int isExtern ( ) #

Returns a value indicating if the node is an extern node (its type is one of the following: NODE_EXTERN, OBJECT_EXTERN, WORLD_EXTERN).

Return value

1 if the node is an extern node; otherwise, 0.

int isField ( ) #

Returns a value indicating if the node is a field node (its type is one of the FIELD_*).

Return value

1 if the node is a field node; otherwise, 0.

int isGeodetic ( ) #

Returns a value indicating if the node is a geodetic-related node.

Return value

1 if the node is a geodetic-related node; otherwise, 0.

GeodeticPivot getGeodeticPivot ( ) #

Returns a pointer to geodetic pivot of the node.

Return value

Geodetic pivot smart pointer, or NULL if the node is not a child of a geodetic pivot node.

void setHandled ( int handled ) #

Disables or shows the node handle. This option is valid only for invisible nodes, such as light and sound sources, particle systems and world-managing nodes (WorldOccluder, triggers, expressions, etc.)

Arguments

  • int handled - 1 to show the handle, 0 to hide it.true to show the handle, false to hide it.

int isHandled ( ) #

Returns a value indicating if the node handle is displayed. This option is valid only for invisible nodes, such as light and sound sources, particle systems and world-managing nodes (WorldOccluder, triggers, expressions, etc.)

Return value

1 if the handle is shown; otherwise, 0.

void getHierarchy ( ) #

Retrieves the whole hierarchy of the node and puts it to the hierarchy buffer.

Arguments

    void setID ( int id ) #

    Sets a unique ID for the node.

    Arguments

    • int id - Node ID.

    int getID ( ) #

    Returns the ID of the node.
    Notice
    See also engine.world.getNodeById() function.

    Return value

    Node ID.

    Mat4 getIWorldTransform ( ) #

    Returns the inverse transformation matrix of the node for transformations in the world coordinates.

    Return value

    Inverse transformation matrix.

    int isLight ( ) #

    Returns a value indicating if the node is a light source (its type is NODE_LIGHT_*).

    Return value

    1 if the node is a light source; otherwise, 0.

    int isLandscapeLayer ( ) #

    Returns a value indicating if the node is a landscape layer (its type is NODE_LANDSCAPE_LAYER_*).

    Return value

    1 if the node is a landscape layer; otherwise, 0.

    vec3 getBodyLinearVelocity ( ) #

    Returns the linear velocity of the node's physical body in the local space.

    Return value

    Linear velocity in the local space.

    void setName ( string name ) #

    Sets a name for the node.

    Arguments

    • string name - New name of the node.

    string getName ( ) #

    Returns the name of the node.

    Return value

    Name of the node.

    int isNavigation ( ) #

    Returns a value indicating if a given node is a navigation node.

    Return value

    1 if the given node is a navigation node; otherwise, 0.

    int getNumAncestors ( ) #

    Returns the number of ancestors of the node.

    Return value

    Number of ancestors.

    int getNumChildren ( ) #

    Returns the number of children of the node.

    Return value

    Number of child nodes.

    int isObject ( ) #

    Returns a value indicating if the node is an object node (its type is NODE_OBJECT_*).

    Return value

    1 if the node is an object node; otherwise, 0.

    Body getObjectBody ( ) #

    Returns a physical body assigned to the node if it is an object node.

    Return value

    Body assigned to the object node; otherwise, NULL (0).

    BodyRigid getObjectBodyRigid ( ) #

    Returns a rigid body assigned to the node if it is an object node.

    Return value

    Rigid body assigned to the object node; otherwise, NULL (0).

    int isObstacle ( ) #

    Returns a value indicating if the node is an obstacle node (its type is NODE_OBSTACLE_*).

    Return value

    1 if the given node is an obstacle node; otherwise, 0.

    void setOldWorldTransform ( Mat4 transform ) #

    Sets old (previous frame) transformation matrix for the node in the world coordinates.

    Arguments

    • Mat4 transform - Old (previous frame) transformation matrix to be set.

    Mat4 getOldWorldTransform ( ) #

    Returns old (previous frame) transformation matrix for the node in the world coordinates.

    Return value

    Old (previous frame) transformation matrix.

    void setParent ( Node parent ) #

    Sets the new parent for the node. Transformations of the current node will be done in the coordinates of the parent.

    Arguments

    • Node parent - New parent node.

    Node getParent ( ) #

    Returns the parent of the node.

    Return value

    Parent node or NULL (0), if the node has no parent.

    int isPhysical ( ) #

    Returns a value indicating if the node is a physical node (its type is NODE_PHYSICAL_*).

    Return value

    1 if the node is a physical node; otherwise, 0.

    int isPlayer ( ) #

    Returns a value indicating if the node is a player node (its type is NODE_PLAYER_*).

    Return value

    1 if the node is a player node; otherwise, 0.

    void setPosition ( Vec3 pos ) #

    Sets the node position.

    Arguments

    • Vec3 pos - Node position in the local space

    Vec3 getPosition ( ) #

    Returns the node position.

    Return value

    Node position in the local space

    Node getPossessor ( ) #

    Returns a possessor of the node. The following nodes can be possessors:
    • NodeReference
    • WorldCluster
    • WorldClutter
    • WorldLayer
    Notice
    This function can only be applied to a root node inside a node reference.

    Return value

    Node posessor, if it exists; otherwise, NULL.

    int getNumProperties ( ) #

    Returns the total number of properties associated with the node.

    Return value

    Total number of properties associated with the node.

    int setProperty ( int num ) #

    Updates the node property with the specified number. A new internal property inherited from the one with the specified name will be set. Such internal properties are saved in a *.world or *.node file.

    Arguments

    Return value

    1 if the specified node property is updated successfully; otherwise, 0.

    void setPropertyEnabled ( int num, int enable ) #

    Enables or disables the node property with the specified number.

    Arguments

    • int num - Node property number in the range from 0 to the total number of node properties.
    • int enable - 1 to enable the specified node property, 0 to disable it.

    int isPropertyEnabled ( int num ) #

    Returns a value indicating if the node property with the specified number is enabled.

    Arguments

    Return value

    1 if the specified property is enabled; otherwise, 0.

    void swapProperty ( int from_num, int to_num ) #

    Swaps two properties with specified numbers in the list of properties associated with the node.
    Notice
    The order of properties in the list determines the execution sequence of logic of corresponding components (if any).

    Arguments

    void clearProperties ( ) #

    Clears the list of properties associated with the node.

    Property getProperty ( int num ) #

    Returns a node property with the specified number if it exists.

    Arguments

    Return value

    Node property.

    string getPropertyName ( int num ) #

    Returns the name of a node property with the specified number.

    Arguments

    Return value

    Property name, if exists; otherwise, NULL.

    void setQuery ( int query ) #

    Updates a value indicating if occlusion query is used for the node.

    Arguments

    • int query - 1 to use occlusion query, 0 not to use.

    int isQuery ( ) #

    Returns a value indicating if occlusion query is used for the node. The default is 0 (not used).

    Return value

    1 if occlusion query is used; otherwise, 0.

    Node getRootNode ( ) #

    Returns the root node for the node. This method searches for the root node among all node's parents and posessors up the hierarchy. If a node does not have a parent or posessor the node itself will be returned.

    Return value

    Root node for the node.

    void setRotation ( quat rot, int identity = 0 ) #

    Sets the node rotation.

    Arguments

    • quat rot - Quaternion representing node rotation in the local space.
    • int identity - Flag indicating if node's scale is to be ignored or taken into account:
      • 0 - node's scale is taken into account. In this case additional calculations are performed to extract current node's scale and apply it when building the final transformation matrix. These additional operations reduce performance and may lead to error accumulation.
      • 1 - node's scale is ignored (assumed to be equal to 1 along all axes). Thus, the number of calculations performed for each rotation is reduced and error accumulation is minimal.
      Notice
      • It is recommended to set this flag for all non-scaled nodes to improve performance and accuracy.
      • Scaling of nodes should be avoided whenever possible, as it requires addidional calculations and may lead to error accumulation.

    quat getRotation ( ) #

    Returns the node rotation.

    Return value

    Quaternion representing node rotation in the local space.

    void setWorldRotation ( quat rot, int identity = 0 ) #

    Sets the node rotation in the world space.

    Arguments

    • quat rot - Node rotation in the world space.
    • int identity - Flag indicating if node's scale is to be ignored or taken into account:
      • 0 - node's scale is taken into account. In this case additional calculations are performed to extract current node's scale and apply it when building the final transformation matrix. These additional operations reduce performance and may lead to error accumulation.
      • 1 - node's scale is ignored (assumed to be equal to 1 along all axes). Thus, the number of calculations performed for each rotation is reduced and error accumulation is minimal.
      Notice
      • It is recommended to set this flag for all non-scaled nodes to improve performance and accuracy.
      • Scaling of nodes should be avoided whenever possible, as it requires addidional calculations and may lead to error accumulation.

    quat getWorldRotation ( ) #

    Returns the node rotation in the world space.

    Return value

    Node rotation in the world space.

    void setScale ( vec3 s ) #

    Sets the scale of the node.
    Notice
    Scaling of nodes should be avoided whenever possible as it requires addidional calculations and may lead to error accumulation.

    Arguments

    • vec3 s - Node scale in the local space.

    vec3 getScale ( ) #

    Returns the scale of the node.

    Return value

    Node scale in the local space.

    int isSound ( ) #

    Returns a value indicating if the node is a sound node (its type is NODE_SOUND_*).

    Return value

    1 if the node is a sound node; otherwise, 0.true if the node is a sound node; otherwise, false.

    void setTransform ( Mat4 transform ) #

    Updates the transformation matrix of the node.

    Arguments

    • Mat4 transform - New transformation matrix.

    Mat4 getTransform ( ) #

    Returns the transformation matrix of the node.

    Return value

    Transformation matrix.

    int getType ( ) #

    Returns the type of the node.

    Return value

    One of the NODE_* pre-defined variables.

    int getTypeId ( string type ) #

    Returns the ID of a node type with a given name.

    Arguments

    • string type - Node type name.

    Return value

    Node type ID, if such type exists; otherwise, -1.

    string getTypeName ( ) #

    Returns a name of the node type.

    Return value

    Node type name.

    string getTypeName ( int type ) #

    Returns the name of a node type with a given ID.

    Arguments

    • int type - Node type ID.

    Return value

    Node type name.

    void setVariable ( string name, Variable v ) #

    Sets the value of a variable with a given name. If such variable does not exist it will be added with a specified value.
    Source code (UnigineScript)
    NodeDummy container = new NodeDummy();
    if(container.hasVariable("key1") == 0) {
    	container.setVariable("key1",42);
    }
    int value = container.getVariable("key1");
    container.removeVariable("key1");

    Arguments

    • string name - Variable name.
    • Variable v - Variable value.

    void setVariable ( Variable v ) #

    Sets the value of the single unnamed variable parameter of the node. If this variable does not exist it will be created with a specified value.

    Arguments

    • Variable v - Variable value.

    Variable getVariable ( string name ) #

    Returns the variable with a given name.
    Source code (UnigineScript)
    NodeDummy container = new NodeDummy();
    if(container.hasVariable("key1") == 0) {
    	container.setVariable("key1",42);
    }
    int value = container.getVariable("key1");
    container.removeVariable("key1");

    Arguments

    • string name - Variable name.

    Return value

    Variable if it exists; otherwise, variable with 0 value.

    Variable getVariable ( ) #

    Returns the single unnamed variable parameter of the node.

    Return value

    Variable if it exists; otherwise, variable with 0 value.

    int isWorld ( ) #

    Returns a value indicating if the node is a world node (its type is NODE_WORLD_*).

    Return value

    1 if the node is a world node; otherwise, 0.

    WorldBoundBox getWorldBoundBox ( ) #

    Returns the bounding box of the node in world's coordinate system.
    Notice
    If the double precision build is used, the function will return an instance of the WorldBoundBox class.

    Return value

    World bounding box.

    WorldBoundSphere getWorldBoundSphere ( ) #

    Returns the bounding sphere of the node in world's coordinate system.
    Notice
    If the double precision build is used, the function will return an instance of the WorldBoundSphere class.

    Return value

    World bounding sphere.

    void setWorldParent ( Node n ) #

    Sets the new parent of the node. Transformations of the current node will be done in the world coordinates.

    Arguments

    • Node n - New parent node.

    void setWorldPosition ( Vec3 pos ) #

    Sets the node position in the world coordinates.

    Arguments

    • Vec3 pos

    Vec3 getWorldPosition ( ) #

    Returns the node position in the world coordinates.

    Return value

    Node position in the world space.

    void setWorldScale ( vec3 s ) #

    Sets the node scale in the world space.
    Notice
    Scaling of nodes should be avoided whenever possible as it requires addidional calculations and may lead to error accumulation.

    Arguments

    • vec3 s - Node scale in the world space.

    vec3 getWorldScale ( ) #

    Returns the node scale in the world space.

    Return value

    Node scale in the world space.

    void setWorldTransform ( Mat4 transform ) #

    Sets the transformation matrix for the node in the world coordinates.

    Arguments

    • Mat4 transform - Transformation matrix.

    Mat4 getWorldTransform ( ) #

    Returns the transformation matrix of the node in the world coordinates.

    Return value

    Transformation matrix.

    vec3 getBodyWorldVelocity ( Vec3 point ) #

    Returns linear velocity of a point of the node's physical body in the world space.

    Arguments

    • Vec3 point - Target point.

    Return value

    Linear velocity in the world space.

    void addChild ( Node n ) #

    Adds a child to the node. Transformations of the new child will be done in the coordinates of the parent.

    Arguments

    • Node n - New child node.

    void addWorldChild ( Node n ) #

    Adds a child to the node. Transformations of the new child will be done in the world coordinates.

    Arguments

    • Node n - New child node.

    clone ( ) #

    Clones the node.

    Return value

    Copy of the node or NULL (0), if an error occurred.

    int findChild ( string name ) #

    Searches for a child node with a given name among the children of the node.

    Arguments

    • string name - Name of the child node.

    Return value

    Child node number, if it is found; otherwise, -1.

    Node findNode ( string name, int recursive = 0 ) #

    Searches for a node with a given name among the children of the node.

    Arguments

    • string name - Name of the child node.
    • int recursive - 1 if the search is recursive (i.e. performed for children of child nodes); otherwise, 0.

    Return value

    Child node, if it is found; otherwise, NULL.

    int hasVariable ( string name ) #

    Returns a value indicating if the node has a variable parameter with a given name.
    Source code (UnigineScript)
    NodeDummy container = new NodeDummy();
    if(container.hasVariable("key1") == 0) {
    	container.setVariable("key1",42);
    }
    int value = container.getVariable("key1");
    container.removeVariable("key1");

    Arguments

    • string name - Variable name.

    Return value

    1 if the node has a variable parameter with a given name; otherwise, 0.

    int hasVariable ( ) #

    Returns a value indicating if the node has a single unnamed variable parameter.

    Return value

    1 if the node has a single unnamed variable parameter; otherwise, 0.

    int loadWorld ( Xml xml ) #

    Loads a node state from the Xml.

    Arguments

    • Xml xml - Xml smart pointer.

    Return value

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

    void removeChild ( Node n ) #

    Removes a child node (added by the addChild() method) from the list of children.

    Arguments

    • Node n - Child node to remove.

    int removeVariable ( string name ) #

    Removes a variable parameter with a given name.
    Source code (UnigineScript)
    NodeDummy container = new NodeDummy();
    if(container.hasVariable("key1") == 0) {
    	container.setVariable("key1",42);
    }
    int value = container.getVariable("key1");
    container.removeVariable("key1");

    Arguments

    • string name - Variable parameter name.

    Return value

    1 if the variable parameter is removed successfully; otherwise, 0.

    void removeWorldChild ( Node n ) #

    Removes a child node (added by the addWorldChild() method) from the list of children.

    Arguments

    • Node n - Child node to remove.

    void renderVisualizer ( ) #

    Renders a bounding box / sphere of the object.
    Notice
    You should enable the engine visualizer by the show_visualizer 1 console command.

    int restoreState ( Stream stream ) #

    Restores the state of a given node from a binary stream.
    • If a node is a parent for other nodes, states of these child nodes need to be restored manually.
    • To save the state into a buffer, file or a message from a socket, make sure the stream is opened. If necessary, you can set a position for writing for buffers and files.
    Warning
    This function is deprecated and will be removed in the next release.

    Arguments

    • Stream stream - Stream with saved node state data.

    Return value

    1 if node state is successfully restored; otherwise, 0.

    int saveState ( Stream stream ) #

    Saves the state of a given node into a binary stream.
    • If a node is a parent for other nodes, states of these child nodes need to be saved manually.
    • To save the state from a buffer, file or a message from a socket, make sure the stream is opened. For buffers and files, you also need to set the proper position for reading.
    Warning
    This function is deprecated and will be removed in the next release.

    Arguments

    • Stream stream - Stream to save node state data.

    Return value

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

    int saveWorld ( Xml xml ) #

    Saves the node into the Xml.

    Arguments

    • Xml xml - Xml smart pointer.

    Return value

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

    void swap ( Node n ) #

    Swaps the nodes saving the pointers.

    Arguments

    • Node n - Node to swap.

    vec3 toLocal ( Vec3 p ) #

    Converts a given vector in the world space to the node's local space.

    Arguments

    • Vec3 p - Vector in the world space.

    Return value

    Vector in the local space.

    Vec3 toWorld ( vec3 p ) #

    Converts a given vector in the local space to the world space.

    Arguments

    • vec3 p - Vector in the local space.

    Return value

    Vector in the world space.

    void translate ( Vec3 t ) #

    Translates the node relative to its local coordinate system: the parent node transformation isn't taken into account.

    Arguments

    • Vec3 t - Translation vector.

    void translate ( scalar x, scalar y, scalar z ) #

    Translates the node relative to its local coordinate system: the parent node transformation isn't taken into account.

    Arguments

    • scalar x - Node translation along the X axis, in units.
    • scalar y - Node translation along the Y axis, in units.
    • scalar z - Node translation along the Z axis, in units.

    void worldTranslate ( Vec3 t ) #

    Translates the node in the world space using the specified vector.

    Arguments

    • Vec3 t - Translation vector.

    void worldTranslate ( scalar x, scalar y, scalar z ) #

    Translates the node in the world space using the values specified for the corresponding axes.

    Arguments

    • scalar x - Node translation along the X axis, in units.
    • scalar y - Node translation along the Y axis, in units.
    • scalar z - Node translation along the Z axis, in units.

    void worldLookAt ( ) #

    Reorients the node to "look" at the target point and sets the given up vector:
    • If the node is a Player-related one, it will "look" at the target point along the negative Z axis. The Y axis will be oriented along the specified up vector.
    • Other nodes will "look" at the target point along the Y axis. The Z axis will be oriented along the specified up vector.

    Arguments

      void worldLookAt ( ) #

      Reorients the node to "look" at the target point. The up vector is oriented along the Z axis.
      • If the node is a Player-related one, it will "look" at the target point along the negative Z axis. The Y axis will be oriented along the world Z axis.
      • Other nodes will "look" at the target point along the Y axis.

      Arguments

        void rotate ( quat r ) #

        Rotates the node relative to its local coordinate system: the parent node transformation isn't taken into account. Rotation is determined by the specified quaternion.

        Arguments

        • quat r - Rotation quaternion.

        void rotate ( float angle_x, float angle_y, float angle_z ) #

        Rotates the node in the world space according to specified Euler angles.

        Arguments

        • float angle_x - Pitch angle, in degrees.
        • float angle_y - Roll angle, in degrees.
        • float angle_z - Yaw angle, in degrees.

        void worldRotate ( quat r ) #

        Rotates the node in the world space. Rotation is determined by the specified quaternion.

        Arguments

        • quat r - Rotation quaternion.

        void worldRotate ( float angle_x, float angle_y, float angle_z ) #

        Rotates the node in the world space according to specified Euler angles.

        Arguments

        • float angle_x - Pitch angle, in degrees.
        • float angle_y - Roll angle, in degrees.
        • float angle_z - Yaw angle, in degrees.

        void setDirection ( ) #

        Updates the direction vector of the node and reorients this node: the specified axis of the node becomes oriented along the specified vector in local coordinates. For example, after running the code below, you will get the X axis of the node pointed along the Y axis in local coordinates.
        Source code (UnigineScript)
        // get the node
        Node node = engine.world.getNodeByName("material_ball");
        // set the X axis to be pointed along the Y axis in local coordinates
        node.setDirection(vec3(0.0f,1.0f,0.0f),vec3(0.0f,0.0f,1.0f),AXIS_X);

        Arguments

          getDirection ( ) #

          Returns the normalized direction vector pointing along the given node axis in local coordinates (i.e. relative to the node's parent). By default, the direction vector pointing along the negative Z axis of the node (in local coordinates) is returned. The direction vector always has a unit length.
          Source code (UnigineScript)
          node.getDirection(node.isPlayer() ? AXIS_NZ : AXIS_Y); // forward direction vector
          node.getDirection(node.isPlayer() ? AXIS_Z : AXIS_NY); // backward direction vector
          node.getDirection(node.isPlayer() ? AXIS_Y : AXIS_Z); // upward direction vector
          node.getDirection(node.isPlayer() ? AXIS_NY : AXIS_NZ); // down direction vector
          node.getDirection(AXIS_X); // right direction vector
          node.getDirection(AXIS_NX); // left direction vector

          Arguments

            Return value

            Direction vector in local coordinates.

            void setWorldDirection ( ) #

            Updates the direction vector of the node and reorients this node: the specified axis of the node becomes oriented along the specified vector in world coordinates. For example, after running the code below, you will get the X axis of the node pointed along the Y axis in world coordinates:
            Source code (UnigineScript)
            // get the node
            Node node = engine.world.getNodeByName("material_ball");
            // set the X axis to be pointed along the Y axis in world coordinates
            node.setWorldDirection(vec3(0.0f,1.0f,0.0f),vec3(0.0f,0.0f,1.0f),AXIS_X);

            Arguments

              getWorldDirection ( ) #

              Returns the normalized direction vector pointing along the given node axis in world coordinates. By default, the direction vector pointing along the negative Z axis of the node is returned. The direction vector always has a unit length.
              Source code (UnigineScript)
              node.getWorldDirection(node.isPlayer() ? AXIS_NZ : AXIS_Y); // forward direction vector
              node.getWorldDirection(node.isPlayer() ? AXIS_Z : AXIS_NY); // backward direction vector
              node.getWorldDirection(node.isPlayer() ? AXIS_Y : AXIS_Z); // upward direction vector
              node.getWorldDirection(node.isPlayer() ? AXIS_NY : AXIS_NZ); // down direction vector
              node.getWorldDirection(AXIS_X); // right direction vector
              node.getWorldDirection(AXIS_NX); // left direction vector

              Arguments

                Return value

                Direction vector in world coordinates.

                Node getCloneNode ( Node original_node ) #

                Returns a node cloned from the specified original node.
                Notice
                This method is intended for use only inside the node clone callback.

                Arguments

                • Node original_node - Original node that was cloned.

                Return value

                Clone of the specified original node if it exists; otherwise the original node itself.

                Property getCloneProperty ( Property original_property ) #

                Returns a node property cloned from the specified original property.
                Notice
                This method is intended for use only inside the node clone callback.

                Arguments

                • Property original_property - Original node property that was cloned.

                Return value

                Clone of the specified original node property if it exists; otherwise the original node property itself.

                void setSaveToWorldEnabled ( int enabled ) #

                Sets a value indicating if saving to *.world file is enabled for the node.
                Notice
                The node shall be saved to a *.world file only if this option is enabled for all of its ancestors as well.

                Arguments

                • int enabled - 1 to enable saving to *.world file for the node; 0 to disable.

                void setSaveToWorldEnabledRecursive ( int enable ) #

                Sets a value indicating if saving to *.world file is enabled for the node and all its children (if any).

                Arguments

                • int enable - 1 to enable saving to *.world file for the node and all its children (if any); 0 to disable.

                int isSaveToWorldEnabled ( ) #

                Returns a value indicating if saving to *.world file is enabled for the node and all of its ancestors (if any).

                Return value

                1 if saving to *.world file is enabled for the node and all of its ancestors (if any); otherwise, 0.

                int isSaveToWorldEnabledSelf ( ) #

                Returns a value indicating if saving to *.world file is enabled for the node.
                Notice
                The node shall be saved to a *.world file only if this option is enabled for all of its ancestors as well (see the isSaveToWorldEnabled() method).

                Return value

                1 if saving to *.world file is enabled for the node; otherwise, 0.

                void setShowInEditorEnabled ( int enabled ) #

                Sets a value indicating if displaying in the World Hierarchy window of the UnigineEditor is enabled for the node.
                Notice
                The node shall be displayed in the hierarchy only if this option is enabled for all of its ancestors as well.

                Arguments

                • int enabled - 1 to enable displaying in the World Hierarchy window of the UnigineEditor for the node; 0 to disable.

                void setShowInEditorEnabledRecursive ( int enable ) #

                Sets a value indicating if displaying in the World Hierarchy window of the UnigineEditor is enabled for the node and all its children (if any).

                Arguments

                • int enable - 1 to enable displaying in the World Hierarchy window of the UnigineEditor for the node and all its children (if any); 0 to disable.

                int isShowInEditorEnabled ( ) #

                Returns a value indicating if displaying in the World Hierarchy window of the UnigineEditor is enabled for the node and all of its ancestors (if any).

                Return value

                1 if displaying in the World Hierarchy window of the UnigineEditor is enabled for the node and all of its ancestors (if any); otherwise, 0.

                int isShowInEditorEnabledSelf ( ) #

                Returns a value indicating if displaying in the World Hierarchy window of the UnigineEditor is enabled for the node.
                Notice
                The node shall be displayed only if this option is enabled for all of its ancestors as well (see the isShowInEditorEnabled() method).

                Return value

                1 if displaying in the World Hierarchy window of the UnigineEditor is enabled for the node; otherwise, 0.

                int getLifetime ( ) #

                Returns the lifetime management type for the root (either parent or posessor) of the node, or for the node itself (if it is not a child and not possessed by any other node).
                Notice
                Lifetime of each node in the hierarchy is defined by it's root (either parent or posessor). Thus, lifetime management type set for a child node that differs from the one set for the root is ignored.

                Return value

                One of the NODE_LIFETIME_* values.

                void setLifetime ( int lifetime ) #

                Arguments

                • int lifetime

                WorldBoundBox getSpatialBoundBox ( ) #

                Returns a bounding box with world coordinates that participates in physics calculations, but doesn't take children into account. This bounding box is used by the spatial tree.

                Return value

                The bounding box with world coordinates.

                WorldBoundSphere getSpatialBoundSphere ( ) #

                Returns a bounding sphere with world coordinates that participates in physics calculations, but doesn't take children into account. This bounding sphere is used by the spatial tree.

                Return value

                The bounding sphere with world coordinates.

                BoundBox getHierarchyBoundBox ( ) #

                Returns a bounding box with local coordinates that takes children into account, but doesn't participate in physics calculations. Exclusion of objects from the spatial tree significantly reduces the size of the tree and improves performance due to saving time on bounding box recalculation when transforming nodes.

                Return value

                The bounding box with local coordinates.

                BoundSphere getHierarchyBoundSphere ( ) #

                Returns a bounding sphere with local coordinates that takes children into account, but doesn't participate in physics calculations. Exclusion of objects from the spatial tree significantly reduces the size of the tree and improves performance due to saving time on bounding sphere recalculation when transforming nodes.

                Return value

                The bounding sphere with local coordinates.

                WorldBoundBox getHierarchyWorldBoundBox ( ) #

                Returns a bounding box with world coordinates that takes children into account, but doesn't participate in physics calculations. Exclusion of objects from the spatial tree significantly reduces the size of the tree and improves performance due to saving time on bounding box recalculation when transforming nodes.

                Return value

                The bounding box with world coordinates.

                WorldBoundSphere getHierarchyWorldBoundSphere ( ) #

                Returns a bounding sphere with world coordinates that takes children into account, but doesn't participate in physics calculations. Exclusion of objects from the spatial tree significantly reduces the size of the tree and improves performance due to saving time on bounding sphere recalculation when transforming nodes.

                Return value

                The bounding sphere with world coordinates.

                WorldBoundBox getHierarchySpatialBoundBox ( ) #

                Returns a bounding box with world coordinates that takes all children and physics into account. This bounding box is used by the spatial tree.

                Return value

                The bounding box with world coordinates.

                WorldBoundSphere getHierarchySpatialBoundSphere ( ) #

                Returns a bounding sphere with world coordinates that takes all children and physics into account. This bounding sphere is used by the spatial tree.

                Return value

                The bounding sphere with world coordinates.

                int getNumWorldTriggers ( ) #

                Returns the number of World Triggers inside which the node is located at the moment. To access any of such triggers by its number simply call the getWorldTrigger() method.

                Return value

                The number of World Triggers inside which the node is located at the moment, or 0 if the node is not currently inside any World Trigger.

                WorldTrigger getWorldTrigger ( int num ) #

                Returns one of the World Triggers inside which the node is located at the moment by its number. For any node in the world, you can check whether it is currently inside any World Trigger and access any of such triggers by simply calling this method.

                Arguments

                • int num - Number of the World Trigger in the list of World Triggers inside which the node is located at the moment.

                Return value

                World Trigger with the specified number inside which the node is located at the moment.
                Last update: 2020-06-01
                Build: ()