engine.editor Functions
This set of functions is related to the Unigine Engine Editor that loads and manages the hierarchy of nodes displayed in the editor.
int engine.editor.addNode (Node node)
Appends a given node to Unigine Editor.Arguments
- Node node - Node to append.
Return value
1 if the node is appended successfully; otherwise, 0.variable engine.editor.call (variable function)
Executes a function of Unigine Editor from an external script. The function should not take any arguments.Arguments
- variable function - Name of the function to execute.
Return value
Value returned by the function.variable engine.editor.call (variable function, variable arg)
Executes a function of Unigine Editor from an external script. The function should take one argument.Arguments
- variable function - Name of the function to execute.
- variable arg - Argument of the function.
Return value
Value returned by the function.variable engine.editor.call (variable function, variable arg0, variable arg1)
Executes a function of Unigine Editor from an external script. The function should take two arguments.Arguments
- variable function - Name of the function to execute.
- variable arg0 - Argument of the function.
- variable arg1 - Argument of the function.
Return value
Value returned by the function.variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2)
Executes a function of Unigine Editor from an external script. The function should take three arguments.Arguments
- variable function - Name of the function to execute.
- variable arg0 - Argument of the function.
- variable arg1 - Argument of the function.
- variable arg2 - Argument of the function.
Return value
Value returned by the function.variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2, variable arg3)
Executes a function of Unigine Editor from an external script. The function should take four arguments.Arguments
- variable function - Name of the function to execute.
- variable arg0 - Argument of the function.
- variable arg1 - Argument of the function.
- variable arg2 - Argument of the function.
- variable arg3 - Argument of the function.
Return value
Value returned by the function.variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2, variable arg3, variable arg4)
Executes a function of Unigine Editor from an external script. The function should take five arguments.Arguments
- variable function - Name of the function to execute.
- variable arg0 - Argument of the function.
- variable arg1 - Argument of the function.
- variable arg2 - Argument of the function.
- variable arg3 - Argument of the function.
- variable arg4 - Argument of the function.
Return value
Value returned by the function.variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2, variable arg3, variable arg3, variable arg6)
Executes a function of Unigine Editor from an external script. The function should take six arguments.Arguments
- variable function - Name of the function to execute.
- variable arg0 - Argument of the function.
- variable arg1 - Argument of the function.
- variable arg2 - Argument of the function.
- variable arg3 - Argument of the function.
- variable arg3 - Argument of the function.
- variable arg6 - Argument of the function.
Return value
Value returned by the function.variable engine.editor.callv (variable function, int id)
Executes a function of the editor from an external script. The function takes an array of arguments (up to 8 arguments are supported).Arguments
- variable function - Name of the function to execute.
- int id - Array of up to 8 arguments.
Return value
Value returned by the function.void engine.editor.clearBindings ()
Clears internal buffers with pointers and instances. This function is used for proper cloning of objects with hierarchies, for example, bodies and joints. Should be called before cloning.int engine.editor.findNode (string name)
Searches for a node by its name.Arguments
- string name - Name of the node.
Return value
Node index if the node is found; otherwise, -1.Node engine.editor.getIntersection (vec3 p0, vec3 p1, int ret_id)
Traces a line from one point to another to find an object located on that line. This function detects intersection with all the editor nodes regardless of them having or not having intersection flag. It also takes into account object handlers. This function does not work for disabled objects.
World space coordinates are used for this function.
Arguments
- vec3 p0 - Start of the line.
- vec3 p1 - End of the line.
- int ret_id - Return array, its components are:
- ret[0]: intersection point (vec3), in the world coordinates.
- ret[1]: normal of the intersection point (vec3), in the world coordinates.
- ret[2]: surface number.
Return value
The first node found on the line or 0 if no nodes are found.Node engine.editor.getIntersection (vec3 p0, vec3 p1, int exclude_id, int ret_id)
Traces a line from one point to another to find an object located on that line, skipping objects from a given list. This function takes into account editor-only objects (object handlers). Intersection does not work for disabled objects.
World space coordinates are used for this function.
Arguments
- vec3 p0 - Start point of the line.
- vec3 p1 - Destination point of the line.
- int exclude_id - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
- int ret_id -
Return array, its components are:
- ret[0]: intersection point (vec3), in the world coordinates.
- ret[1]: normal of the intersection point (vec3), in the world coordinates.
- ret[2]: surface number.
Return value
Reference to the first crossed object or NULL (0), if no object is crossed.Node engine.editor.getNodeByName (string name)
Returns a node (loaded from the *.world file or belonging to the node list of Unigine Editor) by its name.Arguments
- string name - Name of the node.
Return value
Node, if it exists; otherwise, 0.string engine.editor.getNodeName (int num)
Returns a name of a given node (loaded from the *.world file or belonging to the node list of Unigine Editor) by its index in the list of editor nodes.Arguments
- int num - Node index in the list of editor nodes.
Return value
Name of the node.Node engine.editor.getNode (int num)
Returns a node (loaded from the *.world file or belonging to the node list of Unigine Editor) by its index in the list of editor nodes.Arguments
- int num - Node index in the list of editor nodes.
Return value
Node with the provided index.int engine.editor.getNumNodes ()
Returns the number of nodes loaded from the *.world file or belonging to the node list of Unigine Editor.Return value
Number of nodes in the list.Player engine.editor.getPlayer ()
Returns the current player used in the Editor mode.Return value
Current player.variable engine.editor.get (string var)
Returns a variable from the editor script. Instances of user-defined classes cannot be requested in such a manner.Arguments
- string var - Variable name with a namespace, if needed.
Return value
Requested instance.int engine.editor.isLoaded ()
Checks if Unigine Editor is already loaded.Return value
1 if the editor is loaded; otherwise, 0.int engine.editor.isNode (Node node)
Checks if a given node belongs to Unigine Editor.Arguments
- Node node - Node to check.
Return value
1 if the node belongs to Unigine Editor; otherwise, 0.Node engine.editor.loadMesh (string filename)
Loads a mesh from a file. If the mesh is loaded successfully, its node does not belong to any node hierarchy, so be careful and make sure to handle it properly, when it is no longer needed.Arguments
- string filename - File with a mesh.
Return value
Node of a type corresponding to the loaded mesh or 0, if the mesh cannot be loaded.int engine.editor.needReload ()
Returns a value indicating if Unigine Editor should be reloaded.Return value
1 if the editor should be reloaded; otherwise, 0.int engine.editor.releaseNode (Node node)
Release the current node so it is not owned by Unigine Editor (made orphan).Arguments
- Node node - Node to be released.
Return value
1 if the node is released successfully; otherwise, 0void engine.editor.reload ()
Reloads the Unigine Editor. This functions updates node hierarchy, updates loaded textures if they were modified, etc.int engine.editor.removeNode (Node node)
Completely removes a given node.Arguments
- Node node - Node to remove.
Return value
1 if the node is removed successfully; otherwise, 0.int engine.editor.renderLightMapDirect (Object object, int surfaces, int blur, int width, int height, Image image)
Creates the light map for specified objects, whereto scene direct lighting is baked.Arguments
- Object object - Target object.
- int surfaces - Array of object surface indices.
- int blur - Blur size. It is the number of neighboring source pixels (from all sides) that are averaged for each blurred destination pixel. For example, if blur = 2, two pixels from each side are and the blurring kernel is 5x5 pixels.
- int width - Width of the light map.
- int height - Height of the light map.
- Image image - Image to store the light map.
Return value
1 if the light map is successfully created; otherwise, 0.int engine.editor.renderLightMapIndirect (Object object, int surfaces, int samples, float radius, int width, int height, Image image)
Renders the light map for the specified objects, whereto scene indirect lighting is baked using light probs.Arguments
- Object object - Target object.
- int surfaces - Array of object surface indices.
- int samples - The number of rays traced to calculate ambient occlusion.
- float radius - The length of traced rays for ambient occlusion. The smaller the number, the lighter result will be.
- int width - Width of the light map.
- int height - Height of the light map.
- Image image - Image to store the light map.
Return value
1 if the light map is successfully created; otherwise, 0.int engine.editor.saveMesh (string filename, int id)
Saves a mesh into a file. Note that only enabled surfaces will be saved, which makes it possible to save only certain surfaces.Arguments
- string filename - File, in which a mesh is going to be stored.
- int id - Mesh identifier.
Return value
1 if the mesh is saved successfully; otherwise, 0.void engine.editor.setPlayer (Player player)
Sets the current player to be used in the Editor mode.Arguments
- Player player - Player to set as current.
void engine.editor.set (string name, variable variable)
Set a variable in an editor script (this function can be called directly from any other script).Arguments
- string name - Variable name.
- variable variable - Value of the variable.
int engine.editor.swapNodes (Node n0, Node n1)
Swaps positions of given nodes in the list of editor nodes.Arguments
- Node n0 - First node to swap.
- Node n1 - Second node to swap.