public static Vector3 GetNodeStateProperty(Node nodeType, NodeStatePropertyType propertyType, OVRPlugin.Node ovrpNodeType, OVRPlugin.Step stepType) { switch (propertyType) { case NodeStatePropertyType.Acceleration: #if UNITY_2017_1_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.Acceleration)); #else return(OVRPlugin.GetNodeAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f()); #endif case NodeStatePropertyType.AngularAcceleration: #if UNITY_2017_2_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.AngularAcceleration)); #else return(OVRPlugin.GetNodeAngularAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f() * Mathf.Rad2Deg); #endif case NodeStatePropertyType.Velocity: #if UNITY_2017_1_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.Velocity)); #else return(OVRPlugin.GetNodeVelocity(ovrpNodeType, stepType).FromFlippedZVector3f()); #endif case NodeStatePropertyType.AngularVelocity: #if UNITY_2017_2_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.AngularVelocity)); #else return(OVRPlugin.GetNodeAngularVelocity(ovrpNodeType, stepType).FromFlippedZVector3f() * Mathf.Rad2Deg); #endif } return(Vector3.zero); }
public static float GetUpwardsAcceleration() { #if OCULUS_VR if (isOculusGo) { return(OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.Head, OVRPlugin.Step.Render).FromFlippedZVector3f().y / 16f); } #endif return(Vector3.Dot(Input.gyro.userAcceleration, -Input.gyro.gravity)); }
public static bool GetNodeStatePropertyVector3(Node nodeType, NodeStatePropertyType propertyType, OVRPlugin.Node ovrpNodeType, OVRPlugin.Step stepType, out Vector3 retVec) { retVec = Vector3.zero; switch (propertyType) { case NodeStatePropertyType.Acceleration: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.Acceleration, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.AngularAcceleration: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeAngularAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_2_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.AngularAcceleration, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.Velocity: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeVelocity(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.Velocity, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.AngularVelocity: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeAngularVelocity(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_2_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.AngularVelocity, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.Position: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodePose(ovrpNodeType, stepType).ToOVRPose().position; return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.Position, out retVec)) { return(true); } #endif break; } return(false); }