This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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.

Unigine::Node Class

Header: #include <UnigineNode.h>

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 obtain the node via automatic upcasting

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. Get the node via upcasting.
Source code (C++)
// AppWorldLogic.cpp
			
#include "AppWorldLogic.h"
#include <UnigineNode.h>
#include <UnigineObjects.h>

using namespace Unigine;
using namespace Math;

int AppWorldLogic::init() {

	// create a mesh
	MeshPtr mesh = Mesh::create();
	mesh->addBoxSurface("box_0",vec3(1.0f));
	// declare a smart pointer for any type of the node inherited from the Node class (e.g. ObjectMeshStatic)
	// and call a constructor of the corresponding class
	ObjectMeshStaticPtr object_mesh = ObjectMeshStatic::create(mesh);

	// declare a smart pointer for the node
	// and obtain the node pointer from the created ObjectMeshStatic
	NodePtr node = object_mesh;

	return 1;
}

Now you can operate the ObjectMeshStatic instance as a node.

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 save to the .world file 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. Get the node from the ObjectMeshStatic instance via upcasting.
  5. Enable saving to .world file for the node (and all its children).
  6. Edit the node and save the world by calling the world_saveconsole command.
Source code (C++)
#include "AppWorldLogic.h"

#include <UnigineNode.h>
#include <UnigineObjects.h>
#include <UnigineWorld.h>
#include <UnigineConsole.h>

using namespace Unigine;
using namespace Math;

int AppWorldLogic::init() {

	// create a mesh
	MeshPtr mesh = Mesh::create();
	mesh->addBoxSurface("box_0",vec3(1.0f));
	// save a mesh into a file on the disk
	mesh->save("unigine_project/meshes/my_mesh.mesh");
	// declare a smart pointer for any type of the node inherited from the Node class (e.g. ObjectMeshStatic)
	// and call a constructor of the corresponding class create an instance of any class inherited from the Node class (e.g. ObjectMeshStatic)
	ObjectMeshStaticPtr object_mesh = ObjectMeshStatic::create("unigine_project/meshes/my_mesh.mesh");

	// declare a smart pointer for the node,
	// obtain the node pointer from the created ObjectMeshStatic,
	NodePtr node = object_mesh;
	
	// enable saving the node(and all its children) to a .world file
	node->setSaveToWorldEnabledRecursive(true);

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

	// save node changes in the .world file
	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. Get the node from the ObjectMeshStatic instance via upcasting.
  5. Export the node to an external .node file.
  6. Import the prevoiusly exported node to check the result.
Source code (C++)
#include "AppWorldLogic.h"

#include <UnigineNode.h>
#include <UnigineObjects.h>
#include <UnigineWorld.h>
#include <UnigineEditor.h>
#include <UnigineConsole.h>

using namespace Unigine;
using namespace Math;

int AppWorldLogic::init() {

	// create a mesh
	MeshPtr mesh = Mesh::create();
	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)
	ObjectMeshStaticPtr object_mesh = ObjectMeshStatic::create("unigine_project/meshes/my_mesh.mesh");
	// declare a smart pointer for the node
	// and obtain the node pointer from the created NodeDummy
	NodePtr node = object_mesh;
	// export the node into a .node file
	World::saveNode("unigine_project/nodes/my_node.node", node);
	// import the exported node to check the result
	NodePtr imported_node = World::loadNode("unigine_project/nodes/my_node.node");
	// set 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 (C++)
// AppWorldLogic.cpp

#include <UnigineNode.h>
#include <UnigineObjects.h>
#include <UnigineWorld.h>
#include <UnigineEditor.h>
#include <UnigineConsole.h>

using namespace Unigine;
using namespace Math;

int AppWorldLogic::init() {
	
	// create a mesh
	MeshPtr mesh = Mesh::create();
	mesh->addBoxSurface("box_0", vec3(1.0f));
	// create an instance of any class inherited from the Node class (e.g. ObjectMeshStatic)
	ObjectMeshStaticPtr object_mesh = ObjectMeshStatic::create(mesh);
						// declare a smart pointer for the node
	// and obtain the node pointer from the created NodeDummy
	NodePtr node = object_mesh;
					
	// do something with the node
	// ...

	// delete the node
	node.deleteLater();

	return 1;
}

Node Class

Enums

CALLBACK_INDEX#

NameDescription
CALLBACK_PROPERTY_NODE_SLOTS_CHANGED = 0Callback to be fired on changing the number of node's property slots. Callback function signature is as follows:
void Func(NodePtr node, int num);
CALLBACK_PROPERTY_NODE_ADD = 1Node property added callback. This callback is fired when a new property is assigned to the node.
CALLBACK_PROPERTY_NODE_SWAP = 2Node property swapped callback. This callback is fired when two properties swap their positions in the list of node's properties.
CALLBACK_PROPERTY_NODE_REMOVE = 3Node property removed callback. This callback is fired when a property is removed from the list of node's properties.
CALLBACK_PROPERTY_CHANGE_ENABLED = 4Callback to be fired on changing node's property enabled state. Callback function signature is as follows:
void Func(NodePtr node, PropertyPtr prop, int prop_num);
CALLBACK_PROPERTY_SURFACE_ADD = 5Surface property added callback. This callback is fired when a property is assigned to object's surface.
CALLBACK_PROPERTY_SURFACE_REMOVE = 6Surface property removed callback. This callback is fired when a property is removed from object's surface.
CALLBACK_CACHE_NODE_ADD = 7Callback to be fired on adding a node to cache. Occurs once upon calling NodeReference::create() or World::loadNode() :
Source code (C++)
NodeReference::create(“path.node”);
// or
World::loadNode(“path.node”, 1 /* cache */);
Callback function signature is as follows:
void Func(NodePtr node), where node - is a node added to cache.
Notice
Fired only for the root node. If a nested node reference is loaded, the callback shall be fired for the node at the top of the hierarchy only, the one created by the user.
CALLBACK_NODE_LOAD = 8Callback to be fired on loading a node from a file. Callback function signature is as follows:
void Func(NodePtr node);
CALLBACK_NODE_CLONE = 9Callback to be fired on copying a node via Node::clone():
Source code (C++)
node->clone();
Callback function signature is as follows:
void Func(NodePtr node_clone, NodePtr node_original), where node - is a node added to cache.
Notice
Fired only for the root node.
CALLBACK_NODE_SWAP = 10Callback to be fired on swapping a node via Node::clone():
Source code (C++)
node->swap();
Callback function signature is as follows:
void Func(NodePtr node_clone, NodePtr node_original), where node - is a node added to cache.
Notice
Fired only for the root node.
CALLBACK_NODE_REMOVE = 11Callback to be fired on deleting a node. Callback function signature is as follows:
void Func(NodePtr node);
Notice
Fired for each deleted node.
CALLBACK_NODE_CHANGE_ENABLED = 12Callback to be fired on changing node's enabled state. Callback function signature is as follows:
void Func(NodePtr node);
Notice
Fired for each node that has changed its enabled state. Changing the state of the root node, causes the callback to be fired for all its children as well.

TYPE#

NameDescription
ANY_TYPE = -1Any node type.
NODE_BEGIN = 0Begin of the nodes range.
NODE_DUMMY = 0Dummy node. See the NodeDummy class.
NODE_LAYER = 1Layer node. See the NodeLayer class.
NODE_TRIGGER = 2Node trigger. See the NodeTrigger class.
NODE_REFERENCE = 3Node reference. See the NodeReference class.
NODE_EXTERN = 4Extern node. See the NodeExtern class.
NODE_END = 4End of the nodes range.
WORLD_BEGIN = 5Begin of the world nodes range.
WORLD_SPLINE_GRAPH = 5World spline graph. See the WorldSplineGraph class.
WORLD_TRIGGER = 6World trigger. See the WorldTrigger class.
WORLD_CLUTTER = 7World clutter. See the WorldClutter class.
WORLD_SWITCHER = 8Node switcher (to switch off parts of the world). See the WorldSwitcher class.
WORLD_OCCLUDER = 9World occluder. See the WorldOccluder class.
WORLD_OCCLUDER_MESH = 10World mesh occluder. See the WorldOccluderMesh class.
WORLD_TRANSFORM_PATH = 11Path defined transformer. See the WorldTransformPath
WORLD_TRANSFORM_BONE = 12Bone defined transformer. See the WorldTransformBone class.
WORLD_EXPRESSION = 13Node which allows to execute arbitrary expression. See the WorldExpression class.
WORLD_EXTERN = 14External world. See the WorldExtern class.
WORLD_END = 14End of the world nodes range.
GEODETIC_BEGIN = 15Begin of the geodetic nodes range.
GEODETIC_PIVOT = 15Geodetic Pivot node. See the GeodeticPivot class.
GEODETIC_END = 15End of the geodetic nodes range.
FIELD_BEGIN = 16Begin of the field nodes range.
FIELD_SPACER = 16Field Spacer node. See the FieldSpacer class.
FIELD_ANIMATION = 17Field Animation node. See the FieldAnimation class.
FIELD_HEIGHT = 18Field Height node. See the FieldHeight class.
FIELD_SHORELINE = 19Field Shoreline node. See the FieldShoreline class.
FIELD_WEATHER = 20Field Weather node. See the FieldWeather class.
FIELD_END = 20End of the field nodes range.
LIGHT_BEGIN = 21Begin of the light nodes range.
LIGHT_VOXEL_PROBE = 21Voxel probe. See the LightVoxelProbe class.
LIGHT_ENVIRONMENT_PROBE = 22Environment probe. See the LightEnvironmentProbe class.
LIGHT_PLANAR_PROBE = 23
LIGHT_OMNI = 24Omni-directional light source. See the LightOmni class.
LIGHT_PROJ = 25Projected light source. See the LightProj class.
LIGHT_WORLD = 26World light source. See the LightWorld class.
LIGHT_END = 26End of the light nodes range.
DECAL_BEGIN = 27Begin of the decal nodes range.
DECAL_PROJ = 27Projected decal node. See the DecalProj class.
DECAL_ORTHO = 28Orthographic decal node. See the DecalOrtho class.
DECAL_MESH = 29Mesh decal node. See the DecalMesh class.
DECAL_END = 29End of the decal nodes range.
LANDSCAPE_LAYER_BEGIN = 30Beginning of the landscape layers range.
LANDSCAPE_LAYER_MAP = 30Landscape Layer Map. See the LandscapeLayerMap class.
LANDSCAPE_LAYER_END = 30End of the landscape layers range.
OBJECT_BEGIN = 31Begin of the object nodes range.
OBJECT_DUMMY = 31Dummy object. See the ObjectDummy class.
OBJECT_DYNAMIC = 32Dynamic object. See the ObjectDynamic class.
OBJECT_MESH_STATIC = 33Static mesh object. See the ObjectMeshStatic class.
OBJECT_MESH_CLUSTER = 34Mesh Cluster object. See the ObjectMeshCluster class.
OBJECT_MESH_CLUTTER = 35Mesh Clutter object. See the ObjectMeshClutter class.
OBJECT_MESH_SKINNED = 36Skinned mesh object. See the ObjectMeshSkinned class.
OBJECT_MESH_DYNAMIC = 37Dynamic mesh object. See the ObjectMeshDynamic class.
OBJECT_MESH_SPLINE_CLUSTER = 38Mesh Spline Cluster object. See the ObjectMeshSplineCluster class.
OBJECT_TERRAIN_GLOBAL = 40Terrain global object. See the ObjectTerrainGlobal class.
OBJECT_GRASS = 41Grass. See the ObjectGrass class.
OBJECT_PARTICLES = 42Particles object. See the ObjectParticles class.
OBJECT_BILLBOARDS = 43Billboards object for rendering a high number of billboards. See the ObjectBillboard class.
OBJECT_VOLUME_BOX = 44Volume box object. See the ObjectVolumeBox class.
OBJECT_VOLUME_SPHERE = 45Volume sphere object. See the ObjectVolumeSphere class.
OBJECT_VOLUME_OMNI = 46Volume omni light object. See the ObjectVolumeOmni class.
OBJECT_VOLUME_PROJ = 47Volume projected light object. See the ObjectVolumeProj class.
OBJECT_GUI = 48GUI object. See the ObjectGui class.
OBJECT_GUI_MESH = 49GUI mesh object. See the ObjectGuiMesh class.
OBJECT_WATER_GLOBAL = 50Water global object. See the ObjectWaterGlobal class.
OBJECT_WATER_MESH = 51Water mesh object. See the ObjectWaterMesh class.
OBJECT_SKY = 52Sky object. See the ObjectSky class.
OBJECT_LANDSCAPE_TERRAIN = 39LandscapeTerrain object. See the ObjectLandscapeTerrain class.
OBJECT_CLOUD_LAYER = 53Cloud layer object. See the ObjectCloudLayer class.
OBJECT_EXTERN = 54Extern object. See the ObjectExtern class.
OBJECT_TEXT = 55Text object. See the ObjectText class.
OBJECT_END = 55End of the object nodes range.
PLAYER_BEGIN = 56Begin of the player nodes range.
PLAYER_DUMMY = 56Dummy player. See the PlayerDummy class.
PLAYER_SPECTATOR = 57Observing player. See the PlayerSpectator class.
PLAYER_PERSECUTOR = 58Persecuting player. See the PlayerPersecutor class.
PLAYER_ACTOR = 59Acting player. See the PlayerActor class.
PLAYER_END = 59End of the player nodes range.
PHYSICAL_BEGIN = 60Begin of the physical nodes range.
PHYSICAL_WIND = 60Physical wind object. See the PhysicalWind class.
PHYSICAL_FORCE = 61Physical force node that allows to simulate point forces applied to dynamic objects. See the PhysicalForce class.
PHYSICAL_NOISE = 62Physical noise node that allows to simulate force field. See the PhysicalNoise class.
PHYSICAL_WATER = 63Physical water object that has no visual representation. See the PhysicalWater class.
PHYSICAL_TRIGGER = 64Physical trigger. See the PhysicalTrigger class.
PHYSICAL_END = 64End of the physical nodes range.
NAVIGATION_BEGIN = 65Begin of the navigation nodes range.
NAVIGATION_SECTOR = 65Sector within which pathfinding is performed. See the NavigationSector class.
NAVIGATION_MESH = 66Mesh-based navigation area across which pathfinding is performed. See the NavigationMesh class.
NAVIGATION_END = 66End of the navigation nodes range.
OBSTACLE_BEGIN = 67Begin of the obstacle nodes range.
OBSTACLE_BOX = 67Obstacle in the shape of a box avoided by pathfinding. See the ObstacleBox class.
OBSTACLE_SPHERE = 68Obstacle in the shape of a sphere avoided by pathfinding. See the ObstacleSphere class.
OBSTACLE_CAPSULE = 69Obstacle in the shape of a capsule avoided by pathfinding. See the ObstacleCapsule class.
OBSTACLE_END = 69End of the obstacle nodes range.
SOUND_BEGIN = 70Begin of the sound nodes range.
SOUND_SOURCE = 70Sound source. See the SoundSource class.
SOUND_REVERB = 71Sound reverberation zone. See the SoundReverb class.
SOUND_END = 71End of the sound nodes range.
NUM_NODES = 72Counter of node types.
NUM_WORLDS = WORLD_END - WORLD_BEGIN + 1Counter of world node types.
NUM_GEODETICS = GEODETIC_END - GEODETIC_BEGIN + 1Counter of geodetic node types.
NUM_FIELDS = FIELD_END - FIELD_BEGIN + 1Counter of field node types.
NUM_LIGHTS = LIGHT_END - LIGHT_BEGIN + 1Counter of light node types.
NUM_DECALS = DECAL_END - DECAL_BEGIN + 1Counter of decal node types.
NUM_OBJECTS = OBJECT_END - OBJECT_BEGIN + 1Counter of object node types.
NUM_PLAYERS = PLAYER_END - PLAYER_BEGIN + 1Counter of player node types.
NUM_PHYSICALS = PHYSICAL_END - PHYSICAL_BEGIN + 1Counter of physical node types.
NUM_NAVIGATIONS = NAVIGATION_END - NAVIGATION_BEGIN + 1Counter of navigation node types.
NUM_OBSTACLES = OBSTACLE_BEGIN - OBSTACLE_END + 1Counter of obstacle node types.
NUM_SOUNDS = SOUND_END - SOUND_BEGIN + 1Counter of sound node types.
DUMMY = 0Dummy node. See the NodeDummy class.
LAYER = 1Node layer containing parent layer and all its child nodes. See the NodeLayer class.
TRIGGER = 2Dummy node that can fire callbacks on its enabling/disabling or repositioning. See the NodeTrigger class.
REFERENCE = 3Node that references an external NODE file. See the NodeReference class.
EXTERN = 4Extern node.

LIFETIME#

NameDescription
LIFETIME_WORLD = 0Node's lifetime is managed by the world. The node shall be deleted automatically on closing the world.
LIFETIME_ENGINE = 1Node's lifetime is managed by the Engine. The node shall be deleted automatically on Engine shutdown.
LIFETIME_MANUAL = 2Node's lifetime is managed by the user. The node should be deleted manually by the user.

Members


Ptr<Node> getAncestor ( int num ) #

Returns a node ancestor by its number.

Arguments

  • int num - Ancestor ID.

Return value

Ancestor node.

Math::vec3 getBodyAngularVelocity ( ) #

Returns the angular velocity of the node's physical body in the world 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.

Ptr<Node> getChild ( int num ) #

Returns a node child by its number.

Arguments

  • int num - Child ID.

Return value

Child node.

bool isChild ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<Node> & n - Node to check.

Return value

true if the given node is a child; otherwise, false.

void setChildIndex ( const Ptr<Node> & n, int index ) #

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

Arguments

  • const Ptr<Node> & n - Child node.
  • int index - Node index.

int getChildIndex ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<Node> & n - Child node.

Return value

Node index.

void setImmovable ( bool 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

  • bool immovable - true to mark the node as an immovable object; otherwise, false.

bool 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

true if the node is a clutter object; otherwise, false.

void setClutterInteractionEnabled ( bool 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

  • bool enabled

bool 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

true if interaction with World Clutters and Mesh Clutters is enabled; otherwise, false.

void setGrassInteractionEnabled ( bool 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

  • bool enabled - true to enable interaction with Grass nodes, false to disable it.

bool 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

true if interaction with Grass nodes is enabled; otherwise, false.

void setTriggerInteractionEnabled ( bool 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

  • bool enabled - 1 to enable interaction with World Triggers, 0 to disable it.

bool 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

true if interaction with WorldTrigger nodes is enabled; otherwise, false.

void setData ( const char * name, const char * data ) #

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 * name - String containing a key identifying user data to be stored in the *.node file.
    Notice
    The "editor_data" key is reserved for the UnigineEditor.
  • const char * data - New user data. Data can contain an XML formatted string.

const char * getData ( const char * name ) #

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.

Arguments

  • const char * name - String containing a key identifying user data stored in the *.node file.
    Notice
    The "editor_data" key is reserved for the UnigineEditor.

Return value

User string data. Data can be an xml formatted string.

bool isDecal ( ) const#

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

Return value

true if the node is a decal node; otherwise, false.

void setEnabled ( bool enabled ) #

Enables or disables the node.

Arguments

  • bool enabled - true to enable the node, false to disable it.

void updateEnabled ( ) #

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

bool isEnabled ( ) #

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

Return value

true if the node and its parent nodes are enabled; otherwise, false.

bool isEnabledSelf ( ) #

Returns a value indicating if the node is enabled.

Return value

true if the node is enabled; otherwise, false.

bool 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

true if the node is an extern node; otherwise, false.

bool isField ( ) #

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

Return value

true if the node is a field node; otherwise, false.

bool isGeodetic ( ) const#

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

Return value

true if the node is a geodetic-related node; otherwise, false.

Ptr<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 ( bool 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

  • bool handled

bool 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

true if the handle is shown; otherwise, false.

void getHierarchy ( Vector< Ptr<Node> > & hierarchy ) #

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

Arguments

  • Vector< Ptr<Node> > & hierarchy - Hierarchy buffer.

void setID ( int id ) const#

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.

Math::Mat4 getIWorldTransform ( ) #

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

Return value

Inverse transformation matrix.

bool isLight ( ) const#

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

Return value

true if the node is a light source; otherwise, false.

bool isLandscapeLayer ( ) const#

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

Return value

true if the node is a landscape layer; otherwise, false.

Math::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 ( const char * name ) #

Sets a name for the node.

Arguments

  • const char * name - New name of the node.

const char * getName ( ) #

Returns the name of the node.

Return value

Name of the node.

bool isNavigation ( ) #

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

Return value

true if the given node is a navigation node; otherwise, false.

Ptr<Node> getNode ( int id ) #

Returns a node pointer.

Arguments

  • int id - Node identifier.

Return value

Node pointer.

int isNode ( const Ptr<Node> & node ) #

Check the node pointer.

Arguments

  • const Ptr<Node> & node - Node pointer.

Return value

1 if the node is valid; otherwise, 0.

int isNode ( int id ) #

Check the node pointer.

Arguments

  • int id - Node pointer.

Return value

1 if the node is valid; otherwise, 0.

int getNumAncestors ( ) const#

Returns the number of ancestors of the node.

Return value

Number of ancestors.

int getNumChildren ( ) const#

Returns the number of children of the node.

Return value

Number of child nodes.

bool isObject ( ) #

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

Return value

true if the node is an object node; otherwise, false.

Ptr<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).

Ptr<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).

bool isObstacle ( ) #

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

Return value

true if the given node is an obstacle node; otherwise, false.

void setOldWorldTransform ( const Math::Mat4 & transform ) #

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

Arguments

Math::Mat4 getOldWorldTransform ( ) #

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

Return value

Old (previous frame) transformation matrix.

Math::Vec3 getOldWorldPosition ( ) const#

Returns old (previous frame) position of the node in world coordinates.

Return value

Old (previous frame) position of the node.

void setParent ( const Ptr<Node> & parent ) #

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> & parent - New parent node or NULL (0).

Ptr<Node> getParent ( ) #

Returns the parent of the node.

Return value

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

bool isPhysical ( ) #

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

Return value

true if the node is a physical node; otherwise, false.

bool isPlayer ( ) #

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

Return value

true if the node is a player node; otherwise, false.

void setPosition ( const Math::Vec3 & pos ) #

Sets the node position.

Arguments

  • const Math::Vec3 & pos - Node position in the local space

Math::Vec3 getPosition ( ) #

Returns the node position.

Return value

Node position in the local space

Ptr<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 addProperty ( const char * name ) #

Inherits a new property from the one with the given name and adds it to the list of properties associated with the node. The inherited property will be internal, such properties are saved in a *.world or *.node file.

Arguments

  • const char * name - Name of the property to be added.

Return value

Index of the new node property if it was added successfully; otherwise, -1.

int addProperty ( const UGUID & guid ) #

Inherits a new property from the one with the given GUID and adds it to the list of properties associated with the node. The inherited property will be internal, such properties are saved in a *.world or *.node file.

Arguments

  • const UGUID & guid - GUID of the property to be added.

Return value

Index of the new node property if it was added successfully; otherwise, -1.

int addProperty ( const Ptr<Property> & property ) #

Inherits a new property from the specified one and adds it to the list of properties associated with the node. The inherited property will be internal, such properties are saved in a *.world or *.node file.

Arguments

Return value

Index of the new node property if it was added successfully; otherwise, -1.

int insertProperty ( int num, const char * name ) #

Inserts the property with the specified name at the specified position.

Arguments

  • int num - Position at which a new property is to be inserted, in the range from 0 to the total number of node properties.
  • const char * name - Name of the property to be inserted.

Return value

int insertProperty ( int num, const UGUID & guid ) #

Inserts the property with the specified GUID at the specified position.

Arguments

Return value

int insertProperty ( int num, const Ptr<Property> & property ) #

Inserts the specified property at the specified position.

Arguments

Return value

int setProperty ( const char * name ) #

Updates the first node property (the one with a 0 index) in the list of properties associated with the node. 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

  • const char * name - Name of the property to be set.

Return value

int setProperty ( const UGUID & guid ) #

Updates the first node property (the one with a 0 index) in the list of properties associated with the node. A new internal property inherited from the one with the specified GUID will be set. Such internal properties are saved in a *.world or *.node file.

Arguments

  • const UGUID & guid - GUID of the property to be set.

Return value

int setProperty ( const Ptr<Property> & property ) #

Updates the first node property (the one with a 0 index) in the list of properties associated with the node. A new internal property inherited from the one specified will be set. Such internal properties are saved in a *.world or *.node file.

Arguments

Return value

int setProperty ( int num, const char * name ) #

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

int setProperty ( int num, const UGUID & guid ) #

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

Arguments

Return value

int setProperty ( int num, const Ptr<Property> & property ) #

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

Arguments

Return value

void setPropertyEnabled ( int num, bool 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.
  • bool enable - true to enable the specified node property, false to disable it.

bool isPropertyEnabled ( int num ) #

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

Arguments

Return value

true if the specified property is enabled; otherwise, false.

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 removeProperty ( int num ) #

Removes the node property with the specified number.

Arguments

void removeProperty ( const char * name ) #

Removes the node property that has the specified name.
Notice
If several properties with the same name are associated with the node, only the first one will be removed.

Arguments

  • const char * name - Name of the node property to be removed.

void removeProperty ( const UGUID & guid ) #

Removes the node property that has the GUID or parent GUID equal to the specified one.
Notice
If several such properties are associated with the node, only the first one will be removed.

Arguments

  • const UGUID & guid - GUID of the property to be removed (or GUID of its parent).

void removeProperty ( const Ptr<Property> & property ) #

Removes the specified node property or a node property inherited from it.
Notice
If several such properties are associated with the node, only the first one will be removed.

Arguments

  • const Ptr<Property> & property - Node property to be removed.

void clearProperties ( ) #

Clears the list of properties associated with the node.

Ptr<Property> getProperty ( int num ) #

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

Arguments

Return value

Node property smart pointer, if exists; otherwise, NULL.

const char * getPropertyName ( int num ) #

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

Arguments

Return value

Property name, if exists; otherwise, NULL.

int findProperty ( const char * name ) #

Searches for a property with the specified name among the ones assigned to the node.

Arguments

  • const char * name - GUID of a node property to be found.

Return value

Node property number in the range from 0 to the total number of node properties if such a property exists; otherwise -1.

int findProperty ( const UGUID & guid ) #

Searches for a property with the specified GUID among the ones assigned to the node.

Arguments

  • const UGUID & guid - GUID of a node property to be found.

Return value

Node property number in the range from 0 to the total number of node properties if such a property exists; otherwise -1.

int findProperty ( const Ptr<Property> & property ) #

Searches for a specified property among the ones assigned to the node.

Arguments

  • const Ptr<Property> & property - Node property to be found.

Return value

Node property number in the range from 0 to the total number of node properties if such a property exists; otherwise -1.

void setQuery ( bool query ) #

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

Arguments

  • bool query - true to use occlusion query, false not to use.

bool isQuery ( ) #

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

Return value

true if occlusion query is used; otherwise, false.

bool hasQueryForce ( ) const#

Returns a value indicating if the Culled By Occlusion Query option is force-enabled for the node by the Engine.

Return value

true if the Culled By Occlusion Query option is force-enabled for the node by the Engine; otherwise, false.

Ptr<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 ( const Math::quat & rot, bool identity = 0 ) #

Sets the node rotation.

Arguments

  • const Math::quat & rot - Quaternion representing node rotation in the local space.
  • bool identity - Flag indicating if node's scale is to be ignored or taken into account:
    • false - 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.
    • true - 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.

Math::quat getRotation ( ) #

Returns the node rotation.

Return value

Quaternion representing node rotation in the local space.

void setWorldRotation ( const Math::quat & rot, bool identity = 0 ) #

Sets the node rotation in the world space.

Arguments

  • const Math::quat & rot - Node rotation in the world space.
  • bool identity - Flag indicating if node's scale is to be ignored or taken into account:
    • false - 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.
    • true - 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.

Math::quat getWorldRotation ( ) #

Returns the node rotation in the world space.

Return value

Node rotation in the world space.

void setScale ( const Math::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

  • const Math::vec3 & s - Node scale in the local space.

Math::vec3 getScale ( ) #

Returns the scale of the node.

Return value

Node scale in the local space.

bool isSound ( ) #

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

Return value

void setTransform ( const Math::Mat4 & transform ) #

Sets the transformation matrix for the node in local coordinates.

Arguments

  • const Math::Mat4 & transform - New transformation matrix to be set for the node (local coordinates).

void setTransformWithoutChildren ( const Math::Mat4 & transform ) #

Sets the transformation matrix for the node in local coordinates (transformations of all node's children are not affected). This method can be used to change node's transformation relative to its children.

Arguments

  • const Math::Mat4 & transform - New transformation matrix to be set for the node (local coordinates).

Math::Mat4 getTransform ( ) #

Returns the transformation matrix of the node in local coordinates.

Return value

Transformation matrix.

Node::TYPE getType ( ) const#

Returns the type of the node.

Return value

Node type identifier.

Node::TYPE getTypeId ( const char * type ) #

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

Arguments

  • const char * type - Node type name.

Return value

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

const char * getTypeName ( ) #

Returns a name of the node type.

Return value

Node type name.

const char * getTypeName ( Node::TYPE type ) const#

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

Arguments

Return value

Node type name.

void setVariable ( const char * name, const 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 (C++)
NodeDummyPtr container;
if(container->hasVariable("key1")) {
	container->setVariable("key1",42);
}
int value = container->getVariable("key1");
container->removeVariable("key1");

Arguments

  • const char * name - Variable name.
  • const Variable & v - Variable value.

void setVariable ( const 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 getVariable ( const char * name ) #

Returns the variable with a given name.
Source code (C++)
NodeDummyPtr container;
if(container->hasVariable("key1")) {
	container->setVariable("key1",42);
}
int value = container->getVariable("key1");
container->removeVariable("key1");

Arguments

  • const char * 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.

bool isWorld ( ) const#

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

Return value

true if the node is a world node; otherwise, false.

UNIGINE_BOUND_BOX getWorldBoundBox ( ) #

Returns the bounding box of the node in world's coordinate system.

Return value

World bounding box.

UNIGINE_BOUND_SPHERE getWorldBoundSphere ( ) #

Returns the bounding sphere of the node in world's coordinate system.

Return value

World bounding sphere.

void setWorldParent ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<Node> & n - New parent node or NULL (0).

void setWorldPosition ( const Math::Vec3 & pos ) #

Sets the node position in the world coordinates.

Arguments

  • const Math::Vec3 & pos

Math::Vec3 getWorldPosition ( ) #

Returns the node position in the world coordinates.

Return value

Node position in the world space.

void setWorldScale ( const Math::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

  • const Math::vec3 & s - Node scale in the world space.

Math::vec3 getWorldScale ( ) #

Returns the node scale in the world space.

Return value

Node scale in the world space.

void setWorldTransform ( const Math::Mat4 & transform ) #

Sets the transformation matrix for the node in world coordinates.

Arguments

  • const Math::Mat4 & transform - New transformation matrix to be set for the node (world coordinates).

void setWorldTransformWithoutChildren ( const Math::Mat4 & transform ) #

Sets the transformation matrix for the node in world coordinates (transformations of all node's children are not affected). This method can be used to change node's transformation relative to its children.

Arguments

  • const Math::Mat4 & transform - New transformation matrix to be set for the node (world coordinates).

Math::Mat4 getWorldTransform ( ) #

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

Return value

Transformation matrix.

Math::vec3 getBodyWorldVelocity ( const Math::Vec3 & point ) #

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

Arguments

  • const Math::Vec3 & point

Return value

Linear velocity in the world space.

void addChild ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<Node> & n - New child node.

void addWorldChild ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<Node> & n - New child node.

Ptr<Node> clone ( ) const#

Clones the node.

Return value

Cloned node.

int findAncestor ( int type ) #

Returns the ID of node's ancestor of a given type.

Arguments

  • int type - Ancestor type identifier. One of the NODE_* pre-defined variables.

Return value

Ancestor ID if it exists; otherwise -1.

int findAncestor ( const char * name ) #

Returns the ID of node's ancestor with a given name.

Arguments

  • const char * name - Ancestor name.

Return value

Ancestor ID if it exists; otherwise -1.

int findChild ( const char * name ) #

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

Arguments

  • const char * name - Name of the child node.

Return value

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

Ptr<Node> findNode ( const char * name, int recursive = 0 ) #

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

Arguments

  • const char * 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 ( const char * name ) #

Returns a value indicating if the node has a variable parameter with a given name.
Source code (C++)
NodeDummyPtr container;
if(container->hasVariable("key1")) {
	container->setVariable("key1",42);
}
int value = container->getVariable("key1");
container->removeVariable("key1");

Arguments

  • const char * 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.

bool loadWorld ( const Ptr<Xml> & xml ) #

Loads a node state from the Xml.

Arguments

  • const Ptr<Xml> & xml - Xml smart pointer.

Return value

void removeChild ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<Node> & n - Child node to remove.

void removeVariable ( const char * name ) #

Removes a variable parameter with a given name.
Source code (C++)
NodeDummyPtr container;
if(container->hasVariable("key1")) {
	container->setVariable("key1",42);
}
int value = container->getVariable("key1");
container->removeVariable("key1");

Arguments

  • const char * name - Variable parameter name.

Return value

void removeWorldChild ( const Ptr<Node> & n ) #

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

Arguments

  • const Ptr<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.

bool saveState ( const Ptr<Stream> & stream ) #

Saves a node state to a binary stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// initialize a node and set its state
NodeDummyPtr node = NodeDummy::create();
node->setPosition(vec3(1, 1, 0));

// save state
BlobPtr blob_state = Blob::create();
node->saveState(blob_state);

// change state
node->setPosition(vec3(0, 0, 0));

// restore state
blob_state->seekSet(0);		// returning the carriage to the start of the blob
node->restoreState(blob_state);

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

true if node state is successfully saved; otherwise, false.

bool restoreState ( const Ptr<Stream> & stream ) #

Restores a node state from a binary stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// initialize a node and set its state
NodeDummyPtr node = NodeDummy::create();
node->setPosition(vec3(1, 1, 0));

// save state
BlobPtr blob_state = Blob::create();
node->saveState(blob_state);

// change state
node->setPosition(vec3(0, 0, 0));

// restore state
blob_state->seekSet(0);    	// returning the carriage to the start of the blob
node->restoreState(blob_state);

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

true if node state is successfully restored; otherwise, false.

bool saveWorld ( const Ptr<Xml> & xml ) #

Saves the node into the Xml.

Arguments

  • const Ptr<Xml> & xml - Xml smart pointer.

Return value

true if the node is successfully saved; otherwise, false.

void swap ( const Ptr<Node> & n ) const#

Swaps two nodes.

Arguments

  • const Ptr<Node> & n - Node to swap.

Math::vec3 toLocal ( const Math::Vec3 & p ) #

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

Arguments

  • const Math::Vec3 & p - Vector in the world space.

Return value

Vector in the local space.

Math::Vec3 toWorld ( const Math::vec3 & p ) #

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

Arguments

  • const Math::vec3 & p - Vector in the local space.

Return value

Vector in the world space.

void translate ( const Math::Vec3 & t ) #

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

Arguments

  • const Math::Vec3 & t - Translation vector.

void translate ( Math::Scalar x, Math::Scalar y, Math::Scalar z ) #

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

Arguments

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

void worldTranslate ( const Math::Vec3 & t ) #

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

Arguments

  • const Math::Vec3 & t - Translation vector.

void worldTranslate ( Math::Scalar x, Math::Scalar y, Math::Scalar z ) #

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

Arguments

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

void worldLookAt ( const Math::Vec3 & target, const Math::vec3 & up ) #

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

  • const Math::Vec3 & target - Coordinates of the target point in the world space.
  • const Math::vec3 & up - Up vector of the node in the world space. By default, the up vector is oriented along the Z axis.

void worldLookAt ( const Math::Vec3 & target ) #

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

  • const Math::Vec3 & target - Coordinates of the target point in the world space.

void rotate ( const Math::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

  • const Math::quat & r - Rotation quaternion.

void rotate ( const Math::vec3 & angles ) #

Rotates the node in the local space. Rotation is determined by Euler angles passed as a vec3 vector.

Arguments

  • const Math::vec3 & angles

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 ( const Math::quat & r ) #

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

Arguments

  • const Math::quat & r - Rotation quaternion.

void worldRotate ( const Math::vec3 & angles ) #

Rotates the node in the world space. Rotation is determined by Euler angles passed as a vec3 vector.

Arguments

  • const Math::vec3 & angles - Vector containing Euler angles (Pitch, Yaw, Roll).

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 * addCallback ( CALLBACK_INDEX callback, Unigine::CallbackBase2< Ptr<Node>, Ptr<Property> > * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when adding or removing node and surface properties as well as when swapping node properties. The signature of the callback function must be as follows:
Source code (C++)
void callback_function_name(NodePtr node, PropertyPtr property);
Here is an example demonstrating how to track adding a node property via callbacks:
Source code (C++)
NodePtr node;

void node_property_added(NodePtr node, PropertyPtr property)
{
	Log::message("Property \"%s\" was added to the node named \"%s\".\n", property->getName(), node->getName());
    // ...
}

// somewhere in the code

// inheriting a new property named "my_prop" from the base property "node_base"
Properties::findManualProperty("node_base")->inherit("my_prop");

// setting our callback function on adding a node property
Node::addCallback(Node::CALLBACK_PROPERTY_NODE_ADD, MakeCallback(node_property_added));

// adding the property named "my_prop" to the node
node->addProperty("my_prop");

Arguments

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

void * addCallback ( CALLBACK_INDEX callback, Unigine::CallbackBase3< Ptr<Node>, Ptr<Property>, int > * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when adding or removing node and surface properties as well as when swapping node properties. The signature of the callback function must be as follows:
Source code (C++)
void callback_function_name(NodePtr node, PropertyPtr property, int arg3);

Arguments

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

void * addCallback ( CALLBACK_INDEX callback, Unigine::CallbackBase3< Ptr<Node>, int, int > * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when adding or removing node and surface properties as well as when swapping node properties. The signature of the callback function must be as follows:
Source code (C++)
void callback_function_name(NodePtr node, int arg2, int arg3);

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
  • Unigine::CallbackBase3< Ptr<Node>, int, int > * func - Callback pointer.

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeCallback ( CALLBACK_INDEX callback, void * id ) #

Removes the specified callback from the list of callbacks of the specified type. Callback functions can be used to determine actions to be performed when adding or removing node and surface properties as well as when swapping node properties.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
  • void * id - Callback ID obtained when adding it.

Return value

True if the callback of the specified type with the given ID was removed successfully; otherwise false.

void clearCallbacks ( CALLBACK_INDEX callback ) #

Clears all added callbacks of the specified type. Callback functions can be used to determine actions to be performed when adding or removing node and surface properties as well as when swapping node properties.

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.

void setDirection ( const Math::vec3 & dir, const Math::vec3 & up, MathLib::AXIS axis = AXIS_NZ ) #

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 (C++)
// get the node
NodePtr node = 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),Math::AXIS_X);

Arguments

  • const Math::vec3 & dir - New direction vector in local coordinates. The direction vector always has unit length.
  • const Math::vec3 & up - New up vector in local coordinates. If you skip this argument, the Z axis (in local coordinates) will be used. Note that the specified up vector is a hint vector only: the node's up vector points in the direction hinted by the specified up vector. The node's up vector matches the specified up vector (up) only if it is perpendicular to the specified direction vector (dir).
  • MathLib::AXIS axis - Axis along which the direction vector should be pointed. The default is the negative Z axis.

Math::vec3 getDirection ( MathLib::AXIS axis = AXIS_NZ ) #

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 (C++)
node->getDirection(node->isPlayer() ? Math::AXIS_NZ : Math::AXIS_Y); // forward direction vector
node->getDirection(node->isPlayer() ? Math::AXIS_Z : Math::AXIS_NY); // backward direction vector
node->getDirection(node->isPlayer() ? Math::AXIS_Y : Math::AXIS_Z); // upward direction vector
node->getDirection(node->isPlayer() ? Math::AXIS_NY : Math::AXIS_NZ); // down direction vector
node->getDirection(Math::AXIS_X); // right direction vector
node->getDirection(Math::AXIS_NX); // left direction vector

Arguments

  • MathLib::AXIS axis - Axis along which the direction vector points. The default is the negative Z axis.

Return value

Direction vector in local coordinates.

void setWorldDirection ( const Math::vec3 & dir, const Math::vec3 & up, MathLib::AXIS axis = AXIS_NZ ) #

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 (C++)
// get the node
NodePtr node = 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), Math::AXIS_X);

Arguments

  • const Math::vec3 & dir - New direction vector in world coordinates. The direction vector always has unit length.
  • const Math::vec3 & up - New up vector in world coordinates. If you skip this argument, the Z axis (in local coordinates) will be used. Note that the specified up vector is a hint vector only: the node's up vector points in the direction hinted by the specified up vector. The node's up vector matches the specified up vector (up) only if it is perpendicular to the specified direction vector (dir).
  • MathLib::AXIS axis - Axis along which the direction vector should be pointed. The default is the negative Z axis.

Math::vec3 getWorldDirection ( MathLib::AXIS axis = AXIS_NZ ) #

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 (C++)
node->getWorldDirection(node->isPlayer() ? Math::AXIS_NZ : Math::AXIS_Y); // forward direction vector
node->getWorldDirection(node->isPlayer() ? Math::AXIS_Z : Math::AXIS_NY); // backward direction vector
node->getWorldDirection(node->isPlayer() ? Math::AXIS_Y : Math::AXIS_Z); // upward direction vector
node->getWorldDirection(node->isPlayer() ? Math::AXIS_NY : Math::AXIS_NZ); // down direction vector
node->getWorldDirection(Math::AXIS_X); // right direction vector
node->getWorldDirection(Math::AXIS_NX); // left direction vector

Arguments

  • MathLib::AXIS axis - Axis along which the direction vector points. The default is the negative Z axis.

Return value

Direction vector in world coordinates.

Ptr<Node> getCloneNode ( const Ptr<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

  • const Ptr<Node> & original_node - Original node that was cloned.

Return value

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

Ptr<Property> getCloneProperty ( const Ptr<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

  • const Ptr<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 ( bool 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

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

void setSaveToWorldEnabledRecursive ( bool enable ) #

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

Arguments

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

bool isSaveToWorldEnabled ( ) #

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

Return value

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

bool 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

true if saving to *.world file is enabled for the node; otherwise, false.

void setShowInEditorEnabled ( bool 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

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

void setShowInEditorEnabledRecursive ( bool 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

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

bool 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

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

bool 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

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

Node::LIFETIME 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

Lifetime management type for the root node (see the LIFETIME enum).

void setLifetime ( Node::LIFETIME lifetime ) #

Arguments

Ptr<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.

Ptr<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.

Ptr<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.

Ptr<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.

Ptr<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.

Ptr<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.

Ptr<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.

UGUID getLostNodePropertyGUID ( int num ) const#

Returns the GUID of a lost property assigned to the node. If for some reason a property assigned to the specified slot of the node is missing, this method can be used to get it's GUID.

Arguments

  • int num - Target property slot number.

Return value

Lost property GUID.
Last update: 2021-12-13
Build: ()