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

Node Class

Nodes represent all types of objects that are present in the world (whether visible or invisible) and are specifically positioned and oriented.

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

Node Class

Members


void addChild (Node node)

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

Arguments

  • Node node - New child node.

void addWorldChild (Node node)

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

Arguments

  • Node node - New child node.

Node clone ()

Clones the node.

Return value

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

int findChild (string name)

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

Arguments

  • string name - Name of the child node.

Return value

Index number of the child, if it is found; otherwise, -1.

vec3 getAngularVelocity ()

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

Return value

Angular velocity in the local space.

vec3 getBoundCenter ()

Returns the center of the bounding sphere of the node.

Return value

Coordinates of the center of the bounding sphere.

vec3 getBoundMax ()

Returns the point with the maximum coordinates of the axis-aligned bounding box of the node.

Return value

Maximum coordinates of the bounding box.

vec3 getBoundMin ()

Returns the point with the minimum coordinates of the axis-aligned bounding box of the node.

Return value

Minimum coordinates of the bounding box.

float getBoundRadius ()

Returns the radius of the bounding sphere of the node.

Return value

Radius of the bounding sphere.

Node getChild (int id)

Returns a given child of the node.

Arguments

  • int id - ID number of the child.

Return value

Child node.

string getData ()

Returns user string data associated with the node.
  • If the node was loaded from the *.node file, data from the data tag of this file is returned.
  • If the node is loaded from the *.world file, data from the Node data tag of the *.world file is returned.
  • If the node is loaded from the *.world file as a NodeReference, data from the NodeReference data tag of the *.world file is returned.
Notice
You can also use setVariable() to associate an arbitrary user variable with a node.

Return value

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

vec3 getDirection ()

Returns the normalized direction vector of the node. By default, a direction vector points along the mesh local -Z axis (vec3(0,0,-1)). It always has unit length.

Return value

Normalized direction vector in the local space.

int getID ()

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

Return value

Unique ID.

mat4 getIWorldTransform ()

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

Return value

Inverse transformation matrix.

vec3 getLinearVelocity ()

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

Return value

Linear velocity in the local space.

string getName ()

Returns the name of the node.

Return value

Name of the node.

int getNumChilds ()

Returns the number of children of the node.

Return value

Number of child nodes.

Node getParent ()

Returns the parent of the node.

Return value

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

vec3 getPosition ()

Returns the node position.

Return value

The node position in the local space.

Node getPossessor ()

Returns NodeReference, WorldCluster or WorldClutter if they are a container of the current node. This function can only be applied to a root node inside a node reference.

Return value

Container of the node.

string getPropertyName ()

Returns the name of a property associated with the node.

Return value

Property name.

Property getProperty ()

Returns a property associated with the node.

Return value

Property defined for the whole node.

quat getRotation ()

Returns the node rotation.

Return value

The node rotation in the local space.

vec3 getScale ()

Returns scale of the node.

Return value

Scale in the local space.

mat4 getTransform ()

Returns the transformation matrix of the node.

Return value

Transformation matrix.

string getTypeName ()

Returns a name of the node type.

Return value

Type name.

int getType ()

Returns the type of the node.

Return value

One of the NODE_* pre-defined variables.

variable getVariable ()

Returns arbitrary user string variable associated with the node.
Notice
You can also use setData() to associate a user data string, which is written directly into a *.node or a *.world file.

Return value

User variable.

vec3 getWorldBoundCenter ()

Returns the center of the bounding sphere of the node in the world coordinates.

Return value

Coordinates of the center of the bounding sphere.

vec3 getWorldBoundMax ()

Returns the point with the maximum world coordinates of the axis-aligned bounding box of the node.

Return value

Maximum coordinates of the bounding box.

vec3 getWorldBoundMin ()

Returns the point with the minimum world coordinates of the axis-aligned bounding box of the node.

Return value

Minimum coordinates of the bounding box.

float getWorldBoundRadius ()

Returns the radius of the bounding sphere of the node in the world coordinates.

Return value

Radius of the bounding sphere.

vec3 getWorldDirection ()

Returns the normalized direction vector of the node. By default, a direction vector points along the mesh local -Z axis (vec3(0,0,-1)) and is returned in world space coordinates. It always has unit length.

Return value

Normalized direction vector in the world space.

vec3 getWorldPosition ()

Returns the node position.

Return value

The node position in the world space.

quat getWorldRotation ()

Returns the node rotation.

Return value

The node rotation in the local space.

vec3 getWorldScale ()

Returns scale of the node.

Return value

Scale in the local space.

WorldSector getWorldSector ()

Returns a sector, in which the node is located.

Return value

World sector.

mat4 getWorldTransform ()

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

Return value

Transformation matrix.

vec3 getWorldVelocity (vec3 point)

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

Arguments

  • vec3 point - Target point.

Return value

Linear velocity in the world space.

int isChild (Node node)

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

Arguments

  • Node node - Node to check.

Return value

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

int isClutter ()

Returns a value indicating if the node is a clutter object.

Return value

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

int isCollider ()

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

Return value

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

int isDecal ()

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

Return value

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

int isEnabledSelf ()

Returns a value indicating if the node is enabled. The default is 1.

Return value

1 if the node is enabled; otherwise, 0.

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

int isImmovable ()

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

Return value

1 if the node is immovable; 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 NODE_LIGHT_*).

Return value

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

int isObject ()

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

Return value

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

int isPhysical ()

Returns a value indicating if the node is a physical force node (its type is NODE_PHYSICAL_FORCE).

Return value

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

int isPlayer ()

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

Return value

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

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.

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

Return value

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

int isSpatial ()

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.

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 part of the world (its type is NODE_WORLD_*).

Return value

1 if the node is an occluder or a sector or a portal; otherwise, 0.

void removeChild (Node node)

Removes a child node from the list of children. Transformations of the removed child will be done relative to the origin of coordinates.

Arguments

  • Node node - Child node to remove.

void removeWorldChild (Node node)

Removes a child node from the list of children. World position of the removed child is preserved, and its transformations will be done in the world coordinates.

Arguments

  • Node node - Child node to remove.

void renderVisualizer ()

Renders a bounding box / sphere of the object.

int restoreState (Stream stream)

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

Arguments

  • Stream stream - Stream with saved node state data.

Return value

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

int saveState (Stream stream)

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

Arguments

  • Stream stream - Stream to save node state data.

Return value

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

void setClutter (int mode)

Updates a value indicating if the node represents a clutter object.

Arguments

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

void setCollider (int collider)

Updates a value indicating if collision test enabled for the node.

Arguments

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

void setData (string data)

Updates user data associated with the node.
  • If the node was loaded from the *.node file, data is saved directly into the data tag of this file.
  • If the node is loaded from the *.world file, data is saved into the Node data tag of the *.world file.
  • If the node is loaded from the *.world file as a NodeReference, data will be saved to the NodeReference data tag of the *.world file.

Arguments

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

void setDirection (vec3 dir, vec3 up)

Updates the direction vector of the node. By default, a direction vector points along the mesh local -Z axis (vec3(0,0,-1)). This function changes its direction and reorients the mesh.

Arguments

  • vec3 dir - New direction vector in the local space. The direction vector always has unit length.
  • vec3 up - New up vector in the local space. The default is vec3(0.0f,0.0f,1.0f).

void setEnabled (int mode)

Enables or disables the node.

Arguments

  • int mode - Positive number to enable the node, 0 to disable.

void setFolded (int mode)

Shows or minimizes node children in the node tree hierarchy.

Arguments

  • int mode - Positive number to minimize node children, 0 to expand node hierarchy.

void setHandled (int mode)

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 mode - Positive number to show the handle, 0 to hide it.

int setID (int id)

Sets the unique ID for the node.

Arguments

  • int id - Unique ID.

Return value

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

void setImmovable (int mode)

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

Arguments

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

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.

void setName (string name)

Updates the name of the node.

Arguments

  • string name - New name of the node.

void setParent (Node node)

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

Arguments

  • Node node - New parent node.

void setPosition (vec3 pos)

Updates the node position.

Arguments

  • vec3 pos - New position in the local space.

void setProperty (string name)

Associates a given property with the whole node.

Arguments

  • string name - Property name.

void setQuery (int mode)

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

Arguments

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

void setRotation (quat rot, int identity)

Updates the node rotation.

Arguments

  • quat rot - New rotation in the local space.
  • int identity - 1 to enable scaling of the node, 0 to disable it.

void setScale (vec3 scale)

Updates the node scale.

Arguments

  • vec3 scale - New scale in the local space.

void setSpatial (int spatial)

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

Arguments

  • int spatial - Positive value to consider sectors and portals; otherwise, 0.

void setTransform (mat4 matrix)

Updates the transformation matrix of the node.

Arguments

  • mat4 matrix - New transformation matrix.

void setVariable (variable variable)

Updates an arbitrary user variable associated with the node.
Notice
You can also use setData() to associate a user data string, which is written directly into a *.node file.

Arguments

  • variable variable - New user variable for a node.

void setWorldDirection (vec3 dir, vec3 up)

Updates the direction of the node. By default, a direction vector points along the mesh local -Z axis (vec3(0,0,-1)) and is set in world space coordinates. This function changes its direction and reorients the mesh.

Arguments

  • vec3 dir - New direction vector in the world space. The direction vector always has unit length.
  • vec3 up - New up vector in the world space. The default is vec3(0.0f,0.0f,1.0f).

void setWorldParent (Node node)

Updates the parent for the node. Transformations of the current node will be done in the world coordinates.

Arguments

  • Node node - New parent node.

void setWorldPosition (vec3 pos)

Updates the node position.

Arguments

  • vec3 pos - New position in the world space.

void setWorldRotation (quat rot, int identity)

Updates the node rotation.

Arguments

  • quat rot - New rotation in the world space.
  • int identity - 1 to enable scaling of the node, 0 to disable it.

void setWorldScale (vec3 scale)

Updates the node scale.

Arguments

  • vec3 scale - New scale in the local space.

void setWorldTransform (mat4 matrix)

Updates the transformation matrix of the node for transformations in the world coordinates.

Arguments

  • mat4 matrix - New transformation matrix.

void swap (Node node)

Swaps the nodes saving the pointers.

Arguments

  • Node node - Node to swap.

int NODE_DECAL_DEFERRED_MESH

Description

Decal deferred mesh.

int NODE_DECAL_DEFERRED_ORTHO

Description

Deferred orthographic decal.

int NODE_DECAL_DEFERRED_PROJ

Description

Deferred perspective-projected decal.

int NODE_DECAL_OBJECT_OMNI

Description

Object omni-directional decal.

int NODE_DECAL_OBJECT_ORTHO

Description

Object orthographic decal.

int NODE_DECAL_OBJECT_PROJ

Description

Object perspective-projected decal.

int NODE_DECAL_TERRAIN_ORTHO

Description

Terrain orthographic decal.

int NODE_DECAL_TERRAIN_PROJ

Description

Terrain perspective-projected decal.

int NODE_DUMMY

Description

Dummy node.

int NODE_EXTERN

Description

Extern node.

int NODE_FIELD_ANIMATION

Description

Field Animation node.

int NODE_FIELD_SPACER

Description

Field Spacer node.

int NODE_LAYER

Description

Node layer containing parent layer and all its child nodes. See the NodeLayer class.

int NODE_LIGHT_CUBE

Description

Omni-directional light source with cubemap modulation.

int NODE_LIGHT_OMNI

Description

Omni-directional light source. See the LightOmni class.

NODE_LIGHT_PROB

Description

Probe light source based on the spherical harmonics. See the LightProb class.

int NODE_LIGHT_PROJ

Description

Projected light source. See the LightProj class.

int NODE_LIGHT_SPOT

Description

Spot light without shadows. See the LightSpot class.

int NODE_LIGHT_WORLD

Description

World light source. See the LightWorld class.

int NODE_NAVIGATION_MESH

Description

Mesh-based navigation area across which pathfinding is performed.

int NODE_NAVIGATION_SECTOR

Description

Sector within which pathfinding is performed.

int NODE_OBJECT_BILLBOARD

Description

Billboard. See the ObjectBillboard class.

int NODE_OBJECT_BILLBOARDS

Description

Billboards object for rendering a high number of billboards. See the ObjectBillboard class.

int NODE_OBJECT_DUMMY

Description

Dummy object. See the ObjectDummy class.

int NODE_OBJECT_DYNAMIC

Description

Dynamic object. See the ObjectDynamic class.

int NODE_OBJECT_EXTERN

Description

Extern object. See the ObjectExtern class.

int NODE_OBJECT_GRASS

Description

Grass.

int NODE_OBJECT_GUI

Description

GUI object. See the ObjectGui class.

int NODE_OBJECT_GUI_MESH

Description

GUI mesh object. See the ObjectGuiMesh class.

int NODE_OBJECT_MESH

Description

Mesh object. See the ObjectMesh class.

int NODE_OBJECT_MESH_CLUSTER

Description

Mesh Cluster object. See the ObjectMeshCluster class.

int NODE_OBJECT_MESH_CLUTTER

Description

Mesh Clutter object. See the ObjectMeshClutter class.

int NODE_OBJECT_MESH_DYNAMIC

Description

Dynamic mesh object. See the ObjectMeshDynamic class.

int NODE_OBJECT_MESH_SKINNED

Description

Skinned mesh object. See the ObjectMeshSkinned class.

int NODE_OBJECT_PARTICLES

Description

Particles object. See the ObjectParticles class.

int NODE_OBJECT_SKY

Description

Sky object. See the ObjectSky class.

int NODE_OBJECT_TERRAIN

Description

Terrain object. See the ObjectTerrain class.

int NODE_OBJECT_VOLUME_BOX

Description

Volume box object. See the ObjectVolumeBox class.

int NODE_OBJECT_VOLUME_OMNI

Description

Volume omni light object. See the ObjectVolumeOmni class.

int NODE_OBJECT_VOLUME_PROJ

Description

Volume projected light object. See the ObjectVolumeProj class.

int NODE_OBJECT_VOLUME_SPHERE

Description

Volume sphere object. See the ObjectVolumeSphere class.

int NODE_OBJECT_WATER

Description

Water object. See the ObjectWater class.

int NODE_OBJECT_WATER_MESH

Description

Water mesh object. See the ObjectWaterMesh class.

int NODE_OBSTACLE_BOX

Description

Obstacle in the shape of a box avoided by pathfinding.

int NODE_OBSTACLE_CAPSULE

Description

Obstacle in the shape of a capsule avoided by pathfinding.

int NODE_OBSTACLE_SPHERE

Description

Obstacle in the shape of a sphere avoided by pathfinding.

int NODE_PHYSICAL_FORCE

Description

Physical force node that allows to simulate point forces applied to dynamic objects. See the PhysicalForce class.

int NODE_PHYSICAL_NOISE

Description

Physical noise node that allows to simulate force field.

int NODE_PHYSICAL_TRIGGER

Description

Physical trigger. See the PhysicalTrigger class.

int NODE_PHYSICAL_WATER

Description

Physical water object that has no visual representation. See the PhysicalWater class.

int NODE_PHYSICAL_WIND

Description

Physical wind object. See the PhysicalWind class.

int NODE_PIVOT

Description

Node that helps to control rotation and transformation of its children.

int NODE_PLAYER_ACTOR

Description

Acting player. See the PlayerActor class.

int NODE_PLAYER_DUMMY

Description

Dummy player. See the PlayerDummy class.

int NODE_PLAYER_PERSECUTOR

Description

Persecuting player. See the PlayerPersecutor class.

int NODE_PLAYER_SPECTATOR

Description

Observing player. See the PlayerSpectator class.

int NODE_REFERENCE

Description

Node that references an external NODE file. See the NodeReference class.

int NODE_SOUND_REVERB

Description

Sound reverberation zone. See the SoundReverb class.

int NODE_SOUND_SOURCE

Description

Sound source. See the SoundSource class.

int NODE_TRIGGER

Description

Dummy node that can fire callbacks on its enabling/disabling or repositioning. See the NodeTrigger class.

int NODE_WORLD_CLUSTER

Description

Node cluster. See the WorldCluster class.

int NODE_WORLD_CLUTTER

Description

World clutter. See the WorldClutter class.

int NODE_WORLD_EXPRESSION

Description

Node which allows to execute arbitrary expression. See the WorldExpression class.

int NODE_WORLD_EXTERN

Description

External world. See the WorldExtern class.

int NODE_WORLD_LAYER

Description

World layer. See the WorldLayer class.

int NODE_WORLD_OCCLUDER

Description

World occluder. See the WorldOccluder class.

int NODE_WORLD_OCCLUDER_MESH

Description

World mesh occluder. See the WorldOccluderMesh class.

int NODE_WORLD_OCCLUDER_TERRAIN

Description

World terrain occluder. See the WorldOccluderMesh class.

int NODE_WORLD_PORTAL

Description

World portal. See the WorldPortal class.

int NODE_WORLD_REVERB

Description

Sound reverberation zone. See the SoundReverb class.

int NODE_WORLD_SECTOR

Description

World sector. See the WorldSector class.

int NODE_WORLD_SOURCE

Description

Sound source. See the SoundSource class.

int NODE_WORLD_SWITCHER

Description

Node switcher (to switch off parts of the world). See the WorldSwitcher class.

int NODE_WORLD_TRANSFORM

Description

Spline defined transformer. See the WorldTransform class.

int NODE_WORLD_TRANSFORM_BONE

Description

Bone defined transformer. See the WorldTransformBone class.

int NODE_WORLD_TRIGGER

Description

World trigger. See the WorldTrigger class.
Last update: 2017-07-03