Simulated Reality SDK 7500c78d v1.30.2.51085 2024-04-26T11:23:03Z
Stable
|
The HeadTracker API works similarly to the EyeTracker API, but also exposes the user's head position and orientation and the user's ear positions in addition to the user's eye positions.
The HeadTracker API consists out of the following classes
SRContext
is an essential element of any SR application, it maintains a list of all SR components that are in use and cleans them up when the application ends. It also allows different components of the application to share the same Sense implementations.Sense
is an interface used by the SRContext
to keep track of any input or output devices.HeadTracker
is an interface providing access to the data.HeadStream
connects HeadTracker
implementations with user defined HeadListener
implementations.HeadListener
is an interface to be implemented by any components of the user's application that want to receive the data.SR_head
contains the output data.The SR_head
struct is at the center of the HeadTracker interface, this is what applications can subscribe to.
The SR_head
struct contains the head pose, eye positions and ear positions. For more information on the head pose data, you can take a look at the HeadPoseTracker API. For more information on the eye position data, see the EyeTracker API.
The ear position data is only available through the HeadTracker interface. Currently, the ear positions are simply calculated as a constant offset from the head position, but this may change in the future.
The ear position data is contained in the SR_earPair
struct:
The head positions are relative to the normal SR output coordinate system.
Application developers should define how to handle the head pose data by implementing an HeadListener
. It is advisable to include an InputStream<SR::HeadStream>
member, this will come into play when the actual head pose tracker is constructed.
To get access to head pose data, users will have to construct an SRContext and call the static factory function HeadTracker::create
as follows:
Then we need to construct a listener that follows the desired way of processing the data. By calling set
on the InputStream<SR::HeadStream>
field we ensure that the stream is destructed correctly when the HeadListenerImplementation
goes out of scope. When everything is set up context.initialize()
starts using any newly constructed streams to listeners.
If the main function of our application returns, all deconstructors will be called and we will no longer receive data. We should ensure that the application remains open as long as we want.