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); }
private Vector3 PollVInput(Node node, OVRPlugin.Node ovrNode, NodeStatePropertyType type) { Vector3 value; OVRNodeStateProperties.GetNodeStatePropertyVector3(node, type, ovrNode, OVRPlugin.Step.Render, out value); return(value); }
private Quaternion PollQInput(Node node, OVRPlugin.Node ovrNode, NodeStatePropertyType type) { Quaternion value; OVRNodeStateProperties.GetNodeStatePropertyQuaternion(node, type, ovrNode, OVRPlugin.Step.Render, out value); return(value); }
private static bool GetUnityXRNodeStateVector3(Node nodeType, NodeStatePropertyType propertyType, out Vector3 retVec) { retVec = Vector3.zero; NodeState requestedNodeState = default(NodeState); if (!ValidateProperty(nodeType, ref requestedNodeState)) { return(false); } if (propertyType == NodeStatePropertyType.Acceleration) { if (requestedNodeState.TryGetAcceleration(out retVec)) { return(true); } } else if (propertyType == NodeStatePropertyType.AngularAcceleration) { #if UNITY_2017_2_OR_NEWER if (requestedNodeState.TryGetAngularAcceleration(out retVec)) { return(true); } #endif } else if (propertyType == NodeStatePropertyType.Velocity) { if (requestedNodeState.TryGetVelocity(out retVec)) { return(true); } } else if (propertyType == NodeStatePropertyType.AngularVelocity) { #if UNITY_2017_2_OR_NEWER if (requestedNodeState.TryGetAngularVelocity(out retVec)) { return(true); } #endif } else if (propertyType == NodeStatePropertyType.Position) { if (requestedNodeState.TryGetPosition(out retVec)) { return(true); } } return(false); }
public static bool GetNodeStatePropertyQuaternion(NodeStatePropertyType propertyType, Plugin.Node ovrpNodeType, Plugin.ProcessingStep stepType, out Quaternion retQuat) { retQuat = Quaternion.Identity; switch (propertyType) { case NodeStatePropertyType.Orientation: if (Manager.loadedXRDevice == Manager.XRDevice.Oculus) { retQuat = Plugin.GetNodePose(ovrpNodeType, stepType).ToOVRPose().Orientation; return(true); } break; } return(false); }
public static bool GetNodeStatePropertyVector3(NodeStatePropertyType propertyType, Plugin.Node ovrpNodeType, Plugin.ProcessingStep stepType, out Vector3 retVec) { retVec = Vector3.Zero; switch (propertyType) { case NodeStatePropertyType.Acceleration: if (Manager.loadedXRDevice == Manager.XRDevice.Oculus) { retVec = Plugin.GetNodeAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } break; case NodeStatePropertyType.AngularAcceleration: if (Manager.loadedXRDevice == Manager.XRDevice.Oculus) { retVec = Plugin.GetNodeAngularAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } break; case NodeStatePropertyType.Velocity: if (Manager.loadedXRDevice == Manager.XRDevice.Oculus) { retVec = Plugin.GetNodeVelocity(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } break; case NodeStatePropertyType.AngularVelocity: if (Manager.loadedXRDevice == Manager.XRDevice.Oculus) { retVec = Plugin.GetNodeAngularVelocity(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } break; case NodeStatePropertyType.Position: if (Manager.loadedXRDevice == Manager.XRDevice.Oculus) { retVec = Plugin.GetNodePose(ovrpNodeType, stepType).ToOVRPose().Position; return(true); } break; } return(false); }
public static bool GetNodeStatePropertyQuaternion(Node nodeType, NodeStatePropertyType propertyType, OVRPlugin.Node ovrpNodeType, OVRPlugin.Step stepType, out Quaternion retQuat) { retQuat = Quaternion.identity; switch (propertyType) { case NodeStatePropertyType.Orientation: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retQuat = OVRPlugin.GetNodePose(ovrpNodeType, stepType).ToOVRPose().orientation; return(true); } if (GetUnityXRNodeStateQuaternion(nodeType, NodeStatePropertyType.Orientation, out retQuat)) { return(true); } break; } return(false); }
private static bool GetUnityXRNodeStateQuaternion(Node nodeType, NodeStatePropertyType propertyType, out Quaternion retQuat) { retQuat = Quaternion.identity; NodeState requestedNodeState = default(NodeState); if (!ValidateProperty(nodeType, ref requestedNodeState)) { return(false); } if (propertyType == NodeStatePropertyType.Orientation) { if (requestedNodeState.TryGetRotation(out retQuat)) { return(true); } } return(false); }
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); }
public Vector3 GetNodeStateProperty(Node nodeType, NodeStatePropertyType propertyType) { List <NodeState> nodeStateList = new List <NodeState>(); InputTracking.GetNodeStates(nodeStateList); if (nodeStateList.Count == 0) { return(Vector3.zero); } bool nodeStateFound = false; NodeState requestedNodeState = nodeStateList[0]; for (int i = 0; i < nodeStateList.Count; i++) { if (nodeStateList[i].nodeType == nodeType) { requestedNodeState = nodeStateList[i]; nodeStateFound = true; break; } } if (!nodeStateFound) { return(Vector3.zero); } Vector3 retVec; if (propertyType == NodeStatePropertyType.Acceleration) { if (requestedNodeState.TryGetAcceleration(out retVec)) { return(retVec); } } else if (propertyType == NodeStatePropertyType.AngularAcceleration) { #if UNITY_2017_2_OR_NEWER if (requestedNodeState.TryGetAngularAcceleration(out retVec)) { retVec = retVec * Mathf.Rad2Deg; return(retVec); } #endif } else if (propertyType == NodeStatePropertyType.Velocity) { if (requestedNodeState.TryGetVelocity(out retVec)) { return(retVec); } } else if (propertyType == NodeStatePropertyType.AngularVelocity) { #if UNITY_2017_2_OR_NEWER if (requestedNodeState.TryGetAngularVelocity(out retVec)) { retVec = retVec * Mathf.Rad2Deg; return(retVec); } #endif } return(Vector3.zero); }