This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
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
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.

engine.world Functions

Describes how to load the world with all its nodes, manage a spatial tree and handle nodes collisions and intersections.

World Class

Members


Node engine.world.getAsyncNode(int id)

Gets the loaded node. If the loaded node consists of multiple objects, a new dummy object to combine them is created and its smart pointer is returned.

Arguments

Return value

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

void engine.world.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 engine.world.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.

void engine.world.setData(string data)

Updates user data associated with the node.

Arguments

  • string data - New user data.

string engine.world.getData()

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

Return value

User string data.

void engine.world.setDistance(float distance)

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

Arguments

  • float distance - New distance in units.

float engine.world.getDistance()

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

Return value

Distance in units.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, Vector<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 list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • Vector<Node> exclude - The list of objects IDs to exclude.
  • Vec3 * ret_point - The variable.
  • 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

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundFrustum bf, Vector<Object> & objects)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundFrustum bf - The start point coordinates.
  • Vector<Object> & objects - The end point coordinates.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundSphere bs, Vector<Node> & nodes)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundSphere bs - The start point coordinates.
  • Vector<Node> & nodes - The end point coordinates.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(Vec3 p0, Vec3 p1, Vector<Object> & objects)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • Vector<Object> & objects - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.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 list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • Vec3 * ret_point - The list of objects IDs to exclude.
  • vec3 * ret_normal - The variable.
  • 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

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundSphere bs, int type, Vector<Node> & nodes)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundSphere bs - The start point coordinates.
  • int type - The end point coordinates.
  • Vector<Node> & nodes - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundBox bb, int type, Vector<Node> & nodes)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundBox bb - The start point coordinates.
  • int type - The end point coordinates.
  • Vector<Node> & nodes - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, WorldIntersectionTexCoord v)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • WorldIntersectionTexCoord v - The list of objects IDs to exclude.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, Vector<Node> exclude, WorldIntersection v)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • Vector<Node> exclude - The list of objects IDs to exclude.
  • WorldIntersection v - The variable.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, WorldIntersection v)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • WorldIntersection v - The list of objects IDs to exclude.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, Vector<Node> exclude, WorldIntersectionTexCoord v)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • Vector<Node> exclude - The list of objects IDs to exclude.
  • WorldIntersectionTexCoord v - The variable.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, WorldIntersectionNormal v)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • WorldIntersectionNormal v - The list of objects IDs to exclude.

Return value

The reference to the first intersected object, if found; otherwise - 0.

Object engine.world.getIntersection(Vec3 p0, Vec3 p1, int mask, Vector<Node> exclude, WorldIntersectionNormal v)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • Vec3 p0 - The start point coordinates.
  • Vec3 p1 - The end point coordinates.
  • int mask - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.
  • Vector<Node> exclude - The list of objects IDs to exclude.
  • WorldIntersectionNormal v - The variable.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundFrustum bf, int type, Vector<Node> & nodes)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundFrustum bf - The start point coordinates.
  • int type - The end point coordinates.
  • Vector<Node> & nodes - An intersection mask.
    Notice
    If 0 is passed, the function will return NULL.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundBox bb, Vector<Object> & objects)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundBox bb - The start point coordinates.
  • Vector<Object> & objects - The end point coordinates.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundSphere bs, Vector<Object> & objects)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundSphere bs - The start point coordinates.
  • Vector<Object> & objects - The end point coordinates.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.getIntersection(WorldBoundBox bb, Vector<Node> & nodes)

Performs tracing from the p0 point to the p1 point to find the list of objects intersecting the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects. An intersection is 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. A per-surface Intersectionflag is enabled.
  2. An Intersectionoption of the property in theProperties window is enabled.
  3. A surface is enabled.
  4. A surface has an assigned material.
  5. A surface has an assigned property.

Depending on the variable passed as an argument, the result will be presented as following:

Arguments

  • WorldBoundBox bb - The start point coordinates.
  • Vector<Node> & nodes - The end point coordinates.

Return value

The reference to the first intersected object, if found; otherwise - 0.

int engine.world.isLoaded()

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

Return value

1 if the world is loaded; otherwise, 0.

void engine.world.setName(string name)

Assigns a new name to an editable world.

Arguments

  • string name - Name of the world.

string engine.world.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 current world.

Node engine.world.getNode(int id)

Returns a node by its ID. This can be any node: either created in scripts or loaded from the *.world file.
Notice
See also engine.editor.getNodeByName()andengine.editor.getNode()functions to get nodes loaded from the*.world file.

Arguments

  • int id - Node ID.

Return value

Requested node, if found (NULL otherwise).

int engine.world.isNode(int id)

Checks a given node for validity. Either a node itself can be passed or the node ID.

Arguments

  • int id - A node or its ID to test.

Return value

1 if the variable holds a valid Node instance; otherwise, 0.

void engine.world.getNodes(Vector<Node> & nodes)

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

Arguments

  • Vector<Node> & nodes - Return array with node smart pointers.

int engine.world.getNumQueuedNodes()

Returns the number of queued nodes waiting for the background loading. The return value also includes the currently processed node. To add node for the background loading, use the engine.world.loadAsyncNode()function.

Return value

Number of queued nodes including the currently processed node.

int engine.world.getNumQueuedResources()

Returns the number of queued resources waiting for the background loading. The return value also includes the currently processed node.

Return value

Number of queued resources including the currently processed resource.

int engine.world.getNumUpdateNodes()

Returns the number of currently updating nodes in the world.

Return value

Number of updating nodes.

float engine.world.getTotalTime()

Returns the total time (in milliseconds) of loading a resource.

Return value

The total time value, milliseconds.

Node engine.world.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 engine.world.addUpdateNode(Node node)

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

Arguments

  • Node node - Node to be updated.

int engine.world.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 engine.world.checkAsyncNode(int id)

Checks if the node is in the loading queue or already loaded.

Arguments

Return value

1 if the node is in the loading queue or already loaded; otherwise, 0.

int engine.world.clearNode(string name)

Clears a cache of the given NodeReference.

Arguments

  • string name - File with the node.

Return value

1 if the cache was successfully cleaned; otherwise, 0.

int engine.world.forceAsyncNode(int id)

Forces the loading of the node (the specified node gets the higher priority and will be loaded first).

Arguments

Return value

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

int engine.world.loadAsyncNode(string name, int group = 0, float weight = 0.0f)

Loads the node with the specified group and priority to the thread.

Arguments

  • string name - The name of the node.
  • int group - The number of the node group.
  • float weight - The priority of the node.

Return value

The loading operation identifier.

int engine.world.removeAsyncNode(int id)

Removes the node from the loading queue.

Arguments

Return value

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

void engine.world.updateSpatial()

Updates the BSP tree. This function is automatically called each frame. This function is called manually if a new object was added through the script and it needs to participate in spatial intersection during one and the same frame. Or if you have moved the node, and then want to get callbacks on basis of changed position in the same frame.
You may want to call updateSpatial() before: You can call updateSpatial() several times during one frame, but do not use it once too many times. It is more rational to change position of all required nodes first and only after that call updateSpatial().
Last update: 2017-07-03
Build: ()