This page has been translated automatically.
编程
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
应用程序接口
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Editor Class

Header:#include <UnigineEditor.h>

This class provides functionality for the editor script that loads and manages the hierarchy of nodes displayed in the editor.

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

Editor Class

Members


Editor * get()

Returns a pointer to the existing Editor instance.

Return value

A pointer to the Editor instance.

void setData(const char * data)

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

Arguments

  • const char * data - New user data.

const char * 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.

int isEditorPlayer(const Ptr<Player> & player)

Returns a value indicating if the given player is an Editor player.

Arguments

  • const Ptr<Player> & player - A smart pointer to the Player.Player instance.

Return value

1 if the Player is an Editor player; otherwise, 0.

void setEnabled(int enabled)

Enable or disable the editor.

Arguments

  • int enabled - 1 to enable the editor, 0 to disable it.

int isEnabled()

Returns a value of the Enabled parameter. The Enabled parameter controls all internal additional engine processing (for example, reloading of textures when their recording time is changed and so on). For example, the Enabled parameter can be set to 0 when using Syncker in order to increase engine performance (as Syncker operates inside the editor environment and can reduce engine performance).

Return value

1 if the Enabled parameter is set; otherwise, 0.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Vector< Ptr<Node> > & exclude, const Ptr<WorldIntersectionNormal> & intersection)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersectionNormal.

Arguments

  • const Math::Vec3 & p0 - Start point of the line.
  • const Math::Vec3 & p1 - End point of the line.
  • const Vector< Ptr<Node> > & exclude - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
  • const Ptr<WorldIntersectionNormal> & intersection - Pointer to WorldIntersectionNormal.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Ptr<WorldIntersectionTexCoord> & intersection)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersectionTexCoord.

Arguments

  • const Math::Vec3 & p0 - Start point of the line.
  • const Math::Vec3 & p1 - End point of the line.
  • const Ptr<WorldIntersectionTexCoord> & intersection - Pointer to WorldIntersectionTexCoord.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Vector< Ptr<Node> > & exclude, const Ptr<WorldIntersection> & intersection)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersection.

Arguments

  • const Math::Vec3 & p0 - Start point of the line.
  • const Math::Vec3 & p1 - End point of the line.
  • const Vector< Ptr<Node> > & exclude - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
  • const Ptr<WorldIntersection> & intersection - Pointer to WorldIntersection.

Return value

Returns the first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Vector< Ptr<Node> > & exclude, const Ptr<WorldIntersectionTexCoord> & intersection)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersectionTexCoord.

Arguments

  • const Math::Vec3 & p0 - Start point of the line.
  • const Math::Vec3 & p1 - End point of the line.
  • const Vector< Ptr<Node> > & exclude - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
  • const Ptr<WorldIntersectionTexCoord> & intersection - Pointer to WorldIntersectionTexCoord.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Vector< Ptr<Node> > & exclude, Math::Vec3 * ret_point, Math::vec3 * ret_normal, Math::vec4 * ret_texcoord, int * ret_index, int * ret_surface)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned.

Arguments

  • const Math::Vec3 & p0 - Coordinates of the line start point.
  • const Math::Vec3 & p1 - Coordinates of the line end point.
  • const Vector< Ptr<Node> > & exclude - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
  • Math::Vec3 * ret_point - Intersection point of the line and object.
  • Math::vec3 * ret_normal - Normal vector to the intersection point.
  • Math::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 number.
  • int * ret_surface - Intersected surface number.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, Math::Vec3 * ret_point, Math::vec3 * ret_normal, Math::vec4 * ret_texcoord, int * ret_index, int * ret_surface)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned.

Arguments

  • const Math::Vec3 & p0 - Coordinates of the line start point.
  • const Math::Vec3 & p1 - Coordinates of the line end point.
  • Math::Vec3 * ret_point - Intersection point of the line and object.
  • Math::vec3 * ret_normal - Normal vector to the intersection point.
  • Math::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 number.
  • int * ret_surface - Intersected surface number.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Ptr<WorldIntersection> & intersection)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersection.

Arguments

  • const Math::Vec3 & p0 - Start point of the line.
  • const Math::Vec3 & p1 - End point of the line.
  • const Ptr<WorldIntersection> & intersection - Pointer to WorldIntersection.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

Ptr<Node> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, const Ptr<WorldIntersectionNormal> & intersection)

Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersectionNormal.

Arguments

  • const Math::Vec3 & p0 - Start point of the line.
  • const Math::Vec3 & p1 - End point of the line.
  • const Ptr<WorldIntersectionNormal> & intersection - Pointer to WorldIntersectionNormal.

Return value

The first intersected node smart pointer if found; otherwise, NULL pointer.

int isLoaded()

Returns a value indicating if the editor is already loaded.

Return value

Returns 1 if the editor is loaded; otherwise, 0.

Ptr<Node> getNode(int num)

Returns the editor node by its index in the list of editor nodes.

Arguments

  • int num - Node index.

Return value

Editor node.

int isNode(const Ptr<Node> & node)

Checks if a given node belongs to the editor.

Arguments

  • const Ptr<Node> & node - Node pointer.

Return value

Returns 1 if the node belongs to the editor; otherwise, 0.

Ptr<Node> getNodeById(int node_id)

Returns the editor node by its identifier.

Arguments

  • int node_id - Node ID.

Return value

Node, if it is in the list of editor nodes; otherwise, 0.

Ptr<Node> getNodeByName(const char * name)

Returns the editor node by its name.

Arguments

  • const char * name - Name of the node.

Return value

Node, if it is in the list of editor nodes; otherwise, 0.

void setNodeIndex(const Ptr<Node> & n, int index)

Sets a new index for the given node in the list of editor nodes. This function is used to change the nodes hierarchy in the editor.

Arguments

  • const Ptr<Node> & n - Node.
  • int index - Node index.

int getNodeIndex(const Ptr<Node> & n)

Returns the index of the given node in the list of editor nodes. This function is useful when you need to change the nodes hierarchy in the editor.

Arguments

  • const Ptr<Node> & n - Node.

Return value

Node index.

const char * 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.

int getNumNodes()

Returns the number of editor nodes loaded from the *.world file or belonging to the node list of the editor.

Return value

Number of editor nodes.

void setPlayer(const Ptr<Player> & player)

Sets the player to be used in the editor. Editor player is handled differently than in-game players. Parameters set directly for the player are ignored; instead, editor player uses camera parameters set via the interface.

Arguments

  • const Ptr<Player> & player - Editor player to set.

Ptr<Player> getPlayer()

Returns the current player used in the editor.

Return value

Current editor player.

int isRuntimeNode(const Ptr<Node> & node)

Returns a value indicating if the node has been created in runtime. All nodes created in runtime in the world script will be deleted on quitting the world.

Arguments

  • const Ptr<Node> & node - Node to check.

Return value

1 if the node has been created in runtime; otherwise, 0.

void addEditorPlayer(const Ptr<Player> & player)

Adds another editor player.

Arguments

  • const Ptr<Player> & player - Pointer to Player.

int addNode(const Ptr<Node> & node, int is_runtime_node = 0)

Appends a given node to UnigineEditor.
Notice
The node can have only one owner, so before appending it to the Unigine Editor, its ownership by a script must be removed. Otherwise, it can result in a double deletion at the same address and engine crash.

Arguments

  • const Ptr<Node> & node - Pointer to Node.
  • int is_runtime_node - A value indicating if the node should be deleted on quitting the world: 1 to delete the node; 0 to save the node.

Return value

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

void 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 findNode(const char * name)

Searches an editor node by its name.

Arguments

  • const char * name - Name of the node.

Return value

Node index if the node is found; otherwise, -1.

int findNodeById(int node_id)

Searches for the node by ID.

Arguments

  • int node_id - Node ID.

Return value

1 if the node is found; otherwise, 0.

void load(const char * script = "editor/editor.cpp", int legacy_mode = 1)

Loads the editor from the specified script.

Arguments

  • const char * script - Path to the script.
  • int legacy_mode - A flag indicating whether the old or the new editor settings will be used.

int needReload()

Returns a value indicating if Unigine Editor should be reloaded.

Return value

1 if the editor should be reloaded; otherwise, 0.

void quit()

Quit the editor.

int releaseNode(const Ptr<Node> & node, int recursion = 0)

Releases a given node so it is not owned by the editor (made orphan).

Arguments

  • const Ptr<Node> & node - Node to be released.
  • int recursion - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.

Return value

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

void reload()

Reloads the Unigine Editor. This functions updates node hierarchy, updates loaded textures if they were modified, etc.

void removeEditorPlayer(const Ptr<Player> & player)

Removes a given player from the editor.

Arguments

  • const Ptr<Player> & player - Pointer to Player.

int removeNode(const Ptr<Node> & node, int recursion = 0)

Removes a given node from the editor.

Arguments

  • const Ptr<Node> & node - Node to remove.
  • int recursion - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.

Return value

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

int swapNodes(const Ptr<Node> & n0, const Ptr<Node> & n1)

Swaps positions of given nodes in the list of editor nodes.

Arguments

  • const Ptr<Node> & n0 - First node to swap.
  • const Ptr<Node> & n1 - Second node to swap.

Return value

1 if swapping was done successfully; otherwise, 0.

int updateNode(const Ptr<Node> & node, int recursion = 0)

Updates the target node.

Arguments

  • const Ptr<Node> & node - Pointer to Node.
  • int recursion - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.

Return value

1 if the nodes array was updated successfully; otherwise, 0.

int updateNodes(const Vector< Ptr<Node> > & nodes, int recursion = 0)

Updates the target array of nodes.

Arguments

  • const Vector< Ptr<Node> > & nodes - Pointer to nodes array.
  • int recursion - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.

Return value

1 if the nodes array was updated successfully; otherwise, 0.

void videoRestart()

Restarts the video application to apply changes to video settings, if any.
Last update: 2017-07-03
Build: ()