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
Programming
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
API
Containers
Common Functionality
Controls-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
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.World Class

This class provides functionality for the world script. It contains methods required for loading the world with all its nodes, managing a spatial tree and handling nodes collisions and intersections.

Loading of nodes on demand is managed via the AsyncQueue Class.

Notice
C++ methods running editor script functions are described in the Engine class reference.

See also

World Class

Members


int isAutoReloadNodeReferences()

Returns a value indicating if automatic reloading of NodeReferences is enabled. If enabled all NodeReference nodes will reload their *.node files, when the saveNode() method is called.
Notice
This option can be used if you modify and save reference nodes at runtime. Otherwise you'll have to manually update pointers for all NodeReferences referring to the changed node.

Return value

1 if automatic reloading of NodeReferences is enabled; otherwise, 0.

void setAutoReloadNodeReferences(int val)

Enables automatic reloading of NodeReferences. If enabled all NodeReference nodes will reload their *.node files, when the saveNode() method is called.
Notice
This option can be used if you modify and save reference nodes at runtime. Otherwise you'll have to manually update pointers for all NodeReferences referring to the changed node.

Arguments

  • int val - 1 to enable automatic reloading of NodeReferences; 0 - to disable it. The default value is 0.

void setBudget(float budget)

Sets the world generation budget value for Grass and Clutter objects. New objects are not created when time is out of the budget.

Arguments

  • float budget - The budget value in seconds. The default value is 1/60.

float getBudget()

Returns the value of the world generation budget for Grass and Clutter objects. New objects are not created when time is out of the budget.

Return value

The budget value in seconds. The default value is 1/60.

int getCollision(WorldBoundBox bb, Object[] objects)

Searches for all collider objects within a given bounding box.
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundBox bb - Bounding box.
  • Object[] objects - Array with collider objects' smart pointers.

Return value

1 if collider objects are found; otherwise, 0.

int getCollision(WorldBoundSphere bs, Object[] objects)

Searches for all collider objects within a given bounding sphere.
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundSphere bs - Bounding sphere.
  • Object[] objects - Array with collider objects' smart pointers.

Return value

1 if collider objects are found; otherwise, 0.

int getCollision(Vec3 p0, Vec3 p1, Object[] objects)

Performs tracing from the p0 point to the p1 point to find all collider objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects.

Collisions with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Collision flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the collision parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • Object[] objects - Array with collider objects' smart pointers.

Return value

1 if collider objects are found; otherwise, 0.

void setData(string data)

Sets user data associated with the world. In the *.world file, the data is set in the data tag.

Arguments

  • string data - New user data.

string getData()

Returns user string data associated with the world. This string is written directly into the data tag of the *.world file.

Return value

User string data.

void setDistance(float distance)

Updates the distance, at which (and farther) nothing will be rendered or simulated.

Arguments

  • float distance - New distance in units.

float getDistance()

Returns a distance, at which (and farther) nothing will be rendered or simulated.

Return value

Distance in units.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, Vec3[] ret_point, vec3[] ret_normal, vec4[] ret_texcoord, int[] ret_index, int[] ret_surface)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces of a mesh. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • Vec3[] ret_point - Intersection point of the line and object.
  • vec3[] ret_normal - Normal vector to the intersection point.
  • vec4[] ret_texcoord - Texture coordinates of the intersection point (vec4, where vec4.xy is for the first (0) UV channel, vec4.zw is for the second (1) UV channel).
  • int[] ret_index - Intersected triangle (polygon) number.
  • int[] ret_surface - Intersected surface number.

Return value

Intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, Node[] exclude, Vec3[] ret_point, vec3[] ret_normal, vec4[] ret_texcoord, int[] ret_index, int[] ret_surface)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • Node[] exclude - The list of nodes to be excluded.
  • Vec3[] ret_point - Intersection point of the line and object.
  • vec3[] ret_normal - Normal vector to the intersection point.
  • vec4[] ret_texcoord - Texture coordinates of the intersection point (vec4, where vec4.xy is for the first (0) UV channel, vec4.zw is for the second (1) UV channel).
  • int[] ret_index - Intersected triangle (polygon) number.
  • int[] ret_surface - Intersected surface number.

Return value

Intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, WorldIntersection intersection)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • WorldIntersection intersection - WorldIntersection object to be filled.

Return value

First intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, WorldIntersectionNormal intersection)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • WorldIntersectionNormal intersection - WorldIntersectionNormal object to be filled.

Return value

First intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, WorldIntersectionTexCoord intersection)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • WorldIntersectionTexCoord intersection - WorldIntersectionTexCoord object to be filled.

Return value

First intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, Node[] exclude, WorldIntersection intersection)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • Node[] exclude - The list of nodes to be excluded.
  • WorldIntersection intersection - WorldIntersection object to be filled.

Return value

First intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, Node[] exclude, WorldIntersectionNormal intersection)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • Node[] exclude - The list of nodes to be excluded.
  • WorldIntersectionNormal intersection - WorldIntersectionNormal object to be filled.

Return value

First intersected object.

Object getIntersection(Vec3 p0, Vec3 p1, int mask, Node[] exclude, WorldIntersectionTexCoord intersection)

Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • int mask - Intersection mask. If 0 is passed, the function will return NULL.
  • Node[] exclude - The list of nodes to be excluded.
  • WorldIntersectionTexCoord intersection - WorldIntersectionTexCoord object to be filled.

Return value

First intersected object.

int getIntersection(Vec3 p0, Vec3 p1, Object[] objects)

Performs tracing from the p0 point to the p1 point to find objects that intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.

Intersections with the surface can be found only if the following conditions are fulfilled:

  1. The surface is enabled.
  2. Per-surface Intersection flag is enabled.
  3. The surface has a material assigned.
  4. A property inherited from the surface_base is assigned to the surface and the intersection parameter of this property is set to 1 (e.g. via the setParameterInt() method).
Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • Vec3 p0 - Coordinates of the line start point.
  • Vec3 p1 - Coordinates of the line end point.
  • Object[] objects - Array of intersected objects.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundBox bb, Object[] objects)

Searches for intersections with objects that are found in a given bounding box.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundBox bb - Bounding box where intersection search will be performed.
  • Object[] objects - Array of intersected objects.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundSphere bs, Object[] objects)

Searches for intersections with objects that are found in a given bounding sphere.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundSphere bs - Bounding sphere where intersection search will be performed.
  • Object[] objects - Array of intersected objects.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundFrustum bf, Object[] objects)

Searches for intersections with objects that are found in a given bounding frustum.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundFrustum bf - Bounding frustum where intersection search will be performed.
  • Object[] objects - Array of intersected objects.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundBox bb, Node[] nodes)

Searches for intersections with nodes that are found in a given bounding box.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundBox bb - Bounding box where intersection search will be performed.
  • Node[] nodes - Array of intersected nodes.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundSphere bs, Node[] nodes)

Searches for intersections with nodes that are found in a given bounding sphere.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundSphere bs - Bounding sphere where intersection search will be performed.
  • Node[] nodes - Array of intersected nodes.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundBox bb, int type, Node[] nodes)

Searches for intersections with specified type of nodes that are found in a given bounding box.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundBox bb - Bounding box where intersection search will be performed.
  • int type - Node type filter. Only the nodes of the specified type will be checked.
  • Node[] nodes - Array of intersected nodes.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundSphere bs, int type, Node[] nodes)

Searches for intersections with specified type of nodes that are found in a given bounding sphere.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundSphere bs - Bounding sphere where intersection search will be performed.
  • int type - Node type filter. Only the nodes of the specified type will be checked.
  • Node[] nodes - Array of intersected nodes.

Return value

1 if intersections are found; otherwise, 0.

int getIntersection(WorldBoundFrustum bf, int type, Node[] nodes)

Searches for intersections with specified type of nodes that are found in a given bounding frustum.

Notice
As a new node becomes a part of the BSP tree only after the updateSpatial() method is called (the engine calls the method automatically each frame after the world script update() code is executed), all engine subsystems can process this node only in the next frame. If you need to get the node in the very first frame, call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Arguments

  • WorldBoundFrustum bf - Bounding frustum where intersection search will be performed.
  • int type - Node type filter. Only the nodes of the specified type will be checked.
  • Node[] nodes - Array of intersected nodes.

Return value

1 if intersections are found; otherwise, 0.

int loadWorld(string name)

Loads a world from a file and replaces the current world with it.

Arguments

Return value

1 if the world is loaded successfully; otherwise, 0.

int isLoaded()

Returns a value indicating if the current world is fully loaded.

Return value

1 if the world is loaded; otherwise, 0.

void setName(string name)

Sets a new name for the world.

Arguments

  • string name - Name of the world.

string getName()

Returns the name of the currently loaded world. (If a path was specified in the name, the returned string will contain both the world name and a path).

Return value

Name of the world.

void setPath(string path)

Sets the path to the *.world-file where the world is stored.

Arguments

  • string path - Path to the *.world-file.

string getPath()

Returns the current path to the *.world-file where the world is stored.

Return value

Path to the *.world-file.

void setScriptName(string name)

Sets the name of the world script file *.cpp.

Arguments

  • string name - Name of the world script file *.cpp.

string getScriptName()

Returns the name of the world script file *.cpp.

Return value

Name of the world script file *.cpp.

Node getNode(int id)

Returns a node by its ID. This can be any node: either created dynamically in run-time or loaded from the *.world file.

Arguments

  • int id - Node ID.

Return value

Node smart pointer if the node with the specified ID exists; otherwise, NULL.

int isNode(int id)

Checks if a node with a given ID exists in the world.

Arguments

  • int id - Node ID.

Return value

1 if the node with the given ID exists; otherwise, 0.

void getNodes(Node[] nodes)

Gets all of the nodes (either loaded from the *.world file or created dynamically in run-time).

Arguments

  • Node[] nodes - Return array with node smart pointers.

int getNumUpdateNodes()

Returns the number of currently updating nodes in the world.

Return value

Number of updating nodes.

Node getUpdateNode(int num)

Returns an updated node by its ID.

Arguments

  • int num - Node ID.

Return value

The node smart pointer, if found; otherwise - 0.

void addUpdateNode(Node node)

Adds a node that should be updated even if it is outside of the viewing frustum. This function should be called every frame.

Arguments

  • Node node - Node to be updated.

void addUpdateNodes(Node[] nodes)

Adds a node array that should be updated even if the nodes are outside of the viewing frustum. This function should be called every frame.

Arguments

  • Node[] nodes - Nodes array to be updated.

int addWorld(string name)

Loads a world from a file and adds it to the current world.

Arguments

Return value

1 if the world is loaded and added successfully; otherwise, 0.

int clearNode(string name)

Clears a cache of a given node.

Arguments

  • string name - File with the node.

Return value

1 if the cache is cleared successfully; otherwise, 0.

Node loadNode(string name, int cache = 1)

Loads a node from a file. If the node is loaded successfully, it does not belong to any node hierarchy or list, so be careful and make sure to handle it properly, when it is no longer needed.

Arguments

  • string name - Path to the *.node file.
  • int cache - 1 to use the file cache, 0 not to use.

Return value

Loaded node; NULL if the node cannot be loaded.

int loadNodes(string name, Node[] nodes)

Loads nodes from a file.

Arguments

  • string name - Path to the *.node file.
  • Node[] nodes - Array of nodes' smart pointers to which the loaded nodes are appended.

Return value

1 if the nodes are loaded successfully; otherwise, 0.

int saveNode(string name, Node node, int binary = 0)

Saves a given node to a file.

Arguments

  • string name - Path to the *.node file.
  • Node node - Pointer to the node to save.
  • int binary - If set to 1, the node is saved to the binary *.xml. This file cannot be read, but using it speeds up the saving of the node and requires less disk space.

Return value

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

int saveNodes(string name, Node[] nodes, int binary = 0)

Saves nodes to a file.

Arguments

  • string name - Path to the *.node file.
  • Node[] nodes - Array of nodes' smart pointers to be saved.
  • int binary - If set to 1, the node is saved to the binary *.xml. This file cannot be read, but using it speeds up the saving of the node and requires less disk space.

Return value

1 if the nodes are saved successfully; otherwise, 0.

void updateSpatial()

Updates the node BSP (binary space partitioning) tree.

The engine calls this method automatically each frame after the world script update() code is executed. As a new node becomes a part of the BSP tree only after this method is called, all engine subsystems (renderer, physics, sound, pathfinding, collisions, intersections, etc.) can process this node only in the next frame. If you need the subsystem to process the node in the very first frame, you can call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.

Last update: 2018-06-04
Build: ()