This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

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 the getNode() method.

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 from the ObjectMeshStatic instance via the getNode() method.
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->getNode();

	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, it should be added to UnigineEditor first: you should pass node ownership to the editor by releasing script ownership and call the addNode() method of the Editor 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 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. Release script ownership of the ObjectMeshStatic instance.
  5. Get the node from the ObjectMeshStatic instance via the getNode() method.
  6. Add the node to UnigineEditor.
  7. Edit the node and save the world by calling the world_save console command.
Source code (C++)
#include "AppWorldLogic.h"

#include <UnigineNode.h>
#include <UnigineObjects.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");
	// 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");
	// assign a material to the mesh
	object_mesh->setMaterial("mesh_base","*");
	// release script ownership
	object_mesh->release();

	// declare a smart pointer for the node
	// and obtain the node pointer from the created NodeDummy
	NodePtr node = object_mesh->getNode();

	// pass node ownership to the editor by adding the node to it
	Editor::get()->addNode(node);

	// 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::get()->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. Get the node from the ObjectMeshStatic instance via the getNode() method and 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 prevoiusly 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 (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");
	// assign a material to the mesh
	object_mesh->setMaterial("mesh_base", "*");
	// release script ownership
	object_mesh->release();
	// declare a smart pointer for the node
	// and obtain the node pointer from the created NodeDummy
	NodePtr node = object_mesh->getNode();

	// pass node ownership to the editor by adding the node to it
	Editor::get()->addNode(node);

	// export the node into a .node file
	World::get()->saveNode("unigine_project/nodes/my_node.node", node);
	// import the exported node to check the result
	NodePtr imported_node = World::get()->loadNode("unigine_project/nodes/my_node.node");
	// add the imported node to the editor
	//note: an imported node is orphan so you don't need to release script ownership
	Editor::get()->addNode(imported_node);
	// set a position of the node
	imported_node->setPosition(Vec3(4.0f, 0.0f, 1.0f));

	return 1;
}

Deleting a Node#

To delete a node owned by UnigineEditor, pass it to the removeNode() method of the Editor class.

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);
	// assign a material to the mesh
	object_mesh->setMaterial("mesh_base", "*");
	// release script ownership
	object_mesh->release();
	// declare a smart pointer for the node
	// and obtain the node pointer from the created NodeDummy
	NodePtr node = object_mesh->getNode();

	// pass node ownership to the editor by adding the node to it
	Editor::get()->addNode(node);

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

	// delete the node from the editor
	Editor::get()->removeNode(node);
	
	// clear the mesh
	mesh->clear();

	return 1;
}

Node Class

Members


Ptr<Node> getAncestor( int num )

Returns a node ancestor by its number.

Arguments

  • int num - Ancestor ID.

Return value

Ancestor node.

Math::vec3 getAngularVelocity( )

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.

Ptr<Node> getChild( int num )

Returns a node child by its number.

Arguments

  • int num - Child ID.

Return value

Child node.

int 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

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

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 setClutter( int clutter )

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

Arguments

  • int clutter - Positive number to mark the node as a clutter object; otherwise, 0.

int isClutter( )

Returns a value indicating if the node is a 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 setCollider( int collider )

Updates a value indicating if collision detection is enabled for the node (i.e. the node is a collider object). If it is disabled, the node is removed from the physical scene and does not participate in physical interactions.
Notice
Collision detection tests can be performed using getCollision() methods of the World class.

Arguments

  • int collider - Positive number to enable collision detection, 0 to disable.

int isCollider( )

Returns a value indicating if collision detection is enabled for the node.

Return value

1 if collision detection is enabled for the node; otherwise, 0.

void setPortalCullingEnabled( int enabled )

Updates a value indicating if sectors and portals are used for node visibility determination.

Arguments

  • int enabled - 1 to consider sectors and portals; otherwise, 0.

int isPortalCullingEnabled( )

Returns a value indicating if sectors and portals are used for node visibility determination.

Return value

1 if sectors and portals are considered; 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 - 1 to enable interaction with World Triggers, 0 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( 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 * data - New user data. Data can contain an XML formatted string.

const char * getData( )

Returns user data associated with the node.
  • If the node was loaded from the *.node file, data from the data tag of this file is returned.
  • If the node is loaded from the *.world file, data from the Node data tag of the *.world file is returned.
  • If the node is loaded from the *.world file as a NodeReference, data from the NodeReference data tag of the *.world file is returned.

Return value

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

int isDecal( )

Returns a value indicating if the node is a decal node (its type is 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.

void setFolded( int folded )

Shows or minimizes node children in the node tree hierarchy.

Arguments

  • int folded - Positive number to minimize node children; 0 to expand node hierarchy.

int isFolded( )

Returns a value indicating if node children are displayed or minimized in the node tree hierarchy.

Return value

Positive number if node children are hidden in the node tree; 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.

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( 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 (WorldSector, WorldPortal, WorldOccluder, triggers, expressions, etc.)

Arguments

  • int handled - Positive value to show the handle, 0 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 (WorldSector, WorldPortal, WorldOccluder, triggers, expressions, etc.)

Return value

1 if the handle is shown; otherwise, 0.

void deleteHierarchy( const Ptr<Node> & node )

Deletes the whole hierarchy of the given node.

Arguments

  • const Ptr<Node> & node - Node, the hierarchy of which is to be deleted.

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.

int setID( int id )

Sets a unique ID for the node.

Arguments

  • int id - Node ID.

Return value

1 if the ID is set successfully; otherwise, 0.

int getID( )

Returns the ID of the node.
Notice
See also engine.world.getNode() 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.

void setLatest( int latest )

Sets a flag that forces a node to be updated the last of all, after states of all other nodes were updated. For example, a post update flag is useful to draw nodes strictly in front of the camera (after a Player has updated its transformations). By default, this flag is set to 0.

Arguments

  • int latest - Positive value to update a node last of all; otherwise, 0.

int isLatest( )

Checks if a node is forced to be updated the last of all, after states of all other nodes were updated. For example, a post update flag is useful to draw nodes strictly in front of the camera (after a Player has updated its transformations). By default, this flag is set to 0.

Return value

1 if the node is updated last of all; otherwise, 0

int isLight( )

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

Return value

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

Math::vec3 getLinearVelocity( )

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.

int isNavigation( )

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

Return value

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

Ptr<Node> getNode( )

Returns a node pointer.

Return value

Node pointer.

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

Returns 1 if the node is valid; otherwise, 0.

int isNode( int id )

Check the node pointer.

Arguments

  • int id - Node pointer.

Return value

Returns 1 if the node is valid; 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 OBJECT_*).

Return value

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

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

int isObstacle( )

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

Return value

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

void setOldWorldTransform( const Math::Mat4 & transform )

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

Arguments

  • const Math::Mat4 & transform - Old transformation matrix to be set.

Math::Mat4 getOldWorldTransform( )

Returns old transformation matrix for the node in the world coordinates.

Return value

Old transformation matrix.

int isOwner( )

Returns the owner flag. If the pointer is the owner, on its deletion the node also will be deleted. Use grab() and release() functions to change ownership

Return value

Owner flag.

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.

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

Return value

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

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

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

Return value

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

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

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

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

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

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

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

Return value

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

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

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

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

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

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

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 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( int query )

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

Arguments

  • int query - Positive number to use occlusion query, 0 not to use.

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.

Ptr<Node> getRootNode( )

Returns the root node for the node.

Return value

Root node the root node for the node.

void setRotation( const Math::quat & rot, int identity = 0 )

Sets the node rotation.

Arguments

  • const Math::quat & rot - Node rotation in the local space.
  • int identity - 1 to enable scaling of the node, 0 to disable it.

Math::quat getRotation( )

Returns the node rotation.

Return value

Node rotation in the local space.

void setScale( const Math::vec3 & s )

Sets the scale of the node.

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.

int isShadow( )

Returns a value indicating if the node was a shadow caster in the previous frame and, therefore, is updated.

Return value

1 if the node was a shadow caster; otherwise, 0.

int isSound( )

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

Return value

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

void setTransform( const Math::Mat4 & transform )

Sets the transformation matrix for the node in its parent coordinates.

Arguments

  • const Math::Mat4 & transform - New transformation matrix.

Math::Mat4 getTransform( )

Returns the transformation matrix of the node in its parent coordinates.

Return value

Transformation matrix.

int getType( )

Returns a type of the node.

Return value

Node type identifier.

int 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( 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( 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

  • const Variable & v - Variable value.

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.

int isVisible( )

Returns a value indicating if the node was shown in the viewport in the previous frame and, therefore, is updated.

Return value

1 if the node was visible; otherwise, 0.

int isWorld( )

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

Return value

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

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.

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

Sets the node rotation in the world space.

Arguments

  • const Math::quat & rot - Node rotation in the world space.
  • int identity - 1 to enable scaling of the node, 0 to disable it.

Math::quat getWorldRotation( )

Returns the node rotation in the world space.

Return value

Node rotation in the world space.

void setWorldScale( const Math::vec3 & s )

Sets the node scale in the world space.

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.

Ptr<WorldSector> getWorldSector( )

Returns a sector, in which the node is located.

Return value

World sector.

void setWorldTransform( const Math::Mat4 & transform )

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

Arguments

  • const Math::Mat4 & transform - Transformation matrix.

Math::Mat4 getWorldTransform( )

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

Return value

Transformation matrix.

Math::vec3 getWorldVelocity( 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( )

Clones the current 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.

void grab( )

Grabs the node (sets the owner flag to 1). The node should not be handled by the engine after this function is called.

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.

int loadWorld( const Ptr<Xml> & xml )

Loads a node state from the Xml.

Arguments

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

Return value

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

void release( )

Releases the node (sets the owner flag to 0). The node should be handled by the engine after this function is called.

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.

int 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

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

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.

int restoreState( const Ptr<Stream> & stream )

Restores a node state from the stream.
Warning
This function is deprecated and will be removed in the next release.

Arguments

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

Return value

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

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.

int saveState( const Ptr<Stream> & stream )

Saves a node state into the stream.
Warning
This function is deprecated and will be removed in the next release.

Arguments

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

Return value

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

int saveWorld( const Ptr<Xml> & xml )

Saves a node state into the Xml.

Arguments

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

Return value

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

void scale( const Math::vec3 & s )

Scales the node in its local coordinate system: the parent node scale isn't taken into account.

Arguments

  • const Math::vec3 & s - Scale vector.

void swap( const Ptr<Node> & n )

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 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 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 worldScale( const Math::vec3 & s )

Scales the node in the world space.

Arguments

  • const Math::vec3 & s - Scale vector.

void worldTranslate( const Math::Vec3 & t )

Translates the node in the world space.

Arguments

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

void * addCallback( int 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::get()->findManualProperty("node_base")->inherit("my_prop");

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

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

Arguments

  • int callback - Callback type. One of the CALLBACK_* variables.
  • Unigine::CallbackBase2< Ptr<Node>, Ptr<Property> > * 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.

void * addCallback( int 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

  • int callback - Callback type. One of the CALLBACK_* variables.
  • Unigine::CallbackBase3< Ptr<Node>, Ptr<Property>, 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.

void * addCallback( int 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

  • int 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( int 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

  • int 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( int 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

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

void setDirection( const Math::vec3 & dir, const Math::vec3 & up, int 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 = Editor::get()->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).
  • int axis - Axis along which the direction vector should be pointed. The default is the negative Z axis.

Math::vec3 getDirection( int 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

  • int 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, int 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 = Editor::get()->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).
  • int axis - Axis along which the direction vector should be pointed. The default is the negative Z axis.

Math::vec3 getWorldDirection( int 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

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

Return value

Direction vector in world coordinates.
Last update: 2018-12-27
Build: ()