Asset API
The Asset module loads TESLASUIT asset files, either from disk or from an in-memory byte buffer, and gives access to information about a loaded asset, such as its type.
Assets are binary resources (haptic effects, splines, materials, touch sequences, preset and scene animations) that are consumed by other subsystems, such as the haptic player, once loaded. When an asset is no longer needed, it must be unloaded to free the resources it holds.
Functions#
ts_asset_load_from_path#
TsAsset* ts_asset_load_from_path(const char* asset_path);
Loads a TESLASUIT asset from a file on disk.
Preconditions
Parameters
asset_path: const char*, in
Null-terminated path to the *.ts_asset file to load, either absolute or relative to the current working directory.
Returns: TsAsset*
TsAsset handle to the loaded asset, or NULL if the file could not be found or parsed.
See also: ts_asset_load_from_binary_data
ts_asset_load_from_binary_data#
TsAsset* ts_asset_load_from_binary_data(const uint8_t* asset_binary_data, uint64_t size);
Loads a TESLASUIT asset from a byte array held in memory.
Preconditions
Parameters
asset_binary_data: const uint8_t*, in
Pointer to the buffer holding the raw bytes of the asset.
size: uint64_t, in
Size of the buffer pointed to by asset_binary_data, in bytes.
See also: ts_asset_unload
ts_asset_get_type#
TsStatusCode ts_asset_get_type(TsAsset* asset, TsAssetType* asset_type);
Retrieves the type of a previously loaded asset.
Preconditions
Parameters
asset: TsAsset*, in
Handle to the loaded asset, as returned by ts_asset_load_from_path or ts_asset_load_from_binary_data.
asset_type: TsAssetType*, out
On success, filled with the type identifier of the loaded asset.
Returns: TsStatusCode
TsStatusCode indicating whether the asset type was retrieved successfully, or an error code describing why it could not be determined.
See also: TsAssetType
ts_asset_unload#
void ts_asset_unload(TsAsset* asset);
Unloads a previously loaded asset and releases its resources.
Preconditions
Parameters
asset: TsAsset*, in
Handle to the loaded asset to unload, as returned by ts_asset_load_from_path or ts_asset_load_from_binary_data. The handle must not be used after this call.
See also: ts_asset_load_from_binary_data
