Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
mattanimation's avatar
mattanimation
Honored Guest
11 years ago

Getting head rotational data

For the life of me I can't find any documentation on using the OVRDevice class, am I barking up the wrong tree? I just want to get the angular velocity or orientation but using
OVRDevice.GetAngularVelocity()


is expecting arguments, the sensor and then a ref to x,y and z. Why am I needing to pass that function anything? it's a GET function right? is there another class to get the data from? If I have to pass that class some data to get it back, what's it expecting?

If you know a page that has examples please share as I have been unable to find it. Thanks!

2 Replies

Replies have been turned off for this discussion
  • drash's avatar
    drash
    Heroic Explorer
    "Get" functions sometimes want to return whether or not the Get succeeded, and since functions/methods can only return a single value, one simple solution is to return everything else via ref/out parameters.

    That way, you can do something like this:

    Quaternion q = Quaternion.identity;
    if(OVRDevice.GetOrientation(0, ref q))
    {
    Debug.Log("successfully retrieved orientation: " + q.eulerAngles.ToString());
    }
    else
    {
    Debug.Log("unable to retrieve orientation");
    }

    Also, based on the code I see in SDK 0.2.5c, just pass in 0 for the sensor parameter for now.

    Oh, and for the AngularVelocity one, I guess that's new for 0.3.1? Just a guess, but those x/y/z values it wants to return are probably angular velocities in degrees/second around those three axes.
  • ah, ok that makes more sense now. Thanks for the example too, that's what I had been doing but it just didn't click as to why I needed to and then wondered if there was a better way I was missing.

    cheers