This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
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
Materials and Shaders
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.

NodeLayer Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits from: Node

A layer node is a zero-sized node that has no visual representation and enables to save all its child nodes into a separate .node file. Layer nodes should be used to split the world into several logical parts and save each of them in a .node file so that each layer and its child nodes can be edited without affecting the source .world file.

Notice
The layer node itself is not stored in the .node file.

Creating a Layer#

Create an instance of the NodeLayer class. You can also specify such settings as a name, transformation and so on.

Source code (UnigineScript)
#include <core/unigine.h>

int init() {
	// create a layer node
	NodeLayer layer = new NodeLayer();
	// set a name
	layer.setName("LayerNode");
}

Editing a Layer#

Editing a layer node includes adding, deleting, modifying its child nodes. For example, you can add new nodes as follows:

Source code (UnigineScript)
#include <core/unigine.h>

int init() {
	
	// create a layer node
	NodeLayer layer = new NodeLayer();
	// set a name for the node
	layer.setName("layer_0");
	

	// create a mesh
	Mesh mesh = new Mesh();
	mesh.addBoxSurface("box_0", vec3(1.0f));
	// create a node (e.g. an instance of the ObjectMeshDynamic class)
	ObjectMeshDynamic node = new ObjectMeshDynamic(mesh);
	
	// set node transformation
	node.setWorldTransform(translate(Vec3(x * 2, y * 2, 0.0f)));
	// set a name for the node
	node.setName(format("mesh_%d_%d", x + 10, y + 10));
	
	// add the node as a child to the layer node
	layer.addWorldChild(node);

	return 1;
}

Saving a Layer#

Changes made in the child nodes of the layer node can be saved on the disk by saving the world. The nodes will be saved in the separate .node file specified for the layer, not in the .world file.

Source code (UnigineScript)
#include <core/unigine.h>

int init() {
	
	// create a layer node
	NodeLayer layer = new NodeLayer("unigine_project/nodes/layer_0.node");
	// set a name for the node
	layer.setName("layer_0");
	
	
	// create child nodes
	for (int y = -4; y <= 4; y++)
	{
		for (int x = -4; x <= 4; x++)
		{

			// create a mesh
			Mesh mesh = new Mesh();
			mesh.addBoxSurface("box_0", vec3(1.0f));
			// create a node (e.g. an instance of the ObjectMeshDynamic class)
			ObjectMeshDynamic node = new ObjectMeshDynamic(mesh);
			
			// set node transformation
			node.setWorldTransform(translate(Vec3(x * 2, y * 2, 0.0f)));
			// set a name for the node
			node.setName(format("mesh_%d_%d", x + 4, y + 4));
			
			// add the node as a child to the layer node
			layer.addWorldChild(node);
		}
	}
	
	// save the world
	engine.console.run("world_save unigine_project");

	return 1;
}

Instead of saving the world, you can manually save child nodes of the layer into the .node file by using the engine.world.saveNodes() function:

Source code (UnigineScript)
// declare an array of nodes
Node nodes[0] = ();
// add child nodes of the layer to the declared array
for (int i = 0; i < layer.getNumChildren(); i++) {
    nodes.append(layer.getChild(i));
}
// save nodes to the .node file
if (engine.world.saveNodes(layer.getNodePath(), nodes) == 0) {
	log.error("Layer hasn't been saved\n");
}

See Also#

NodeLayer Class

Members


static NodeLayer ( string name ) #

Constructor. Creates a node layer with specified file name to store it.

Arguments

  • string name - Name of the layer.

void setNodePath ( string name ) #

Updates the name of the node layer: a path to a .node file where child nodes of the layer are stored.

Arguments

  • string name - Path to a .node file.

string getNodePath ( ) #

Returns the name of the node layer: a path to a .node file where child nodes of the layer are stored.

Return value

Path to the .node file.

static int type ( ) #

Returns the type of the node.

Return value

NodeLayer type identifier.
Last update: 2022-03-10
Build: ()