Open topic with navigation

# Pose Buffering

In Tracking Basics, we showed you how to get the tracked target's current pose. The Tracker Target API also includes functions to enable pose buffering and obtain a buffer of poses over a specified time interval. This information is especially useful if you need to "look back" in time to determine where a target was positioned and oriented.

One use of pose buffering is to determine which object or UI control the stylus was intersecting immediately before the user pressed the stylus button. When the user clicks the stylus button, this causes the stylus to move slightly. You can use the buffered pose to improve the user's ability to select an object or control.

The following code example enables buffering, allocates the buffer, and retrieves the buffer for a specified time period, relative to the current time. It then iterates over the buffer. Note that the buffer is an array of type ZSTrackerPose.

      // zSpaceContext set during initialization.
      // ZSContext zSpaceContext = ...;

      ZSHandle stylusHandle = NULL;
      zsFindTargetByType(zSpaceContext, ZS_TARGET_TYPE_PRIMARY, 0, &stylusHandle);

      // Enable pose buffering.
      zsSetTargetPoseBufferingEnabled(stylusHandle, true);

      // Get all target poses between 0.1 and 0.2 seconds ago.
      ZSTrackerPose poseBuffer[25];
      ZSInt32 poseBufferSize = sizeof(poseBuffer);
      zsGetTargetPoseBuffer(stylusHandle, 0.1f, 0.2f, poseBuffer, &poseBufferSize);

      // Iterate over all of the poses.
      for (ZSInt32 i = 0; i < poseBufferSize; ++i)
      {
        // Do something with poseBuffer[i]
      }

Note:
  The above code example is not part of an SDK sample application.

For further information about pose buffering, refer to the Tracker Target API.

Open topic with navigation