WaveVR_PoseTracker¶
Older versions (2.0.25 and before) can be found here: WaveVR_PoseTracker
Contents |
Introduction¶
The easiest way to track poses is to use the WaveVR_PoseTrackerManager.cs script. This script manages all pose tracking behaviors.
This script manages the two scripts below to track poses:
- WaveVR_DevicePoseTracker.cs: device pose tracking.
- WaveVR_ControllerPoseTracker.cs: controller pose tracking.
For a GameObject (e.g. Generic_MC_R(Clone)) with the component WaveVR_PoseTrackerManager.cs,
if you specify the device type to WVR_DeviceType_Controller_Right
and the right device loses tracking (or disconnected),
WaveVR_PoseTrackerManager.cs will hide the children objects of the GameObject (e.g. Generic_MC_R(Clone)).
For the WaveVR sample controller, please see the photo below:
You can see that WaveVR_PoseTrackerManager.cs is added to Generic_MC_R(Clone)
.
Thus, if the WVR_DeviceType_Controller_Right
device loses tracking, the children objects (MIA_Ctrl, BeamR, ControllerPointerR) will be hidden (disabled).
Note: The GameObject with WaveVR_PoseTrackerManager.cs will NOT be disabled by WaveVR_PoseTrackerManager.cs .
So, if you want to hide the tracked GameObject with the WaveVR_PoseTrackerManager.cs component when specified device is lost-tracking or disconnected, you will have to use WaveVR_ControllerManager
Resources¶
Prefab¶
- WaveVR is located in Assets/WaveVR/Prefabs/
- Controller Loader is located in Assets/WaveVR/Prefabs/
Scripts¶
All scripts about tracking poses are located in Assets/WaveVR/Scripts/TrackingPose/
Sample¶
- PoseTracker_Test is located in Assets/Samples/PoseTracker_Test/Scene/
- HelloVR is located in Assets/Samples/HelloVR/Scene/
How to Use¶
Scene Hierarchy¶
Open the sample scene PoseTracker_Test.
Look at the Inspector of Cube. WaveVR_DevicePoseTracker is used here to receive the pose event and update the cube pose.
The Type is set to choose one of the controllers.
Press the Play key to play the scene in editor mode, the Generic_MC_R(clone) controller will be generated with the component WaveVR_PoseTrackerManager .
Then the WaveVR_ControllerPoseTracker component will be loaded automatically and configured like the WaveVR_PoseTrackerManager .
You can see the head object and the ControllerLoader_R (a prefab from Assets/WaveVR/Prefabs/) object underneath the WaveVR object.
This usage demonstrates a controller uses
localPosition
of the head underneath the same parent.In the Inspector of WaveVR, you can see the Y axis rotates 90 degrees. Thus, in editor mode, you have to turn your head around 90 degrees to see FrontCube .
Look at the Inspector of head. You can see the WaveVR_DevicePoseTracker component has
Type
with WVR_Device_Type_HMD. There is a option namedEnable Neck Model
.This option takes effect only when the
Origin
of WaveVR_Render is WVR_Pose Origin Model_Origin On Head_3 DoF.When this option is checked, WaveVR will simulate the head position in the 3DoF (rotation only) environment.
Editor Mode¶
In editor mode, please use the mouse and keyboard to simulate the controller.
For the 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
For the 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: press button
For the left controller:
- Mouse left button: touch button
Script¶
There is a Timing
option in the pose tracker scripts.
If you choose When New Poses
, the device pose will be updated before rendering.
If you choose ``When Update`, the device pose will be updated at the end of each frame.
WaveVR_DevicePoseTracker and WaveVR_ControllerPoseTracker listen to event MSG_NEW_POSES
in OnEnable
void OnEnable()
{
WaveVR_Utils.Event.Listen(MSG_NEW_POSES, OnNewPoses);
The pose of an object will be updated in each frame in OnNewPoses
.
Also, you can see the Inverse Pos and Inverse Rotation checkboxes in WaveVR_DevicePoseTracker. They 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 provides options for pose simulation.
If the Track Position
option is checked, the Simulate Position
option will show.
If the Simulate Position
option is selected as When No Position
or Force Simulation
, the Follow Head
option will show.
Follow Head
means that when a controller is put (on a table or another place), the controller should follow the head’s movement in scene.
Note: The head’s position which the controller follows is local position, not world position. A demonstration can be seen in Scene Hierarchy