/// <summary> /// Blink causes the color to change. At most once per second. /// </summary> void blinkInterface_StateChanged(object sender, OSVR.ClientKit.TimeValue timestamp, int sensor, bool report) { if (lastBlinkReportState != report && timestamp.seconds - lastBlinkColorChangeTimestampSeconds > 1) { ChangeColorNext(); lastBlinkColorChangeTimestampSeconds = timestamp.seconds; } lastBlinkReportState = report; }
/// <summary> /// Button wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes. /// </summary> /// <param name="userdata">Unused</param> /// <param name="timestamp">Unused</param> /// <param name="report">Button report</param> private void ButtonCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.ButtonReport report) { bool pressed = (report.state == 1); if (buttonCallbacks != null) { buttonCallbacks(path, pressed); } }
/// <summary> /// Analog wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes. /// </summary> /// <param name="userdata">Unused</param> /// <param name="timestamp">Unused</param> /// <param name="report">Analog report</param> private void AnalogCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.AnalogReport report) { float val = (float)report.state; if (null != analogCallbacks) { analogCallbacks(path, val); } }
/// <summary> /// Position wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion. /// </summary> /// <param name="userdata">Unused</param> /// <param name="timestamp">Unused</param> /// <param name="report">Tracker position report</param> private void PositionCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PositionReport report) { Vector3 position = Math.ConvertPosition(report.xyz); if (null != positionCallbacks) { positionCallbacks(path, position); } }
/// <summary> /// Orientation wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion. /// </summary> /// <param name="userdata">Unused</param> /// <param name="timestamp">Unused</param> /// <param name="report">Tracker orientation report</param> private void OrientationCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.OrientationReport report) { Quaternion rotation = Math.ConvertOrientation(report.rotation); if (null != orientationCallbacks) { orientationCallbacks(path, rotation); } }
/// <summary> /// Pose (as a 4x4 matrix) wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion. /// </summary> /// <param name="userdata">Unused</param> /// <param name="timestamp">Unused</param> /// <param name="report">Tracker pose report</param> private void PoseMatrixCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PoseReport report) { Matrix4x4 matPose = Math.ConvertPose(report.pose); if (null != poseMatrixCallbacks) { poseMatrixCallbacks(path, matPose); } }
/* END GENERATED CODE - unity-generate.lua */ #endregion /// These wrappers sadly have to be mostly hand-written, despite their similarity, since they convert data types /// and also data conventions (into Unity's left-handed coordinate system) #region Private wrapper callbacks/trampolines /// <summary> /// Pose (as position and orientation) wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion. /// </summary> /// <param name="userdata">Unused</param> /// <param name="timestamp">Unused</param> /// <param name="report">Tracker pose report</param> private void PoseCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PoseReport report) { Vector3 position = Math.ConvertPosition(report.pose.translation); Quaternion rotation = Math.ConvertOrientation(report.pose.rotation); if (null != poseCallbacks) { poseCallbacks(path, position, rotation); } }
void Interface_StateChanged(object sender, OSVR.ClientKit.TimeValue timestamp, int sensor, double report) { if (trackedGameObjects.Length == 0 || trackedGameObjects[CurrentIndex] == null) { return; } if (disableGameObjectBelowConfidenceThreshold) { confidence = report; //disable the active gameobject if confidence is below the threshold if (confidence < threshold) { //SetActive() may not be the best choice here, but this is where you put code to handle //a loss of tracking confidence if (trackedGameObjects[CurrentIndex].activeSelf) { trackedGameObjects[CurrentIndex].SetActive(false); } } else { for (int i = 0; i < trackedGameObjects.Length; i++) { if (i == CurrentIndex) { if (!trackedGameObjects[i].activeSelf) { trackedGameObjects[i].SetActive(true); } } else { if (trackedGameObjects[i].activeSelf) { trackedGameObjects[i].SetActive(false); } } } } } }
void Interface_StateChanged(object sender, OSVR.ClientKit.TimeValue timestamp, int sensor, double report) { Debug.Log("Got analog value " + report); }
public void handleButton(object sender, OSVR.ClientKit.TimeValue timestamp, int sensor, byte report) { Debug.Log("[OSVR-Unity-Samples] Got button: " + sensor.ToString() + " state is " + report.ToString()); }
private void callback(IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.OrientationReport report) { transform.localRotation = Math.ConvertOrientation(report.rotation); }
private void callback(IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PositionReport report) { transform.localPosition = Math.ConvertPosition(report.xyz); }