# ObjectGuiMesh Class (CPP) **Header:** #include **Inherits from:** Object This class allows for rendering [GUI](../../../objects/objects/gui/gui_mesh.md) onto an arbitrary mesh. Unlike [ObjectGui](../../../api/library/objects/class.objectgui_cpp.md), 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. ### See Also UnigineScript sample ## ObjectGuiMesh Class ### Members ## int getScreenHeight () const Returns the current screen height of the mesh GUI object. ### Return value Current screen height of the mesh GUI object ## int getScreenWidth () const Returns the current screen width of the mesh gui object. ### Return value Current screen width of the mesh gui object ## void setControlDistance ( float distance ) Sets a new distance at which the GUI becomes controllable. ### Arguments - *float* **distance** - The distance at which the GUI becomes controllable ## float getControlDistance () const Returns the current distance at which the GUI becomes controllable. ### Return value Current distance at which the GUI becomes controllable ## void setMouseMode ( int mode ) Sets a new mouse mode. One of the [MOUSE_*](#MOUSE_VIRTUAL) variables. ### Arguments - *int* **mode** - The mouse mode ## int getMouseMode () const Returns the current mouse mode. One of the [MOUSE_*](#MOUSE_VIRTUAL) variables. ### Return value Current mouse mode ## void setMouseShow ( bool show ) Sets a new value indicating if the mouse cursor is rendered in the mesh GUI object. ### Arguments - *bool* **show** - value indicating if the mouse cursor is rendered in the mesh GUI object ## bool isMouseShow () const Returns the current value indicating if the mouse cursor is rendered in the mesh GUI object. ### Return value value indicating if the mouse cursor is rendered in the mesh GUI object ## void setBackground ( bool background ) Sets a new value indicating if gui background (black screen) is rendered. ### Arguments - *bool* **background** - value indicating if gui background (black screen) is rendered ## bool isBackground () const Returns the current value indicating if gui background (black screen) is rendered. ### Return value value indicating if gui background (black screen) is rendered ## Ptr < Gui > getGui () const Returns the current [gui](../../../api/library/gui/class.gui_cpp.md) instance associated with the object. ### Return value Current gui instance associated with the object ## void setMeshPath ( const char * path ) Sets a new path to the source *.mesh*-file used for the object. > **Notice:** Setting a new path does not update the mesh immediately, and if the mesh is in the procedural mode, it will be reset. The mesh should contain a single surface; in case the mesh contains several surfaces, only the one with the 0 index will be used. ### Arguments - *const char ** **path** - The path to the source .mesh-file used for the object ## const char * getMeshPath () const Returns the current path to the source *.mesh*-file used for the object. > **Notice:** Setting a new path does not update the mesh immediately, and if the mesh is in the procedural mode, it will be reset. The mesh should contain a single surface; in case the mesh contains several surfaces, only the one with the 0 index will be used. ### Return value Current path to the source .mesh-file used for the object ## bool isMeshLoadedVRAM () const Returns the current value indicating if the source mesh used for the object is loaded to video memory (VRAM). ### Return value **true** if the source mesh used for the object is loaded to video memory (VRAM); otherwise **false**. ## bool isMeshLoadedRAM () const Returns the current value indicating if the source mesh used for the object is loaded to memory (RAM). ### Return value **true** if the source mesh used for the object is loaded to memory (RAM); otherwise **false**. ## bool isMeshNull () const Returns the current value indicating if the source mesh used for the object is null (does not exist, unassigned, not loaded, etc.). ### Return value **true** if the source mesh used for the object is null (does not exist, unassigned, not loaded, etc.); otherwise **false**. ## ObjectMeshStatic::PROCEDURAL_MODE getMeshProceduralMode () const Returns the current value indicating which procedural mesh generation mode assigned to the mesh. The value corresponds to one of the available *[PROCEDURAL_MODE](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE)* types, determining how procedural data is stored, updated, and unloaded. ### Return value Current procedural mesh generation mode assigned to the mesh ## bool isMeshProceduralDynamic () const Returns the current value indicating if the current procedural mode is *[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*. ### Return value **true** if the current procedural mode is PROCEDURAL_MODE_DYNAMIC; otherwise **false**. ## bool isMeshProceduralActive () const Returns the current value indicating if an asynchronous operation on the procedural mesh is currently in progress. ### Return value **true** if an asynchronous operation on the procedural mesh is currently in progress; otherwise **false**. ## bool isMeshProceduralDone () const Returns the current value indicating if all asynchronous operations on the procedural mesh have completed. ### Return value **true** if all asynchronous operations on the procedural mesh have completed; otherwise **false**. --- ## static ObjectGuiMeshPtr create ( const char * mesh_path , const char * name = 0 ) An ObjectGuiMesh constructor. The *Gui Mesh* will be created on the basis of the mesh loaded from the specified path. ### Arguments - *const char ** **mesh_path** - Path to the source *.mesh*-file used for the object - *const char ** **name** ## static ObjectGuiMeshPtr create ( ) Constructor. Creates a new *Gui Mesh* object. ## void setMouse ( const Math:: Vec3 & p0 , const Math:: Vec3 & p1 , int mouse_buttons , bool mouse_show ) Sets mouse cursor position in the [virtual control mode](#MOUSE_VIRTUAL). ### Arguments - *const Math::[Vec3](../../../api/library/math/class.vec3_cpp.md) &* **p0** - Start point. A line segment between the start and the end points must intersect ObjectGui. The point of intersection determines x and y coordinates on the ObjectGui. - *const Math::[Vec3](../../../api/library/math/class.vec3_cpp.md) &* **p1** - End point. A line segment between the start and the end points must intersect ObjectGui. The point of intersection determines x and y coordinates on the ObjectGui. - *int* **mouse_buttons** - Mouse button status. Set 1 to indicate that the button is clicked; otherwise, 0. - *bool* **mouse_show** - Mouse cursor status. Set 1 to show 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. ## static int type ( ) Returns the type identifier of *ObjectMeshStatic*. ### Return value *ObjectMeshStatic* type identifier. ## Ptr getMeshCurrentRAM ( ) const Returns the current source mesh used for the object and loaded to memory (RAM). ### Return value A current source mesh used for the object. ## Ptr < MeshRender > getMeshCurrentVRAM ( ) Returns the current render mesh used for the object and loaded to video memory (VRAM). ### Return value A current render mesh used for the object. ## Ptr getMeshForceRAM ( ) Returns the source mesh used for the object and loads it to memory (RAM) immediately. ### Return value A source mesh used for the object. ## Ptr < MeshRender > getMeshForceVRAM ( ) Returns the render mesh used for the object and loads it to video memory (VRAM) immediately. At that, the static mesh will also be loaded to memory (RAM). > **Notice:** Loading to VRAM must be performed in the main thread only. ### Return value A render mesh used for the object. ## Ptr getMeshAsyncRAM ( ) Returns the source mesh used for the object and loads it to memory (RAM) asynchronously. ### Return value A source mesh used for the object. ## Ptr < MeshRender > getMeshAsyncVRAM ( ) **[ Main Thread ]**Returns the render mesh used for the object and loads it to video memory (VRAM) asynchronously. At that, the static mesh will also be loaded to memory (RAM). > **Notice:** Loading to VRAM must be performed in the main thread only. ### Return value A render mesh used for the object. ## Ptr < Mesh > getMeshDynamicRAM ( ) Returns the procedural source mesh associated with the object and ensures it is loaded into system memory (RAM). This method is only available when the mesh is in the **dynamic** (*[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*) mode. A *procedural mesh* is a mesh created via code and uses a specific streaming mode. In *[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*, the object stays in memory after creation and is only unloaded manually using *[deleteDynamicMesh()](../../../api/library/objects/class.objectmeshstatic_cpp.md#deleteDynamicMesh_int)* or when the procedural mode is changed. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Return value A procedural source mesh used for the object. ## Ptr < MeshRender > getMeshDynamicVRAM ( ) Returns the procedural render mesh associated with the object and ensures it is loaded into video memory (VRAM). This method is only available when the mesh is in the **dynamic** (*[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*) mode. A *procedural mesh* is a mesh created via code and uses a specific streaming mode. In *[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*, the object stays in memory after creation and is only unloaded manually using *[deleteDynamicMesh()](../../../api/library/objects/class.objectmeshstatic_cpp.md#deleteDynamicMesh_int)* or when the procedural mode is changed. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Return value A procedural render mesh used for the object. ## bool loadAsyncVRAM ( ) **[ Main Thread ]**Asynchronously loads the mesh to video memory (VRAM) if the [async streaming mode for meshes](../../../api/library/rendering/class.render_cpp.md#STREAMING_MODE) is enabled. Otherwise, the [forced](#loadForceVRAM_bool) loading is performed. This method is recommended for implementing your own prefetch system (i.e. asynchronous pre-loading of meshes to video memory before they are used). > **Notice:** Loading to VRAM must be performed in the main thread only. ### Return value true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to VRAM, true will be returned. ## bool loadAsyncRAM ( ) Asynchronously loads the mesh to memory (RAM) if the [async streaming mode for meshes](../../../api/library/rendering/class.render_cpp.md#STREAMING_MODE) is enabled. Otherwise, the [forced](#loadForceRAM_bool) loading is performed. This method is recommended for implementing your own prefetch system (i.e. asynchronous pre-loading of meshes to memory before they are used). ### Return value true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to RAM, true will be returned. ## bool loadForceVRAM ( ) Performs force-loading of the mesh to video memory (VRAM) immediately. The forced loading to VRAM is performed in the main thread. > **Notice:** Loading to VRAM must be performed in the main thread only. ### Return value true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to VRAM, true will be returned. ## bool loadForceRAM ( ) Performs force-loading of the mesh to memory (RAM) immediately. ### Return value true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to RAM, true will be returned. ## void setMeshProceduralMode ( ObjectMeshStatic::PROCEDURAL_MODE mode , int mesh_render_flags = 0 ) Sets the procedural mode for the mesh. The specified mode defines how procedural data is stored, updated, and unloaded. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[ObjectMeshStatic::PROCEDURAL_MODE](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE)* **mode** - One of the *[PROCEDURAL_MODE](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE)* to apply to the mesh. - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) that control how vertex and index data are stored for the mesh render. ## Ptr < Mesh > createCopyMeshRAM ( ) const Creates and returns a copy of the source mesh used by the object, loading it directly from disk if it is not present in cache. This method does not stream the copied mesh into memory cache, resulting in lower RAM usage. ### Return value A copy of the source mesh, or nullptr if source mesh is not presented in RAM or its file path is invalid. ## bool getCopyMeshRAM ( Ptr < Mesh > & result ) const Retrieves a copy of the source mesh used by the object and writes it to the provided mesh object. If the mesh is not present in cache, it is loaded directly from disk. This method does not stream the copied mesh into memory cache, resulting in lower RAM usage. ### Arguments - *[Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)> &* **result** - Object that will receive a copy of the source mesh. ### Return value true if the mesh was copied successfully, false if source mesh is not present in RAM or its file path is invalid. ## bool applyCopyMeshProceduralForce ( const Ptr & mesh , int mesh_render_flags = 0 ) **[ Main Thread ]** Copies all vertex data from the given mesh into the object's procedural mesh forcibly, executing the operation immediately. Works only when **procedural mode is enabled**. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[const Ptr &](#ConstMeshPtr)* **mesh** - Source mesh to copy vertex data from. - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the mesh was copied successfully, otherwise false. ## bool applyMoveMeshProceduralForce ( const Ptr < Mesh > & mesh , int mesh_render_flags = 0 ) **[ Main Thread ]** Moves all vertex data from the given mesh into the object's procedural mesh forcibly, executing the operation immediately without memory allocation and data copying (move semantics). In *[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*, this method behaves identically to its asynchronous variant. Works only when **procedural mode is enabled**. This operation **swaps the object's mesh data with the given mesh**. When reusing the same mesh object for further data generation, ensure that its internal state (e.g. number of surfaces) is valid. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *const [Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)> &* **mesh** - Source mesh to move vertex data from. - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the mesh was moved (transferred without copying) successfully, otherwise false. ## bool applyMoveMeshProceduralForce ( const Ptr < Mesh > & mesh_ram , const Ptr < MeshRender > & mesh_vram ) **[ Main Thread ]** Moves all vertex and render data from the given *mesh_ram* and *mesh_vram* into the object's procedural mesh forcibly, executing the operation immediately using move semantics, without data copying or VRAM allocation. Works only when **procedural mode is enabled**. This operation **swaps the object's mesh data with the given mesh**. When reusing the same mesh object for further data generation, ensure that its internal state (e.g. number of surfaces) is valid. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *const [Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)> &* **mesh_ram** - Source mesh containing vertex data. - *const [Ptr](../../../api/library/common/class.ptr_cpp.md)<[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)> &* **mesh_vram** - Source mesh containing render data. ### Return value true if the data was moved (transferred without copying) successfully, otherwise false. ## bool applyCopyMeshProceduralAsync ( const Ptr & mesh , int mesh_render_flags = 0 ) **[ Main Thread ]** Copies all vertex data from the given mesh into the object's procedural mesh asynchronously. The operation is not forced and is executed in the background with no noticeable delay. Works only when **procedural mode is enabled**. In *[PROCEDURAL_MODE_FILE](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_FILE)* and *[PROCEDURAL_MODE_BLOB](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_BLOB)*, this method performs faster compared to the forced variant, as file writes and memory operations are offloaded to background threads. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[const Ptr &](#ConstMeshPtr)* **mesh** - Source mesh to copy vertex data from. - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the mesh was copied successfully, otherwise false. ## bool applyMoveMeshProceduralAsync ( const Ptr < Mesh > & mesh , int mesh_render_flags = 0 ) **[ Main Thread ]** Moves all vertex data from the given mesh into the object's procedural mesh asynchronously. The operation is not forced and is executed in the background with no noticeable delay, without memory allocation and data copying (move semantics). Works only when **procedural mode is enabled**. In *[PROCEDURAL_MODE_FILE](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_FILE)* and *[PROCEDURAL_MODE_BLOB](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_BLOB)*, this method performs faster compared to the forced variant, as file writes and memory operations are offloaded to background threads. This operation **swaps the object's mesh data with the given mesh**. When reusing the same mesh object for further data generation, ensure that its internal state (e.g. number of surfaces) is valid. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *const [Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)> &* **mesh** - Source mesh to copy vertex data from. - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ## bool applyMoveMeshProceduralAsync ( const Ptr < Mesh > & mesh_ram , const Ptr < MeshRender > & mesh_vram ) **[ Main Thread ]** Moves all vertex and render data from the given mesh_ram and mesh_vram into the object's procedural mesh asynchronously, without copying or allocating VRAM. The operation is not forced and is executed in the background with no noticeable delay. Works only when **procedural mode is enabled**. In *[PROCEDURAL_MODE_FILE](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_FILE)* and *[PROCEDURAL_MODE_BLOB](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_BLOB)*, this method performs faster, as file writes and memory operations are offloaded to background threads. In *[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*, this method behaves identically to its forced variant. This operation **swaps the object's mesh data with the given mesh**. When reusing the same mesh object for further data generation, ensure that its internal state (e.g. number of surfaces) is valid. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *const [Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)> &* **mesh_ram** - Source mesh containing vertex data. - *const [Ptr](../../../api/library/common/class.ptr_cpp.md)<[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)> &* **mesh_vram** - Source mesh containing render data. ### Return value true if the data was moved successfully, otherwise false. ## bool deleteDynamicMesh ( ) **[ Main Thread ]** Releases all memory used by the procedural mesh, including both VRAM and RAM. Works only when procedural mode is set to *[PROCEDURAL_MODE_DYNAMIC](../../../api/library/objects/class.objectmeshstatic_cpp.md#PROCEDURAL_MODE_DYNAMIC)*. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Return value true if the memory was released successfully, otherwise false. ## bool runGenerateMeshProceduralAsync ( CallbackBase1 < Ptr < Mesh >> * callback_generate , int mesh_render_flags = 0 ) **[ Main Thread ]** Starts asynchronous generation of procedural mesh data. The *callback_generate* function is executed in a background thread and must create and fill a mesh object with new data. The generated mesh will be transferred to the object once complete, without blocking the main thread. Works only when **procedural mode is enabled**. Note that the callback is executed in a single dedicated thread controlled by the engine, it is not parallelized and must not spawn additional threads. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[CallbackBase1](../../../api/library/common/callbacks/class.callbackbase1_cpp.md)<[Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)>> ** **callback_generate** - Callback function responsible for creating and filling the source mesh. Executed in the main thread. The function must be wrapped using *[MakeCallback()](../../../api/library/common/class.unigine.namespace_cpp.md#MakeCallback_Classm_RetClassm)* and have the following signature: ```cpp void callback_generate(Ptr mesh) ``` - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the modification was completed and applied successfully, otherwise false ## bool runGenerateMeshProceduralAsync ( CallbackBase1 < Ptr < Mesh >> * callback_generate , CallbackBase * callback_done , int mesh_render_flags = 0 ) **[ Main Thread ]** Starts asynchronous generation of procedural mesh data. The *callback_generate* function is executed in a background thread and must create and fill a mesh object with new data. The generated mesh will be transferred to the object once complete, without blocking the main thread. After the mesh has been applied to the object, the optional callback_done will be called. Works only when **procedural mode is enabled**. Note that the callback is executed in a single dedicated thread controlled by the engine, it is not parallelized and must not spawn additional threads. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[CallbackBase1](../../../api/library/common/callbacks/class.callbackbase1_cpp.md)<[Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)>> ** **callback_generate** - Callback function responsible for creating and filling the source mesh. Executed in the main thread. The function must be wrapped using *[MakeCallback()](../../../api/library/common/class.unigine.namespace_cpp.md#MakeCallback_Classm_RetClassm)* and have the following signature: ```cpp void callback_generate(Ptr mesh) ``` - *[CallbackBase](../../../api/library/common/callbacks/class.callbackbase_cpp.md) ** **callback_done** - Optional callback executed after geometry has been fully applied. The function must be wrapped using *[MakeCallback()](../../../api/library/common/class.unigine.namespace_cpp.md#MakeCallback_Classm_RetClassm)* and have the following signature: ```cpp void callback_done() ``` - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the generation was completed and applied successfully, otherwise false ## bool runGenerateMeshProceduralForce ( CallbackBase1 < Ptr < Mesh >> * callback_generate , int mesh_render_flags = 0 ) **[ Main Thread ]** Starts immediate (forced) generation of procedural mesh data. The *callback_generate* function is executed in the main thread and must create and fill a mesh object with new data. The generated mesh is applied to the object as soon as generation completes. Works only when **procedural mode is enabled**. > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[CallbackBase1](../../../api/library/common/callbacks/class.callbackbase1_cpp.md)<[Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)>> ** **callback_generate** - Callback function responsible for creating and filling the source mesh. Executed in the main thread. The function must be wrapped using *[MakeCallback()](../../../api/library/common/class.unigine.namespace_cpp.md#MakeCallback_Classm_RetClassm)* and have the following signature: ```cpp void callback_generate(Ptr mesh) ``` - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the generation was completed and applied successfully, otherwise false ## bool runGenerateMeshProceduralForce ( CallbackBase1 < Ptr < Mesh >> * callback_generate , CallbackBase * callback_done , int mesh_render_flags = 0 ) **[ Main Thread ]** Starts immediate (forced) generation of procedural mesh data. The *callback_generate* function is executed in the main thread and must create and fill a Mesh object with vertex data. Once the mesh is applied to the object, the optional *callback_done* is called on the main thread. Works only when **procedural mode is enabled** > **Notice:** Please note that procedural mesh modification **directly affects streaming and memory usage (RAM, VRAM, and disk)** depending on the selected procedural mode. For details, see the [Procedural Mesh Workflow](#procedural_workflow) section. ### Arguments - *[CallbackBase1](../../../api/library/common/callbacks/class.callbackbase1_cpp.md)<[Ptr](../../../api/library/common/class.ptr_cpp.md)<[Mesh](../../../api/library/rendering/class.mesh_cpp.md)>> ** **callback_generate** - Callback function responsible for creating and filling the source mesh. Executed in the main thread. The function must be wrapped using *[MakeCallback()](../../../api/library/common/class.unigine.namespace_cpp.md#MakeCallback_Classm_RetClassm)* and have the following signature: ```cpp void callback_generate(Ptr mesh) ``` - *[CallbackBase](../../../api/library/common/callbacks/class.callbackbase_cpp.md) ** **callback_done** - Optional callback executed after geometry has been fully applied. The function must be wrapped using *[MakeCallback()](../../../api/library/common/class.unigine.namespace_cpp.md#MakeCallback_Classm_RetClassm)* and have the following signature: ```cpp void callback_done() ``` - *int* **mesh_render_flags** - Optional [usage flags](../../../api/library/rendering/class.meshrender_cpp.md#USAGE_DYNAMIC_VERTEX) for *[MeshRender](../../../api/library/rendering/class.meshrender_cpp.md)*. ### Return value true if the generation was completed and applied successfully, otherwise false