Python-based Data Binding
WORK IN PROGRESS
The Python Connector Library is a simple library written in python and c++ that provides functionality to start and load scene composer binary assets and interact with a predefined set of data binding items (Variant) through python scripting.
Building
On host, the project can be built, using the new cmake environment and by setting <cgi-studio-root>/cmake/Candera/PlayerConnector as source code location. To build the project, right-click PlayerConnectorDll in Visual Studio and click Build. When the build finished
Python Connector Library
The library consists of a python class CanderaAppConnector. This class has the methods for getting and setting values to databinding items. Also callbacks can be registered that are invoked when a data binding value has been changed.
- Constructor
- Init
- Step
- SetIntValue
- SetBoolValue
- SetStringValue
- SetFloatValue
- GetIntValue
- GetBoolValue
- GetStringValue
- GetFloatValue
- RegisterCallback
- ShutDown
Constructor
Creates and instance of this class. Expects and absolute or relative path to the player connector binary as parameter.
| Parameters |
|
Init
Initializes the player with the provided asset path. Expects an absolute or relative path to the asset binary as parameter. Must be called before every other method. Returns a bool if the operation was successful.
| Parameters |
|
| Returns | Boolean if operation was successful |
Step
Invokes the internal message processing and render loop execution. Needs to be called continuously. Databinding updates are reflected internally during the invocation of this method. Returns a bool if the operation was successful.
| Parameters | None |
| Returns | Boolean if operation was successful |
SetIntValue
Sets an integer value to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
SetBoolValue
Sets a bool value to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
SetStringValue
Sets a string to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
SetFloatValue
Sets a float value to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
GetIntValue
Gets an int value from a predefined databinding source item.
| Parameters |
|
| Returns | The integer value |
GetBoolValue
Gets a bool value from a predefined databinding source item.
| Parameters |
|
| Returns | The bool value |
GetStringValue
Gets a string from a predefined databinding source item.
| Parameters |
|
| Returns | The string |
GetFloatValue
Gets a float value from a predefined databinding source item.
| Parameters |
|
| Returns | The float value |
RegisterCallback
Registers a callback method. Multiple methods can be registered. Passed method must have two parameters. First param is BindingSourceItem and second parameter is value.
CallbackFn: Callable type with two parameters
Returns
Boolean if operation was successful
ShutDown
Shuts down the asset player and frees up allocated resources.