Example #1
0
        void Awake()
        {
            _sendFrameCallback = NativePlugin.GetSendFrameCallback();

            LogVersion();

            QualitySettings.vSyncCount      = 0;
            QualitySettings.maxQueuedFrames = 0;
        }
Example #2
0
        internal static bool ScanForWands()
        {
            int result = 1;

            try
            {
                result = NativePlugin.ScanForWands();
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }

            return(0 == result);
        }
Example #3
0
        public static bool SwapWandHandedness()
        {
            int result = 1;

            try
            {
                result = NativePlugin.SwapWandHandedness();
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }

            return(0 == result);
        }
Example #4
0
        // TODO: We may want to change this to something like "GetWandStatus()",
        // returning a flags enum with options like "ready, disconnected, batteryLow" etc.
        public static bool GetWandAvailability(Input.WandTarget targetWand = Input.WandTarget.Primary)
        {
            bool wandAvailable = false;

            try
            {
                int result = NativePlugin.GetWandAvailability(ref wandAvailable, targetWand);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }

            return(wandAvailable);
        }
Example #5
0
        bool GetHeadPoseImpl(ref Vector3 position, ref Quaternion rotation)
        {
            int result = 1;

            try
            {
                result = NativePlugin.GetGlassesPose(_headRotation, _headPosition);
                if (0 == result)
                {
                    position = new Vector3(_headPosition[0], _headPosition[1], _headPosition[2]);
                    rotation = new Quaternion(_headRotation[0], _headRotation[1], _headRotation[2], _headRotation[3]);
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }

            return(0 == result);
        }
Example #6
0
        internal static bool GetWandControlsState(ref WandControlsState wandButtonsState, Input.WandTarget targetWand = Input.WandTarget.Primary)
        {
            int result = 1;

            try
            {
                UInt32  buttons   = 0;
                float[] stick     = new float[2];
                float   trigger   = 0f;
                Int64   timestamp = 0;

                result = NativePlugin.GetControllerState(targetWand, ref buttons, stick, ref trigger, ref timestamp);

                wandButtonsState = new WandControlsState(timestamp, buttons, new Vector2(stick[0], stick[1]), trigger);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }


            return(0 == result);
        }
Example #7
0
        private bool GetDisplayDimensionsImpl(ref Vector2Int displayDimensions)
        {
            int result = 1;

            try
            {
                result = NativePlugin.GetMaxDisplayDimensions(_displaySettings);

                if (result == 0)
                {
                    displayDimensions = new Vector2Int(_displaySettings[0], _displaySettings[1]);
                }
                else
                {
                    Log.Warn("Plugin.cs: Failed to retrieve display settings from plugin.");
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }

            return(0 == result);
        }
Example #8
0
        bool PresentStereoImagesImpl(
            IntPtr leftTexHandle,
            IntPtr rightTexHandle,
            int texWidth_PIX,
            int texHeight_PIX,
            bool isSrgb,
            float fovYDegrees,
            float widthToHeightRatio,
            Quaternion rotToUGBL_ULVC,
            Vector3 posULVC_UGBL,
            Quaternion rotToUGBL_URVC,
            Vector3 posURVC_UGBL)
        {
            float startY_VCI = -Mathf.Tan(fovYDegrees * (0.5f * Mathf.PI / 180.0f));
            float startX_VCI = startY_VCI * widthToHeightRatio;
            float width_VCI  = -2.0f * startX_VCI;
            float height_VCI = -2.0f * startY_VCI;

            _rotToULVC_UGBL[0] = -rotToUGBL_ULVC.x;
            _rotToULVC_UGBL[1] = -rotToUGBL_ULVC.y;
            _rotToULVC_UGBL[2] = -rotToUGBL_ULVC.z;
            _rotToULVC_UGBL[3] = rotToUGBL_ULVC.w;

            _posULVC_UGBL[0] = posULVC_UGBL.x;
            _posULVC_UGBL[1] = posULVC_UGBL.y;
            _posULVC_UGBL[2] = posULVC_UGBL.z;

            _rotToURVC_UGBL[0] = -rotToUGBL_URVC.x;
            _rotToURVC_UGBL[1] = -rotToUGBL_URVC.y;
            _rotToURVC_UGBL[2] = -rotToUGBL_URVC.z;
            _rotToURVC_UGBL[3] = rotToUGBL_URVC.w;

            _posURVC_UGBL[0] = posURVC_UGBL.x;
            _posURVC_UGBL[1] = posURVC_UGBL.y;
            _posURVC_UGBL[2] = posURVC_UGBL.z;

            int result = 0;

            try
            {
                result = NativePlugin.QueueStereoImages(leftTexHandle,
                                                        rightTexHandle,
                                                        (ushort)texWidth_PIX,
                                                        (ushort)texHeight_PIX,
                                                        isSrgb,
                                                        startX_VCI,
                                                        startY_VCI,
                                                        width_VCI,
                                                        height_VCI,
                                                        _rotToULVC_UGBL,
                                                        _posULVC_UGBL,
                                                        _rotToURVC_UGBL,
                                                        _posURVC_UGBL);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }

            if (result != 0)
            {
                return(false);
            }

            GL.IssuePluginEvent(_sendFrameCallback, 0);

            return(true);
        }
Example #9
0
 bool GetGlassesAvailabilityImpl()
 {
     return(NativePlugin.RefreshGlassesAvailable() == 0);
 }