Razer Hydra Input in Unity3D : Sixense Input control syntax

dsky-screenshot-lightsaber

we’ve been doing some fairly extensive development with the Razer Hydras in anticipation of the forthcoming Sixense STEM, as well as a bevy of other 6DoF controllers (Perception Neuron, Sony Move, PrioVR, etc). The Hydra input harness is somewhat convoluted and exists outside and parallel to the standard Unity Input Manager.

razer_hydra_TIGHT

 

I’ve found scant documentation for this on the interwebs, so here is the result of our reverse engineering efforts. If you want to code for Hydra input in your Unity experiences, here are the hooks:

First, we map primary axis and buttons as symbolic representations in the Unity Input Manager (i.e. P1-Horizontal, P1-Vertical, P1-Jump…); those handle basic keyboard, mouse, and standard gamepad input (xbox, playstation). Then inside of our Input handler code, we write custom routines to detect the Hydras, to read their values, and to sub those values into the aforementioned symbolic variables.

Our best recommendation is to install the Sixense plug-in from the Unity Asset Store, and to thoroughly examine the SixenseInputTest.cs that comes with it.

The basic streaming vars are :

• SixenseInput.Controllers[i].Position — Vector3 XYZ
• SixenseInput.Controllers[i].Rotation Vector4 Quaternion
• SixenseInput.Controllers[i].JoystickX — analog float -1.0 to 1.0
• SixenseInput.Controllers[i].JoystickY — analog float -1.0 to 1.0
• SixenseInput.Controllers[i].Trigger — analog float 0.0 to 1.0

obtaining the button taps is a bit more obfuscated,
they’re something like:

• SixenseInput.Controllers[i].GetButton(buttonObjectName)
where “buttonObjectName” is one of many objects:
ONE, TWO, THREE, FOUR, START, BUMPER, JOYSTICK
representing which “switch” is being closed on that cycle,

It also appears that there are two simpler methods,
if you want to trap explicit button press events:

• SixenseInput.Controllers[i].GetButtonDown(buttonObjectName)
• SixenseInput.Controllers[i].GetButtonUp(buttonObjectName)

This sample script has a bevy of (non-optimized?) methods for reading the controllers output in real time, from which you can (in code) map all buttons, thumbsticks, and 6DoF XYZ YPR data to your app. Hopefully the STEM API will be far more integrated into the standard Unity Input Manager framework, and thus work in seamless parallel with standard controllers, without the need for custom code.

Have any tips on Hydra input for Unity?
Pop’em into the comments below:

Unity 5 port complete

Well, the port to Unity 5 took a bit longer than expected. Then again, what port doesn’t? Overall, we’re very happy with the more robust namespace support in code, and the physically based shader model. It took quite some time to re-tool all our custom shaders into a PBR model, but once done, the results are spectacular, no pun intended.

R2-PBR-shaders

R2D2 with the new PBR in Unity5. We’re loving that blue-alloy metal look!

And, we finally solved the mascara issue with all our character models, which we created in Mixamo’s excellent Fuse product. For those techies / artists out there: the trick is to duplicate the existing Legacy/Diffuse-Bump shader for each character, keep the textures and normals, and set the shader model to “Standard / Specular / Fade” with a smoothness of 1.0. Do the same with the eyes, and you’ll have that beautiful “twinkle in the eyes” that all pseudo-living avatars should properly exhibit.

Luke finally drops the mascara and gets real eyebrows -- and a spark

Luke finally drops the mascara and gets real eyebrows — and a spark

In other news, our friends at Magic Leap released their first actual concept video. Just single-player for now, but fun stuff nonetheless.

That’s all for today.

Onward.

The lightsaber… that is all.

killer-best-lightsaber

I realised many months ago that the make or break of our VR experience will be the veracity and feel of the lightsaber. To this end, I’ve developed a wishlist of features:

  1. accurate saber model with metal and buttons
    1. — getting there.
    2. need a really good reflective metal shader
    3. need it to be all solid faces :)
  2. perfect glowing blade
    1. — COMPLETE with alpha textures AND point light source
  3. perfect control by hands
    1. — COMPLETE with Razer Hydra
  4. dynamic motion-driven sound FX
    1. halfway there
    2. need some velocity based flange / distortion
    3. OpenAL or other, transform tip velocity vector to dynamic sFX
  5. hands interaction
    1. switch saber power-on/off from keyboard control to Hydra control
  6. multiple on/of cycles
    1. once lightsaber is off:
    2. blade needs Prefab re-instantiation to be tied to proper place on base
    3. and finally…
  7. interaction with architecture
    1. calculate the intersection of the blade with solids
    2. leaving decals on wall where point hits
    3. showing a fire where it is actively intersection
    4. throwing sparks

Yeah. That should about do it.

lightsaber-cutting-wall