Skip to content

engine_control

Francisco Dias edited this page Nov 22, 2024 · 4 revisions

Engine Control

Interhaptics Docs Section: Engine Control


This module contains the functions related to Engine Control.

Functions

This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.



Back To Top

interhaptics_init

This function initialises the different components and modules of the Interhaptics Engine:

  • Haptic Material Manager: module in charge of loading and storing haptic effects
  • Human Avatar Manager: module in charge of mapping between device, human avatar, and experience
  • Haptic Event Manager: module in charge of the control of haptic sources

Syntax:

interhaptics_init()



Returns:

Boolean




Back To Top

interhaptics_quit

This function cleans up the different components and modules of the Interhaptics Engine. To be called before the application is quit.


Syntax:

interhaptics_quit()



Returns:

N/A




Back To Top

interhaptics_set_global_intensity

This function sets the global rendering intensity factor for the whole engine.


Syntax:

interhaptics_set_global_intensity(intensity)
Argument Type Description
intensity Real A positive value. 0 is nothing. Base value is 1.



Returns:

N/A




Back To Top

interhaptics_get_global_intensity

This function gets the global rendering intensity factor for the whole engine.

It returns the global intensity, or -1 if the mixer is not initialised.


Syntax:

interhaptics_get_global_intensity()



Returns:

Real




Back To Top

interhaptics_add_hm

This function adds the content of an .haps file to the Interhaptics Engine for future use. It returns a reference to the new haptic effect to be used in other functions.


Syntax:

interhaptics_add_hm(content)
Argument Type Description
content String The JSON content of the .haps file to be loaded. This needs to follow the Interhaptics .haps format.



Returns:

Real




Back To Top

interhaptics_add_parametric_effect

This function creates a haptic effect by processing parameters such as amplitude, pitch, and transients. This function generates a haptic effect based on the given input parameters and can optionally loop it.

It returns the ID of the haptic effect created.


Syntax:

interhaptics_add_parametric_effect(amplitude, pitch, freq_min, freq_max, transient, is_looping)
Argument Type Description
amplitude Array of Real An array of amplitude values. Should be formatted as Time - Value pairs. Value is between 0 and 1.
pitch Array of Real An array of pitch values. Should be formatted as Time - Value pairs. Value is between 0 and 1.
freq_min Real The minimum value for the frequency range.
freq_max Real The maximum value for the frequency range.
transient Array of Real An array of transient values. The array should be formatted as Time - Amplitude - Pitch triplets, with both Amplitude and Pitch values ranging between 0 and 1.
is_looping Boolean Indicates whether the effect should loop or not.



Returns:

Real




Back To Top

interhaptics_delete_hm

This function deletes an existing haptic effect.


Syntax:

interhaptics_delete_hm(material_ref)
Argument Type Description
material_ref Real The ID of the haptic effect to delete.



Returns:

N/A




Back To Top

interhaptics_update_hm

This function replaces the content of an already loaded haptic effect and returns whether the replace was successful. This can be useful when the ID of the haptic effect needs to be persistent.


Syntax:

interhaptics_update_hm(material_ref, content)
Argument Type Description
material_ref Real ID of the haptic effect to be replaced.
content String The JSON content of the .haps file to be loaded. This needs to follow the Interhaptics .haps format.



Returns:

Boolean




Back To Top

interhaptics_transients_played_on_those_body_parts

This function returns true if at least one active event targeting the given body parts contains transients.


Syntax:

interhaptics_transients_played_on_those_body_parts(perception, body_parts)
Argument Type Description
perception Real The perception to play
body_parts Array of Real The IDs of the body parts targeted



Returns:

Boolean