Exemplo n.º 1
0
        //device情報を取得する
        public bool GetPropertyBool(uint idx, ETrackedDeviceProperty prop, out bool result)
        {
            ETrackedPropertyError error = new ETrackedPropertyError();

            result = openvr.GetBoolTrackedDeviceProperty(idx, prop, ref error);
            return(error == ETrackedPropertyError.TrackedProp_Success);
        }
Exemplo n.º 2
0
        private void UpdatePoses()
        {
            _vrSystem.GetDeviceToAbsoluteTrackingPose(_trackingOrigin, 0, _allPoses);

            for (int i = 0; i < _tracker.Count; i++)
            {
                int index = _tracker[i].DeviceId;

                if (index == -1)
                {
                    continue;
                }

                var pose = _allPoses[index];

                float batteryPercent = 1.0f;
                bool  isCharging     = false;

                if (_tracker[i].HasBattery)
                {
                    var error = ETrackedPropertyError.TrackedProp_UnknownProperty;
                    batteryPercent = _vrSystem.GetFloatTrackedDeviceProperty((uint)index, ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref error);

                    isCharging = _vrSystem.GetBoolTrackedDeviceProperty((uint)index, ETrackedDeviceProperty.Prop_DeviceIsCharging_Bool, ref error);
                }

                _tracker[i].SetTrackingState(pose.eTrackingResult, batteryPercent, isCharging, false);

                if (pose.bPoseIsValid)
                {
                    var absTracking = pose.mDeviceToAbsoluteTracking;

                    Vector3    pos;
                    Quaternion rot;
                    HOVR_Utility.GetPosAndRotation(absTracking, out pos, out rot);

                    pos.Scale(_posScale);

                    _tracker[i].ReceivePose(pos, rot);
                }
            }
        }