WaveVR_PoseTracker

Old version (2.0.25 and before): here

Contents

Introduction

WaveVR provides two scripts for tracking pose

  • WaveVR_DevicePoseTracker.cs
  • WaveVR_ControllerPoseTracker.cs

Developer can use WaveVR_DevicePoseTracker to track device pose and WaveVR_ControllerPoseTracker for controller pose .

For convenient use, WaveVR provides the WaveVR_PoseTrackerManager.cs script used in all controller model prefab.

Resources

Prefab

  • WaveVR: in Assets/WaveVR/Prefabs/
  • Generic Controller Model: in Assets/WaveVR/Resources/Controller/
  • Specified Controller Model: in Assets/ControllerModel/Finch/Resources/Controller/ and Assets/ControllerModel/Link/Resources/Controller/
  • 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/wavevr_posetracker01.jpg
  1. Look in Inspector of Cube. WaveVR_DevicePoseTracker is used here to receive event and update pose of the cube.

    The Type is set to choose one of the controllers.

_images/wavevr_posetracker03.jpg
  1. WaveVR_PoseTrackerManager used in controller model prefab vr_controller_tank_0_8_6DOF_MC_R
_images/wavevr_posetracker05.jpg

Please notify that vr_controller_tank_0_8_6DOF_MC_R and head have different parents.

So if developer changes the pose of parent of head, it won’t take effect on vr_controller_tank_0_8_6DOF_MC_R.

  1. We can see head and ControllerLoader_R (prefab from Assets/WaveVR/Prefabs/) under WaveVR.

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

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 manages the behavior of tracking pose / connection status / system focus.

_images/wavevr_posetracker06.jpg

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

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

Included Objects fields specify which GameObjects are controlled by WaveVR_PoseTrackerManager.

For example, prefab vr_controller_tank_0_8_MC_R contains 3 components:

_images/wavevr_posetracker04.jpg

So all components should be included in WaveVR_PoseTrackerManager.