How to Add Positional Tracking to the Oculus Tuscany Demo with the Razer Hydra

Before you begin you’ll need:

Visual Studio (Express) 10 and the Direct X SDK (June 2010)

1. Get the Oculus SDK: here.

Get the Sixense SDK: here.

2. Compile and test the samples. In this case we are using the OculusWorldDemo as our starting point.

3. Load the OculusSDK\Samples\LibOVR_Samples_Msvc2010.sln file and make sure OculusWorldDemo is the Startup Project.

4. Add the include directories and libraries for Razer. OculusWorldDemo > Properties: C/C++ > General > Additional Include Directories: (Add) C:\dev\SixenseSDK_062612\include (or wherever you installed SDK) Linker > General.>Additional Library Directories: (Add) C:\dev\SixenseSDK_062612\lib\win32\release_dll (or debug_dll if you are in debug mode) Linker > Input > Additonal Dependencies: (Add) sixense.lib sixense_utils.lib

5. Add header files to top of OculusWorldDemo.cpp

[csharp]
#include
#include <sixense_math.hpp>
#include <sixense_utils/button_states.hpp>
#include <sixense_utils/event_triggers.hpp>
#include <sixense_utils/controller_manager/controller_manager.hpp>
[/csharp]

6. Add some protected variables to the OculusWorldDemoApp class:

[csharp]
sixenseAllControllerData acd;
float hand_lf_x, hand_lf_y, hand_lf_z,hand_rt_x, hand_rt_y, hand_rt_z;
float hand_rt_offset_x,hand_rt_offset_y, hand_rt_offset_z;
float hand_lf_offset_x,hand_lf_offset_y, hand_lf_offset_z;
[/csharp]

7. Find ..

[csharp]OculusWorldDemoApp::OnStartup[/csharp]

..and add the Hydra setup to the end:

[csharp]
// Init sixense
sixenseInit();
// Init the controller manager. This makes sure the controllers are present,
//assigned to left and right hands, and that
// the hemisphere calibration is complete.
sixenseUtils::getTheControllerManager()>
setGameType(
sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER );
[/csharp]

8. Find ..

[csharp]void OculusWorldDemoApp::OnIdle()[/csharp]

..and add this to the end of the ,csharp]if(pSensor)[/csharp] block:

[csharp]
float scale = .0015f;
//read the left controller and save the position values
hand_lf_x = scale * acd.controllers[1].pos[0] ;
hand_lf_y = scale * acd.controllers[1].pos[1] ;
hand_lf_z = scale * acd.controllers[1].pos[2] ;
hand_lf_offset_y += scale *acd.controllers[1].joystick_y ;
hand_lf_offset_x += acd.controllers[0].joystick_x * acd.controllers[0].joystick_x * (acd.controllers[0].joystick_x > 0 .1 : .1) ;
hand_lf_offset_z += acd.controllers[0].joystick_y * acd.controllers[0].joystick_y * (acd.controllers[0].joystick_y > 0 ? . 1 : .1);
[/csharp]

SEE ALSO
New 'Skydance's Behemoth' Trailer Shows Off New Boss, Gameplay & More Ahead of December Release

9. Farther down in:

[csharp]OculusWorldDemoApp::OnIdle()[/csharp]

..right before the command:

[csharp]View = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + forward, up);[/csharp]

..insert the hydra’s offset values to the eye position:

[csharp]
//calculate the player’s body rotation
Matrix4f yawRotate = Matrix4f::RotationY(Player.BodyYaw);

//get the hydra’s offset from the last reset position
Vector3f eye_hydra ( hand_lf_offset_x – hand_lf_x , hand_lf_y – hand_lf_offset_y, hand_lf_offset_z – hand_lf_z );

// adjust for body rotation so looking forward is always forward
Vector3f eye_orientationVector = yawRotate.Transform(eye_hydra);

//add new eye position to the base eye postion
shiftedEyePos += eye_orientationVector;
[/csharp]

One problem with the early tests was the Hydra would not track correctly if you rotated your head sideways and then looked in that direction. This is because the Hydra is recording its offset in world space, but does not know that your entire body has been rotated in the scene. Keeping track of the BodyYaw, and then rotating the Hydra translations by that rotation value keeps everything lined up properly. Pressing the trigger in the Right Hydra will toggle between strafe mode and rotate mode.

The head “modeling” in the original demo works but offsetting the viewers eyes in front or the rotation point on the head.  This is very much like how the hydra bodyYaw calculations are done.  However, with the Hydra being on the back of the head, opposite of the eyes, it effectively undoes the head modeling.  To compensate for this, and get our nice head / eye modeling back, we have to increase the length of the headBaseToEyeProtrusion.  You will see my adjustment variable hydra_head_offset= 2.5 that I use to scale this value.  Play with this to get different amount of eye head modeling effects.

You can download the compiled binary and the source below:

SEE ALSO
iPhone 16 Adds Spatial Photos and Spatial Audio Capture for Vision Pro

Download HydraHeadTracker.zip Here

Disclaimer: Files are downloaded at the users own risk, RoadToVR accept no liability to any damage done as a result of use or misuse of the file(s) provided.

NOTES for the download: The right hydra stick moves the player, holding down the trigger toggles between rotate mode and strafe mode.

Pressing the left bumper resets the head tracker so if you need to move more forward just lean back and repress the bumper.

A huge “thank you!” to Tony for his hard work and allowing us to share his work. You can discuss this article further over on our Developer Forums. You can catch Tony over at his YouTube channel here.

1
2
Newsletter graphic

This article may contain affiliate links. If you click an affiliate link and buy a product we may receive a small commission which helps support the publication. More information.


Based in the UK, Paul has been immersed in interactive entertainment for the best part of 27 years and has followed advances in gaming with a passionate fervour. His obsession with graphical fidelity over the years has had him branded a ‘graphics whore’ (which he views as the highest compliment) more than once and he holds a particular candle for the dream of the ultimate immersive gaming experience. Having followed and been disappointed by the original VR explosion of the 90s, he then founded RiftVR.com to follow the new and exciting prospect of the rebirth of VR in products like the Oculus Rift. Paul joined forces with Ben to help build the new Road to VR in preparation for what he sees as VR’s coming of age over the next few years.
  • Daan Kortenbach

    Hi Tony, great work! Happy to see more people are working on the idea of using Sixense tech for positional tracking :) https://www.roadtovr.com/topic/the-gallery-qa-we-need-your-questions#post-4341

  • WormSlayer

    Awesome, I remember that interplay logo! :D

    • Paul James

      That’s pretty much word for word what I said to Tony when he told me. :)

  • realbogart

    Hey!
    I really want to get this to work but there seems to be some class (GamepadState) and parameters in RenderParams missing. I am using version 0.2.3 of the oculus sdk. Thanks for this!

  • eyeandeye

    Does anyone else have a problem with “File Load Error” when trying to run it? I downloaded the compiled version, put the two missing sixense.dll files in with it, but can’t figure out which files from the tuscany demo to copy over. I’ve tried copying all of them, and putting them in various locations within the hydraheadtracker folder, no luck. Sorry if I’m asking in a totally random, inappropriate or outdated location.