UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
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
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes

Unigine::Plugins::Syncker::Master Class

Warning
The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Sim SDK edition to use it.
Header: #include <plugins/UnigineSyncker.h>
Inherits: Syncker

This class represents the master interface of the Syncker.

Notice
Syncker plugin must be loaded.

Master Class

Enums

CALLBACK_INDEX#

Callback types.
NameDescription
SESSION_STARTED = 0Callback function to be fired on starting a session (all Slaves are connected, MTU is determined).
Callback signature:
Source code
callback_function_name(void)
SESSION_FINISHED = 1Callback function to be fired on closing a session.
Callback signature:
Source code
callback_function_name(void)
SLAVE_CONNECTED = 2Callback function to be fired on successful connection of a new Slave.
Callback signature:
Source code
callback_function_name(int slave_num)
SLAVE_DISCONNECTED = 3Callback function to be fired before disconnecting a Slave. The reason for disconnection specified in string format ("disconnected by slave", "timeout", etc.)
Callback signature:
Source code
callback_function_name(int slave_num, const char *reason)
MASTER_SETUP_CHANGED = 4Callback to be fired on changing settings on the Master.
Callback signature:
Source code
void callback_function_name(void);
SLAVE_SETUP_CHANGED = 5Callback to be fired on changing settings on a Slave.
Callback signature:
Source code
void callback_function_name(int slave_num);

SYNC_MASK#

Node synchronization mask.
NameDescription
NODE_FLAGS = 1Update only simple node flag (enabled, etc.)
TRANSFORM = 1 << 1Update node transform (with interpolation).
DERIVED = 31 << 3Update information of derived class (11111000 - without the first 3 bits).
OBJECT = 1 << 3Update object parameters.
OBJECT_SURFACE = 1 << 4Update surfaces with overridden material params.

DEFAULT_SYNC_NODES#

Types of nodes that will be synchronized automatically after world loading.
NameDescription
LIGHT_WORLD = 1World light. See the LightWorld class.
WATER_GLOBAL = 1 << 1Global water. See the ObjectWaterGlobal class.
CLOUD_LAYER = 1 << 2Cloud layer. See the ObjectCloudLayer class.
OBJECT_PARTICLES = 1 << 3Particle system. See the ObjectParticles class.

Members


int getNumSlaves ( ) #

Returns the total number of the slaves connected to the Master.

Return value

Total number of slaves connected to the Master.

const char * getSlaveAddress ( int num ) #

Returns the network address of the given slave computer.

Arguments

  • int num - Slave number.

Return value

Network address of the slave computer.

int getSlavePort ( int num ) #

Returns the UDP port used by the slave with the specified number.

Arguments

  • int num - Slave number.

Return value

UDP port of the specified slave computer. 0 - means any unused port available.

long long getSlaveID ( int num ) #

Returns the ID of the slave with the specified number. A unique Slave ID consists of two parts: IP (32 bits) + port (16 bits)

Arguments

  • int num - Slave number.

Return value

ID of the slave with the specified number.

const char * getSlaveWorldName ( int num ) #

Returns the name of the world file currently loaded on the specified slave.

Arguments

  • int num - Slave number.

Return value

Name of the world file currently loaded on the specified slave.

const char * getSlaveView ( int num, int display_num ) #

Returns the name of the display or projector stored in the configuration file and assigned to the given display of the given slave computer.

Arguments

  • int num - Slave number.
  • int display_num - Display number.

Return value

Name of the display or projector.

void setSyncPlayer ( bool enabled ) #

Enables synchronization of the current player's parameters via the UDP protocol:
  • Its transformation
  • Projection matrix
  • Viewport mask
  • Mask for reflections
  • Applied post-materials (if any)
Notice
Current player synchronization is used only when all slaves use the same camera.

Arguments

  • bool enabled - true to enable synchronization; false - to disable it.

bool isSyncPlayer ( ) #

Returns a value indicating if synchronization of the current player is enabled.
Notice
Current player synchronization is used only when all slaves use the same camera.

Return value

true if synchronization of the current player is enabled; otherwise, false.

void setSyncRender ( bool enabled ) #

Enables synchronization of all render parameters via the UDP protocol: light scattering, occlusion, etc.
Notice
When all slaves use the same rendering settings, synchronization of render parameters can be disabled.

Arguments

  • bool enabled - true to enable synchronization; false - to disable it.

bool isSyncRender ( ) #

Returns a value indicating if synchronization of all render parameters is enabled.
Notice
When all slaves use the same rendering settings, synchronization of render parameters can be disabled.

Return value

true if synchronization of all render parameters is enabled; otherwise, false.

void addSyncNode ( const Ptr<Node> & node, unsigned char sync_mask = ~0 ) #

Enables synchronization of parameters of the given node via the UDP protocol.
Notice
Scene nodes are not synchronized by default, this method is used to add a particular node to the synchronization queue.

Arguments

  • const Ptr<Node> & node - Node to synchronize.
  • unsigned char sync_mask - Synchronization mask.

void addSyncNodes ( const Vector< Ptr<Node> > & nodes, unsigned char sync_mask = ~0 ) #

Enables synchronization of parameters of given nodes via the UDP protocol.
Notice
Scene nodes are not synchronized by default, this method is used to add particular nodes to the synchronization queue.

Arguments

  • const Vector< Ptr<Node> > & nodes - List of nodes to synchronize.
  • unsigned char sync_mask - Synchronization mask.

void setSyncNodeMask ( const Ptr<Node> & node, unsigned char sync_mask ) #

Sets a new synchronization mask for the specified node. Synchronization mask can be used for optimization reasons limiting the amount of data to be synchronized and thus reducing network load. For example, for moving parts of a helicopter we can set a mask to synchronize only node transformations:
Source code (C++)
master->setSyncNodeMask(fan_small, Syncker::Master::TRANSFORM);
master->setSyncNodeMask(fan_big, Syncker::Master::TRANSFORM);

Arguments

  • const Ptr<Node> & node - Node for which a new synchronization mask is to be set.
  • unsigned char sync_mask - New synchronization mask to be set for the specified node.

unsigned char getSyncNodeMask ( const Ptr<Node> & node ) #

Returns the synchronization mask for the specified node.

Arguments

  • const Ptr<Node> & node - Node, for which a synchronization mask is to be obtained.

Return value

Synchronization mask of the specified node.

bool isSyncNode ( const Ptr<Node> & node ) #

Returns a value indicating if synchronization of the given node is enabled. Using this method you can quickly check if a node is monitored by the Syncker (node's states are dispatched to Slaves over the network).

Arguments

  • const Ptr<Node> & node - Node to be checked.

Return value

true if synchronization of the given node is enabled; otherwise, false.

int getNumSyncNodes ( ) #

Returns the total number of nodes in the synchronization queue.

Return value

Total number of nodes in the synchronization queue.

Ptr<Node> getSyncNode ( int num ) #

Returns the synchronized node with the given number.

Arguments

  • int num - Node number in the synchronization queue.

Return value

Synchronized node.

void removeSyncNode ( int num ) #

Removes the specified node from the synchronization queue.

Arguments

  • int num - Node number in the synchronization queue.

void removeSyncNode ( const Ptr<Node> & node ) #

Removes the specified node from the synchronization queue.

Arguments

  • const Ptr<Node> & node - Node to be removed from synchronization.

void removeSyncNodeID ( int node_id ) #

Removes the specified node from the synchronization queue by its ID.

Arguments

  • int node_id - ID of the node to be removed from the synchronization queue.

void removeSyncNodes ( const Vector< Ptr<Node> > & nodes ) #

Removes the specified nodes from the synchronization queue.

Arguments

  • const Vector< Ptr<Node> > & nodes - List of nodes to be removed from the synchronization queue.

void clearSyncNodes ( ) #

Removes all nodes from the synchronization queue.

void addSyncMaterial ( const Ptr<Material> & material ) #

Enables synchronization of the given material via the UDP protocol.
Notice
Scene materials are not synchronized by default, this method is used to add a particular material to the synchronization queue.

Arguments

  • const Ptr<Material> & material - Material to synchronize.

void addSyncMaterials ( const Vector< Ptr<Material> > & materials ) #

Enables synchronization of given materials via the UDP protocol.
Notice
Scene materials are not synchronized by default, this method is used to add particular materials to the synchronization queue.

Arguments

  • const Vector< Ptr<Material> > & materials - List of materials to synchronize.

bool isSyncMaterial ( const Ptr<Material> & mat ) #

Returns a value indicating if synchronization of the given material is enabled. Using this method you can quickly check if a material is monitored by the Syncker (material's states are dispatched to Slaves over the network).

Arguments

  • const Ptr<Material> & mat - Material to be checked.

Return value

true if synchronization of the given material is enabled; otherwise, false.

int getNumSyncMaterials ( ) #

Returns the total number of materials in the synchronization queue.

Return value

Total number of materials in the synchronization queue.

Ptr<Material> getSyncMaterial ( int num ) #

Returns the synchronized material with the given number.

Arguments

  • int num - Material number in the synchronization queue.

Return value

Synchronized material.

void removeSyncMaterial ( int num ) #

Removes the material with the given number from the synchronization queue.

Arguments

  • int num - Material number in the synchronization queue.

void removeSyncMaterial ( const Ptr<Material> & material ) #

Removes the specified material from the synchronization queue.

Arguments

  • const Ptr<Material> & material - Material to be removed from the synchronization queue.

void removeSyncMaterials ( const Vector< Ptr<Material> > & materials ) #

Removes the specified materials from the synchronization queue.

Arguments

  • const Vector< Ptr<Material> > & materials - List of materials to be removed from the synchronization queue.

void clearSyncMaterials ( ) #

Removes all materials from the synchronization queue.

void createNode ( const Ptr<Node> & node ) #

Synchronizes creation of the given node on all Slaves. This method is to be called after node creation on the Master.
Notice
It is recommended to use the loadNode() or loadNodereference() methods whenever possible as this approach allows adding nodes of all types, unlike the createNode() method that supports only a limited number of them.
Example:
Source code (C++)
NodePtr node = NodeDummy::create(); 
master->createNode(node);

Arguments

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

void deleteNode ( const Ptr<Node> & node ) #

Synchronizes deletion of the given node (with all its children) on the Master and all Slaves. Similar to calling deleteLater() for the node.

Arguments

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

bool isNodeCreatedBySyncker ( const Ptr<Node> & node ) #

Returns a value indicating if the given node was created via the createNode() method. Using this method you can quickly check if a node is in the run-time objects creation buffer.

Arguments

  • const Ptr<Node> & node - Node to be checked.

Return value

true if if the given node was created via the createNode() method; otherwise, false.

void setSlavePlayer ( int num, const Ptr<Player> & player ) #

Sets the specified player for all slave computers specified by the mask.
Notice
Synchronization of the main master camera is disabled.

Arguments

  • int num - Bit mask, that defines slaves, on which the specified player is to be set. Use ~0 for all slaves.
    Notice
    Each bit of the mask corresponds to a slave. To specify certain slave use: 1 << slave_number
  • const Ptr<Player> & player - Player to be set.

void setSlavePlayer ( const char * view, const Ptr<Player> & player ) #

Sets the specified player for all Slave computers using the specified view (see the sync_view argument).
Notice
Synchronization of the main master camera is disabled.

Arguments

  • const char * view - Name of the view (display or projector).
  • const Ptr<Player> & player - Player to be set.

void setSendRate ( float rate ) #

Sets the frequency of sending packets to Slaves. Use this method when network load is too high and slows down the whole IG system. It is recommended to use this method with interpolation enabled.
Notice
Available in the asynchronous mode only.

Arguments

  • float rate - Frequency of sending packets to Slaves. The default value is -1 (every frame).
    Notice
    The value should not be less than 1 / getInterpolationPeriod(), otherwise the image shall be "stuttering".

float getSendRate ( ) #

Returns the current frequency of sending packets to Slaves. Use this method when network load is too high and slows down the whole IG system. It is recommended to use this method with interpolation enabled.
Notice
Available in the asynchronous mode only.

Return value

Frequency of sending packets to Slaves.

void setAllowExtraSlaves ( bool slaves ) #

Sets a value indicating if new Slaves can connect to the Master after starting the session. This can be used, for example, to connect a Slave which is used as a tool for configuring projections and does not operate as an IG.

Arguments

  • bool slaves - true to permit new Slaves connecting to the Master after starting the session; false - to forbid it.

bool isAllowExtraSlaves ( ) #

Returns a value indicating if new Slaves can connect to the Master after starting the session. This can be used, for example, to connect a Slave which is used as a tool for configuring projections and does not operate as an IG.

Return value

true if new Slaves can connect to the Master after starting the session; otherwise, false.

void setViewOffset ( const Math::vec3 & offset ) #

Sets a new player's head position on the Master.

Arguments

  • const Math::vec3 & offset - New player's head position coordinates to be set.

double getTime ( ) #

Returns the current Master time.

Return value

Current master time, in seconds.

void setSyncViewOffset ( bool offset ) #

Enables synchronization of view offset for projections via the UDP protocol.

Arguments

  • bool offset - true to enable synchronization; false - to disable it.

bool isSyncViewOffset ( ) #

Returns a value indicating if synchronization of view offset for projections is enabled.

Return value

true if synchronization of view offset for projections is enabled; otherwise, false.

void setSyncWorldLoad ( bool load ) #

Enables synchronization of world loading via the UDP protocol.

Arguments

  • bool load - true to enable synchronization; false - to disable it.

bool isSyncWorldLoad ( ) #

Returns a value indicating if synchronization of world loading is enabled.

Return value

true if synchronization of world loading is enabled; otherwise, false.

void setDefaultSyncNodes ( unsigned char nodes ) #

Sets a new mask defining types of nodes that will be synchronized automatically after world loading. This mask can be used for optimization reasons limiting the number of nodes to be synchronized and thus reducing network load. For example, you can restrict automatic synchronization to global water, and clouds only:
Source code (C++)
master->setDefaultSyncNodes(Syncker::Master::WATER_GLOBAL | Syncker::Master::CLOUD_LAYER);

Arguments

  • unsigned char nodes - Mask defining types of nodes that will be synchronized automatically after world loading.

unsigned char getDefaultSyncNodes ( ) #

Returns the current mask defining types of nodes that will be synchronized automatically after world loading. This mask can be used for optimization reasons limiting the number of nodes to be synchronized and thus reducing network load.

Return value

Current mask defining types of nodes that will be synchronized automatically after world loading.

void loadWorld ( const char * name ) #

Loads a world from the specified file on the Master and all Slaves. Syncker is able to automatically synchronize the current world, but it works as follows: Slaves shall only start loading a new world after it is completely loaded on the Master. This method provides a 2x speedup of world loading process, as it forces all hosts to start loading the world almost simultaneously.

Arguments

  • const char * name - Path to the *.world file to be loaded.

Ptr<Node> loadNode ( const char * name ) #

Loads a node from the specified file to the world on the Master and all Slaves. This is a network analogue of the loadNode() method of the World class.

Arguments

  • const char * name - Path to the *.node file.

Return value

Loaded node or nullptr if an error has occurred.

Ptr<NodeReference> loadNodeReference ( const char * name ) #

Loads a node reference from the specified file to the world on the Master and all Slaves. This is a network analogue of the NodeReference class constructor.

Arguments

  • const char * name - Path to the *.node file.

bool isNodeLoadedBySyncker ( const Ptr<Node> & node ) #

Returns a value indicating if the given node was loaded by the Syncker via the loadNode() or the loadNodeReference() method.

Arguments

  • const Ptr<Node> & node - Node to be checked.

Return value

true if if the given node was created via the createNode() method; otherwise, false.

void * addCallback ( int callback, Unigine::CallbackBase * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when sending or receiving user messages, as well as when changing settings on the Master or a Slave. The signature of the callback function can be one of the following:
Source code (C++)
// for the Syncker::Master::SESSION_STARTED type
void callback_function_name(void);

// for the Syncker::Master::SESSION_FINISHED type
void callback_function_name(void);

// for the Syncker::Master::SLAVE_CONNECTED type
void callback_function_name(int slave_num);

// for the Syncker::Master::SLAVE_DISCONNECTED type
void callback_function_name(int slave_num);

// for the Syncker::Master::MASTER_SETUP_CHANGED type
void callback_function_name(void);

// for the Syncker::Master::SLAVE_SETUP_CHANGED type
void callback_function_name(int slave_num);

Arguments

Return value

Number of the last added callback of the specified type, if the callback was added successfully; otherwise, -1.

bool removeCallback ( int callback, void * func ) #

Removes a given callback from the list of callbacks of the specified type. Callback functions can be used to determine actions to be performed when sending or receiving user messages, as well as when changing settings on the Master or a Slave.

Arguments

Return value

true if the position callback with the given ID was removed successfully; otherwise false.

void clearCallbacks ( int callback ) #

Clears all added callbacks of the specified type. Callback functions can be used to determine actions to be performed when sending or receiving user messages, as well as when changing settings on the Master or a Slave.

Arguments

Last update: 2020-04-10