WaveVR_PoseTracker

Old version (2.99 and before): here

Contents

Introduction

For tracking pose, the easiest way is use WaveVR_PoseTrackerManager.cs . This script manages all pose tracking behaviors.

This script manages two scripts below to track pose:

  • WaveVR_DevicePoseTracker.cs: device pose tracking.
  • WaveVR_ControllerPoseTracker.cs: controller pose tracking.

If developer adds component WaveVR_PoseTrackerManager.cs to a GameObject (e.g. Generic_MC_R(Clone)) and WaveVR_PoseTrackerManager.cs is specified to a device (e.g. Dominant).

Thus, if Dominant is lost-tracking (or disconnected), WaveVR_PoseTrackerManager.cs will hide the children objects of Generic_MC_R(Clone).

In WaveVR sample controller:

_images/wavevr_posetracker08.jpg

Developer can see that WaveVR_PoseTrackerManager.cs is added to Generic_MC_R(Clone).

So if Dominant is lost-tracking, the children objects (MIA_Ctrl, BeamR, ControllerPointerR) will be hidden (disabled).

Note: the GameObject to which WaveVR_PoseTrackerManager.cs is added will NOT be disabled by WaveVR_PoseTrackerManager.cs .

So if developer wants to hide tracked GameObject to which WaveVR_PoseTrackerManager.cs is added when specified device is lost-tracking or disconnected, use WaveVR_ControllerManager

Resources

Prefab

  • WaveVR in Assets/WaveVR/Prefabs/
  • Controller Loader in Assets/WaveVR/Prefabs/

Scripts

All scripts about tracking pose locate in Assets/WaveVR/Scripts/TrackingPose/

Sample

  • PoseTracker_Test: in Assets/Samples/PoseTracker_Test/Scene/
  • HelloVR: in Assets/Samples/HelloVR/Scene/

How to Use

Scene Hierarchy

  1. Open sample scene PoseTracker_Test.
_images/posetracker_01.png
  1. Press Play key to play scene in editor mode, Generic_MC_R(clone) controller will be generated. It uses WaveVR_PoseTrackerManager .
_images/posetracker_02.png _images/posetracker_03.png
  1. We can see head and ControllerLoader (prefab from Assets/WaveVR/Prefabs/) under WaveVR.

    This is used to demonstrate that controller uses localPosition of head and beneath the same parent.

    In inspector of WaveVR, we can see Y axis rotates 90 degree. Thus in editor mode, it has to turn head around 90 degree to see FrontCube .

  2. Looking at Inspector of head. Script WaveVR_DevicePoseTracker has Type with Head.

    There is a option named Enable Neck Model.

_images/posetracker_04.png

This option takes effect only when the Origin of WaveVR_Render is WVR_Pose Origin Model_Origin On Head_3 DoF.

When the option is checked, WaveVR will simulate head position in 3DoF (rotation only) environment.

Editor Mode

In Editor mode, use the mouse and keyboard to simulate the controller.

Head -

  • Left Ctrl + mouse: roll
  • Left Alt + mouse: yaw and pitch
  • Left Shift + mouse: move (X,Y) position
  • Left Shift + mouse scroll wheel: move Z position

Right controller -

  • Right Ctrl + mouse: roll
  • Right Alt + mouse: yaw and pitch
  • Right Shift + mouse: move (X,Y) position
  • Right Shift + mouse scroll wheel: move Z position
  • Mouse right button: button pressed

Left controller -

  • Mouse left button: button touched

Script

In all tracking pose scripts, there is a Timing option.

If developer chosen When New Poses, device pose would be updated before rendering.

If developer chosen When Update, device pose would be updated at end of each frame.

In WaveVR_DevicePoseTracker and WaveVR_ControllerPoseTracker, it listens to event MSG_NEW_POSES in OnEnable

void OnEnable()
{
    WaveVR_Utils.Event.Listen(MSG_NEW_POSES, OnNewPoses);

Pose of object will be updated each frame in OnNewPoses.

Also, you can see the Inverse Pos and Inverse Rotation checkboxes in WaveVR_DevicePoseTracker. These are used to inverse the position and rotation of the pose.

For example, when you are looking at a ball and moving left, the ball looks like its moving in the opposite direction (moving to the right).

For advanced uses of inverse, refer to Samples/SeaOfCube/Scenes/SeaOfCube

WaveVR_PoseTrackerManager provices options for pose simulation.

_images/posetracker_05.png

If Track Position is checked, Simulate Position checkbox will show.

  • When No Position: if device does NOT have position, use simulation positon.
  • Force Simulation: use simulation position anyway.
  • No Simulation: do NOT use simulation position.

If Simulate Position is selected as When No Position or Force Simulation, Follow Head checkbox will show.

Follow Head means that when controller is put (on table or whatever), controller should follow head movement or not in scene.

Note: the head position which controller follows is localPosition, not world position. Demonstration is in Scene Hierarchy