This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
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.

ObjectGuiMesh Class

This class allows for rendering GUI onto an arbitrary mesh. Unlike ObjectGui, it can be used to create non-flat displays positioned in the world. If the mesh contains several surfaces, the same GUI will be rendered on each of them. Note that the GUI will be rendered according to the UV mapping of surfaces.

The following samples demonstrate the ObjectGuiMesh class usage:

See Also

ObjectGuiMesh Class

This class inherits from Object

Members


ObjectGuiMesh (variable v, string name = 0, int dynamic = 0)

An ObjectGuiMesh constructor. The ObjectGuiMesh will be created on the basis of the specified mesh.

Arguments

  • variable v - Variable of one of the following types:
    • Mesh mesh - The source mesh.
    • string name - The path to the .mesh file.
  • string name - Name of the new GUI mesh.
  • int dynamic - Dynamic flag:
    • 0 - If the mesh vertices are changed in run-time, meshes loaded from the same file will be also changed.
    • 1 - If the mesh vertices are changed in run-time, meshes loaded from the same file won't be changed.
    Notice
    This argument is available only if the first argument is string.

int createMesh (string name, int dynamic = 0)

Creates the GUI mesh with the specified parameters.

Arguments

  • string name - Path to the *.mesh file.
  • int dynamic - Dynamic flag:
    • 0 - If the mesh vertices are changed in run-time, meshes loaded from the same file will be also changed.
    • 1 - If the mesh vertices are changed in run-time, meshes loaded from the same file won't be changed

Return value

1 if the mesh is created successfully; otherwise - 0.

void flushMesh ()

Flushes the mesh geometry into the video memory.

float getControlDistance ()

Returns the distance, at which the GUI becomes controllable.

Return value

Distance in units.

Gui getGui ()

Returns a Gui instance associated with the object. This function is used when assigning a widget to the GUI mesh.
Notice
When you create an instance of the ObjectGuiMesh class, it is automatically associated with a Gui instance.

Return value

GUI associated with the object.

Examples

To get the GUI and assign a widget to it, you can use the following:

Source code (UnigineScript)
// create an instance of the ObjectGuiMesh class
ObjectGuiMesh object_gui_mesh = add_editor(new ObjectGuiMesh("samples/objects/meshes/gui_01.mesh"));
// get a GUI associated with the GUI mesh
Gui gui = object_gui_mesh.getGui();
// create a widget to be assigned
WidgetSpriteVideo sprite_video = new WidgetSpriteVideo(gui,"samples/objects/videos/sanctuary.ogv");
// add a new widget to the GUI mesh
gui.addChild(sprite_video,GUI_ALIGN_EXPAND);
If you add a GUI mesh via UnigineEditor, you should use the engine.editor.getNodeByName() (or engine.editor.getNode() if the node index is known) to get the GUI mesh:
Source code (UnigineScript)
// get the editor node named "ObjectGuiMesh_0" and cast it to ObjectGuiMesh
ObjectGuiMesh object_gui_mesh = class_cast("ObjectGuiMesh",engine.editor.getNodeByName("ObjectGuiMesh_0"));

string getMeshName ()

Returns the name of the mesh.

Return value

Name of the mesh.

int getMesh (Mesh mesh)

Copies the current mesh into the source mesh.

Arguments

  • Mesh mesh - Source mesh.

Return value

1 if the mesh is copied successfully.

int getMouseShow ()

Returns a value indicating if the mouse cursor is rendered in the mesh GUI object.

Return value

1 if the cursor is rendered; otherwise, 0.

int getScreenHeight ()

Returns the screen height of the mesh GUI object.

Return value

Height in pixels.

int getScreenWidth ()

Returns the screen width of the mesh GUI object.

Return value

Width in pixels.

int loadMesh (string name)

Loads a new mesh instead of the current mesh from the .mesh file. This function doesn't change the mesh name.

Arguments

  • string name - The path to the .mesh file.

Return value

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

int saveMesh (string name)

Saves the mesh into the .mesh format.

Arguments

  • string name - The path to the file.

Return value

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

void setControlDistance (float distance)

Sets a distance, at which the GUI becomes controllable.

Arguments

  • float distance - New distance in units. If a negative value is provided, 0 will be used instead.

void setMeshName (string name)

Sets the new name for the mesh.

Arguments

  • string name - Name to be set for the mesh.

int setMesh (Mesh mesh)

Copies the source mesh into the current mesh.

Arguments

  • Mesh mesh - The source mesh to be copied.

Return value

1 if the mesh is copied successfully; otherwise, 0.

void setMouseShow (int show)

Sets a value indicating if the mouse cursor should be rendered in the mesh GUI object.

Arguments

  • int show - Positive number to render the mouse cursor; otherwise, 0.

void setScreenSize (int width, int height)

Sets screen dimensions of the mesh GUI object.

Arguments

  • int width - New width in pixels. If a negative value is provided, 0 will be used instead.
  • int height - New height in pixels. If a negative value is provided, 0 will be used instead.
Last update: 2017-07-03
Build: ()