Esempio n. 1
0
 public override bool InitInternal()
 {
     if ((XDevicePlugin.GetInt(XDevicePlugin.ID_CONTEXT, XDevicePlugin.kField_CtxDeviceVersionInt, 0x4000) & 0xF000) != 0x4000)
     {
         return(false);
     }
     //
     if (true)
     {
         Vector3 position = PlayerPrefsEx.GetVector3("XimmerseTracker[Outside-in].position");
         Vector3 rotation = PlayerPrefsEx.GetVector3("XimmerseTracker[Outside-in].rotation");
         XDevicePlugin.SetTrackerPose(m_Handle, position.y, position.z, rotation.x);
         //
         XDevicePlugin.GetTrackerPose(m_Handle, out position.y, out position.z, out rotation.x);
         //
         int i = m_Controllers.Length; while (i-- > 0)
         {
             XDevicePlugin.SetBool(XDevicePlugin.GetInputDeviceHandle(m_Controllers[i].key), XDevicePlugin.kField_IsAbsRotationBool, true);
         }
         //
         //PlayerPrefsEx.SetBool("VRDevice.forceFadeOnBadTracking",true);
         XDevicePlugin.NativeMethods.XDeviceSetDecoderFeature(XDevicePlugin.FEATURE_BLOB_AUTO);
     }
     return(base.InitInternal());
 }
Esempio n. 2
0
 public override void UpdateState()
 {
     if (m_Handle >= 0)
     {
         if (Time.frameCount != m_PrevFrameCount)
         {
             int t = m_PrevFrameCount;
             m_PrevFrameCount = Time.frameCount;
             if (EnsureAnchor())
             {
                 //
                 UpdateAnchor();
                 m_PrevFrameCount = t;
                 base.UpdateState();
                 //
                 if (m_EnableEmulatedHand)
                 {
                     for (int i = 0, imax = m_EmulatedHands.Length; i < imax; ++i)
                     {
                         if (m_EmulatedHands[i].handedness != ControllerType.None)
                         {
                             m_EmulatedHands[i].OnControllerUpdate();
                             if (m_IsRequestVR)
                             {
                                 m_EmulatedHands[i].showGizmos = (XDevicePlugin.GetNodePosition(m_Handle, 0, i, null) & TrackingResult.PositionTracked) == 0;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        public override bool InitInternal()
        {
            if ((XDevicePlugin.GetInt(XDevicePlugin.ID_CONTEXT, XDevicePlugin.kField_CtxDeviceVersionInt, 0) & 0xF000) != 0x3000)
            {
                return(false);
            }
            // TODO : Read offsets from the plugin.
#if !true
            m_AnchorPosition = Vector3.zero;
            m_AnchorRotation = Quaternion.identity;
#else
            VRDevice vrDevice = VRContext.currentDevice;
            if (vrDevice != null)
            {
                m_AnchorPosition = vrDevice.inOutsideMarkPose.position;
                m_AnchorRotation = vrDevice.inOutsideMarkPose.rotation;
            }
            else
            {
                m_AnchorPosition = Vector3.zero;
                m_AnchorRotation = Quaternion.identity;
            }
#endif
            //
            return(base.InitInternal());
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes the device module.
        /// </summary>
        public static void InitializeDeviceModule(bool isFirst = true)
        {
            if (isInitialized)
            {
                return;
            }
            if (Application.platform == RuntimePlatform.Android)
            {
                Ximmerse.InputSystem.XDevicePlugin.Init();
                //Apply logs:
                XDevicePlugin.SetLogger((int level, string _tag, string log) =>
                {
                    Debug.LogFormat("level:{0} ,tag:{1}, log:{2}", level, _tag, log);
                });

                if (isFirst)
                {
                    XDevicePlugin.CopyAssetsToPath(kConfigFileDirectory);
                }
                DevicerHandle.SlideInContext = XDevicePlugin.NewContext(XDevicePlugin.XContextTypes.kXContextTypeSlideIn);/// 创建SlideIn设备上下文
                DevicerHandle.HmdHandle      = XDevicePlugin.GetDeviceHandle(DevicerHandle.SlideInContext, "XHawk-0");
                if (isFirst)
                {
                    TagTrackingUtil.ApplyDefaultConfig();
                }

                DeviceConnectionState vpuConn = (DeviceConnectionState)XDevicePlugin.GetInt(DevicerHandle.HmdHandle, XDevicePlugin.XVpuAttributes.kXVpuAttr_Int_ConnectionState, 0);
                isVPUConnected = vpuConn == DeviceConnectionState.Connected;
                XDevicePlugin.RegisterObserver(DevicerHandle.HmdHandle, XDevicePlugin.XVpuAttributes.kXVpuAttr_Int_ConnectionState, new XDevicePlugin.XDeviceConnectStateChangeDelegate(OnVPUConnectionStateChanged), DevicerHandle.HmdHandle);
                isInitialized = true;

                Debug.LogFormat("Slide in HLAPI initialized successfully. HLAPI version : {0}, Algorithm version: {1}", HLAPIVersion.Version, HLAPIVersion.AlgVersion);
                Debug.LogFormat("VPU device state {0} ", vpuConn);
            }
            else if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
            {
                Ximmerse.InputSystem.XDevicePlugin.Init();
                XDevicePlugin.SetLogger((int level, string _tag, string log) =>
                {
                    Debug.LogFormat("level:{0} ,tag:{1}, log:{2}", level, _tag, log);
                });
                DevicerHandle.SlideInContext = XDevicePlugin.NewContext(XDevicePlugin.XContextTypes.kXContextTypeSlideIn);/// 创建SlideIn设备上下文
                DevicerHandle.HmdHandle      = XDevicePlugin.GetDeviceHandle(DevicerHandle.SlideInContext, "XHawk-0");
                Debug.LogFormat("VPU Context: {0}, Hmd handle:{1}", DevicerHandle.SlideInContext.mNativeHandle.ToInt32(), DevicerHandle.HmdHandle.mNativeHandle.ToInt32());
                TagTrackingUtil.ApplyDefaultConfig();


                var vpuConn = (DeviceConnectionState)XDevicePlugin.GetInt(DevicerHandle.HmdHandle, XDevicePlugin.XVpuAttributes.kXVpuAttr_Int_ConnectionState, 0);
                isVPUConnected = vpuConn == DeviceConnectionState.Connected;
                XDevicePlugin.RegisterObserver(DevicerHandle.HmdHandle, XDevicePlugin.XVpuAttributes.kXVpuAttr_Int_ConnectionState, new XDevicePlugin.XDeviceConnectStateChangeDelegate(OnVPUConnectionStateChanged), DevicerHandle.HmdHandle);
                isInitialized = true;

                Debug.LogFormat("Slide in HLAPI initialized successfully. HLAPI version : {0}, Algorithm version: {1}", HLAPIVersion.Version, HLAPIVersion.AlgVersion);
                Debug.LogFormat("VPU device state {0} ", vpuConn);
            }
            else
            {
                Debug.LogWarningFormat("Tracking Library not available for current platform : {0}. Currently we supports Android/Windows platform.", Application.platform);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// We will lose the VR context,when reloading level.
 /// Calling this function per frame can ensure that the anchor is alive.
 /// </summary>
 public virtual bool EnsureAnchor()
 {
     // <!-- TODO: VR Legacy Mode. -->
     // If the X-Hawk isn't connected,the game will run as legacy VR mode(Gets input events with GearVR touchpad).
     if (XDevicePlugin.GetInt(m_Handle, XDevicePlugin.kField_ConnectionStateInt, 0) != (int)DeviceConnectionState.Connected)
     {
         XDevicePlugin.SetInt(m_HmdInput.handle, XDevicePlugin.kField_ConnectionStateInt, (int)DeviceConnectionState.Disconnected);
         return(false);
     }
     //
     if (trackingSpace == null)
     {
         trackingSpace = VRContext.GetAnchor(VRNode.TrackingSpace);
     }
     //
     if (anchor == null)
     {
         Transform centerEyeAnchor = VRContext.GetAnchor(VRNode.CenterEye);
         if (m_IsRequestVR && centerEyeAnchor == null)
         {
             return(false);
         }
         else
         {
             CreateAnchor();
             //
             if (m_IsRequestVR)
             {
                 VRContext.main.onRecenter -= Recenter;
                 VRContext.main.onRecenter += Recenter;
             }
         }
     }
     return(true);
 }
Esempio n. 6
0
 public virtual void UpdateAnchorFromPlugin()
 {
     XDevicePlugin.GetObject(m_Handle, XDevicePlugin.kField_TRSObject, m_UpdateAnchorFromPluginTRS, 0);
     if (true)
     {
         anchor.localPosition = new Vector3(
             m_UpdateAnchorFromPluginTRS[0],
             m_UpdateAnchorFromPluginTRS[1],
             -m_UpdateAnchorFromPluginTRS[2]
             );
         anchor.localRotation = new Quaternion(
             -m_UpdateAnchorFromPluginTRS[3],
             -m_UpdateAnchorFromPluginTRS[4],
             m_UpdateAnchorFromPluginTRS[5],
             m_UpdateAnchorFromPluginTRS[6]
             );
         //
         if (makeTrackerForward)
         {
             if (trackingSpace != null)
             {
                 trackingSpace.localRotation = Quaternion.Euler(0.0f, -(anchor.localRotation.eulerAngles.y + 180.0f), 0.0f);
             }
         }
     }
 }
Esempio n. 7
0
 public static string ToString(TrackerInput input, int[] nodes)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder(string.Format(
                                                                      "TrackingInput@{0} Timestamp:{1}\n", input.m_Handle, input.m_State.frameCount));
     if (XDevicePlugin.GetInt(input.m_Handle, XDevicePlugin.kField_ConnectionStateInt, 0) != (int)DeviceConnectionState.Connected)
     {
         //
         sb.Append("Connection State=\"" + ((DeviceConnectionState)XDevicePlugin.GetInt(input.m_Handle, XDevicePlugin.kField_ConnectionStateInt, 0)));
         sb.Append("\"\nError Code=\"" + XDevicePlugin.GetInt(input.m_Handle, XDevicePlugin.kField_ErrorCodeInt, 0) + "\"");
     }
     else
     {
         Vector3 pos = new Vector3();
         int     node; for (int i = 0, imax = nodes.Length; i < imax; ++i)
         {
             node = nodes[i];
             if (input.Exists(node))
             {
                 pos = input.GetLocalPosition(node);
                 sb.AppendLine(string.Format("Node@{0} is {1}",
                                             node, pos.ToString("F3")));
             }
             else
             {
                 sb.AppendLine(string.Format("Node@{0} is not existed.", node));
             }
         }
     }
     return(sb.ToString());
 }
Esempio n. 8
0
 protected virtual void Start()
 {
     XDevicePlugin.Init();
     if (m_Handle == -1)
     {
         m_Handle = XDevicePlugin.GetInputDeviceHandle(deviceName);
     }
 }
Esempio n. 9
0
 public virtual void Recenter()
 {
     XDevicePlugin.SendMessage(m_Handle, XDevicePlugin.kMessage_RecenterSensor, 0, 0);
     if (onRecenter != null)
     {
         onRecenter.Invoke();
     }
 }
Esempio n. 10
0
 public virtual bool Exists(int node)
 {
     if (Controller != null && pointer != null)
     {
         return(XDevicePlugin.GetInt(Controller.handle, XDevicePlugin.kField_ConnectionStateInt, 0) == (int)DeviceConnectionState.Connected &&
                pointer.localPosition.sqrMagnitude > 0.0f);
     }
     return(false);
 }
 public override bool InitInternal()
 {
     if ((XDevicePlugin.GetInt(XDevicePlugin.ID_CONTEXT, XDevicePlugin.kField_CtxDeviceVersionInt, 0x4000) & 0xF000) != 0x4000)
     {
         return(false);
     }
     //
     return(base.InitInternal());
 }
Esempio n. 12
0
 public virtual bool Exists(int node)
 {
     if (Controller != null)
     {
         return(XDevicePlugin.GetInt(Controller.handle, XDevicePlugin.kField_ConnectionStateInt, 0) == (int)DeviceConnectionState.Connected);
         //return Controller.connectionState==DeviceConnectionState.Connected;
     }
     return(false);
 }
Esempio n. 13
0
 public virtual int InitInput()
 {
     if (m_Handle == -1)
     {
         m_Handle = XDevicePlugin.GetInputDeviceHandle(deviceName);
     }
     //
     return(m_Handle != -1?0:-1);
 }
Esempio n. 14
0
 /// <summary>
 /// Init X-Hawk for different user environments.
 /// </summary>
 public virtual bool InitInternal()
 {
     //
     XDevicePlugin.SetInt(m_Handle, XDevicePlugin.kField_TrackingOriginInt, (int)VRContext.trackingOrigin);
     XDevicePlugin.SendMessage(m_Handle, XDevicePlugin.kMessage_RecenterSensor, 0, 0);
     //
     if (true)
     {
         int i = 0, imax = m_Controllers.Length;
         controllers = new TrackedControllerInput[imax];
         //
         ControllerInputManager mgr = ControllerInputManager.instance;
         ControllerInput        ci;
         if (mgr != null)
         {
             for (; i < imax; ++i)
             {
                 ci = mgr.GetControllerInput(m_Controllers[i].key);
                 if (ci is TrackedControllerInput)
                 {
                     controllers[i] = ci as TrackedControllerInput;
                     controllers[i].inputTracking = this;
                     controllers[i].node          = m_Controllers[i].value;
                 }
                 else
                 {
                     controllers[i] = CreateControllerInput(m_Controllers[i].key, this, m_Controllers[i].value);
                     if (controllers[i].handle != -1)
                     {
                         mgr.AddControllerInput(controllers[i].name, controllers[i]);
                     }
                     else
                     {
                         controllers[i] = null;
                     }
                 }
                 //
                 if (i < 2)
                 {
                     m_EmulatedHands[i].Controller = controllers[i];
                     m_EmulatedHands[i].followGaze = ArmModel.GazeBehavior.Always;
                     m_EmulatedHands[i].Start();
                 }
             }
         }
     }
     // VR Context
     m_HmdInput = ControllerInputManager.GetInput(ControllerType.Hmd);
     // VRContext must have a CenterEyeAnchor at least.
     m_IsRequestVR = (VRContext.GetAnchor(VRNode.CenterEye) != null);
     EnsureAnchor();
     //
     Log.i("XHawkInput", "Initialize successfully.");
     //
     return(true);
 }
Esempio n. 15
0
 /// <summary>
 /// De-initialize the module.
 /// </summary>
 public static void DeInitializeModule()
 {
     if (isInitialized)
     {
         isInitialized = false;
         XDevicePlugin.ReleaseContext(DevicerHandle.HmdHandle);
         XDevicePlugin.SetLogger(null);
         XDevicePlugin.Exit();
     }
 }
Esempio n. 16
0
 public virtual void UpdateState()
 {
     if (Time.frameCount != m_PrevFrameCount)
     {
         m_PrevFrameCount = Time.frameCount;
         m_PrevState      = m_State;
         //
         XDevicePlugin.GetInputState(this.handle, ref this.m_State);
     }
 }
Esempio n. 17
0
 protected virtual void OnDestroy()
 {
     s_InstanceCached = false;
     //
     if (onDestroy != null)
     {
         onDestroy();
     }
     //
     XDevicePlugin.Exit();
 }
Esempio n. 18
0
 public virtual void Recenter_DK4()
 {
     XDevicePlugin.SendMessage(m_Handle, XDevicePlugin.kMessage_RecenterSensor, 1, 0);
     UpdateAnchorFromPlugin();
     m_AnchorInfoCached = false;
     //
     if (m_TrackerFrustum != null)
     {
         m_TrackerFrustum.OnTrackerRecenter();
     }
 }
Esempio n. 19
0
 public virtual void OnControllerUpdate()
 {
     if (centerEye == null)
     {
         centerEye     = VRContext.GetAnchor(VRNode.CenterEye);
         trackingSpace = VRContext.GetAnchor(VRNode.TrackingSpace);
     }
     if (unityHelper == null)
     {
         unityHelper = new GameObject("UnityHelper-" + handedness).transform;
         pointer     = new GameObject("Pointer-" + handedness).transform;
         //
         unityHelper.SetParent(trackingSpace);
         unityHelper.localPosition = Vector3.zero;
         unityHelper.localRotation = Quaternion.identity;
         unityHelper.localScale    = Vector3.one;
         pointer.SetParent(unityHelper);
         pointer.localPosition = Vector3.zero;
         pointer.localRotation = Quaternion.identity;
         pointer.localScale    = Vector3.one;
     }
     if (centerEye != null)
     {
         //
         unityHelper.position = centerEye.position                                                                     //@Eye
                                - centerEye.rotation * NECK_TO_EYE                                                     //@Neck
                                + Quaternion.AngleAxis(centerEye.rotation.eulerAngles.y, Vector3.up) * neckToShoulder; //@Shoulder
         //
         Quaternion rotation = Quaternion.LookRotation(Controller.GetRotation() * Vector3.forward, Vector3.up);
         if (trackingSpace != null)
         {
             unityHelper.rotation = trackingSpace.rotation * rotation;
         }
         else
         {
             unityHelper.rotation = rotation;
         }
         //
         if ((XDevicePlugin.GetInt(Controller.handle, XDevicePlugin.kField_TrackingResultInt, 0) & (int)TrackingResult.PositionTracked) == 0)
         {
         }
         else
         {
             if (trackingSpace == null)
             {
                 pointer.position = Controller.GetPosition();
             }
             else
             {
                 pointer.position = trackingSpace.TransformPoint(Controller.GetPosition());
             }
         }
     }
 }
Esempio n. 20
0
 /// <summary>
 ///
 /// </summary>
 public virtual bool InitInternal()
 {
     if (m_IsInited)
     {
         return(true);
     }
     m_IsInited = true;
     // Plugin context.
     deviceName = "XHawk-0";
     if (m_Handle == -1)
     {
         m_Handle = XDevicePlugin.GetInputDeviceHandle(deviceName);
     }
     XDevicePlugin.SetInt(m_Handle, XDevicePlugin.kField_TrackingOriginInt, (int)VRContext.trackingOrigin);
     XDevicePlugin.SendMessage(m_Handle, XDevicePlugin.kMessage_RecenterSensor, 0, 0);
     //
     if (true)
     {
         int i = 0, imax = m_Controllers.Length;
         controllers = new TrackedControllerInput[imax];
         //
         ControllerInputManager mgr = ControllerInputManager.instance;
         ControllerInput        ci;
         if (mgr != null)
         {
             for (; i < imax; ++i)
             {
                 ci = mgr.GetControllerInput(m_Controllers[i].key);
                 if (ci is TrackedControllerInput)
                 {
                     controllers[i] = ci as TrackedControllerInput;
                     controllers[i].inputTracking = this;
                     controllers[i].node          = m_Controllers[i].value;
                 }
                 else
                 {
                     controllers[i] = CreateControllerInput(m_Controllers[i].key, this, m_Controllers[i].value);
                     mgr.AddControllerInput(controllers[i].name, controllers[i]);
                 }
             }
         }
     }
     // VR Context
     m_HmdInput = ControllerInputManager.GetInput(ControllerType.Hmd);
     // VRContext must have a CenterEyeAnchor at least.
     m_IsRequestVR = (VRContext.GetAnchor(VRNode.CenterEye) != null);
     EnsureAnchor();
     //
     Log.i("XHawkInput", "Initialize successfully.");
     //
     return(true);
 }
Esempio n. 21
0
 public virtual void StartHaptics(int strength, int frequency, float duration = 0.0f)
 {
     DelayedCall.Free(ref m_VibrationDC);
     //
     strength = Mathf.Clamp(strength, 0, 100);        //[0,100],0 -> Default.
     XDevicePlugin.SendMessage(handle, XDevicePlugin.kMessage_TriggerVibration,
                               (int)((strength <= 0?20:strength) | ((frequency << 16) & 0xFFFF0000)),
                               (int)(duration * 1000)
                               );
     if (duration > 0.0f)
     {
         m_VibrationDC = Juggler.Main.DelayCall(StopHaptics, duration);
     }
 }
Esempio n. 22
0
 public virtual int InitInput()
 {
     if ((XDevicePlugin.GetInt(XDevicePlugin.ID_CONTEXT, XDevicePlugin.kField_CtxDeviceVersionInt, 0) & 0xF000) != 0x1000)
     {
         return(-1);
     }
     // Override ControllerInput in ControllerInputManager.
     if (true)
     {
         //
         ControllerInputManager mgr = ControllerInputManager.instance;
         ControllerInput        ci;
         if (mgr != null)
         {
             for (int i = 0, imax = m_Controllers.Length; i < imax; ++i)
             {
                 if (m_Controllers[i].handedness != ControllerType.None)
                 {
                     ci = mgr.GetControllerInput(m_Controllers[i].name);
                     if (ci is TrackedControllerInput)
                     {
                         m_Controllers[i].Controller = ci as TrackedControllerInput;
                         m_Controllers[i].Controller.inputTracking = m_Controllers[i];
                         m_Controllers[i].Controller.node          = -1;
                     }
                     else
                     {
                         m_Controllers[i].Controller = new TrackedControllerInput(m_Controllers[i].name, m_Controllers[i], -1);
                         if (m_Controllers[i].Controller.handle != -1)
                         {
                             mgr.AddControllerInput(m_Controllers[i].name, m_Controllers[i].Controller);
                         }
                         else
                         {
                             m_Controllers[i].Controller = null;
                         }
                     }
                     //
                     m_Controllers[i].Start();
                 }
             }
         }
         else
         {
             return(-1);
         }
     }
     //
     return(0);
 }
 public virtual void StartHaptics(int strength, int frequency, float duration = 0.0f)
 {
     ++m_HapticsDC;
     //
     strength = Mathf.Clamp(strength, 0, 100);        //[0,100],0 -> Default.
     XDevicePlugin.SendMessage(handle, XDevicePlugin.kMessage_TriggerVibration,
                               (int)((strength <= 0?20:strength) | ((frequency << 16) & 0xFFFF0000)),
                               (int)(duration * 1000)
                               );
     if (duration > 0.0f)
     {
         // TODO :
         ControllerInputManager.instance.StartCoroutine(StopHapticsDelayed(duration));
     }
 }
Esempio n. 24
0
        public virtual float GetBetterYaw()
        {
            float yaw = getHmdYaw();

            //
            if (yaw >= 0 &&
                (XDevicePlugin.GetNodePosition(m_Handle, 0, 2, null) & TrackingResult.PositionTracked) != 0)
            {
                return(360.0f - yaw);
            }
            else
            {
                return(GetRawYaw() + m_YawOffset);
            }
        }
Esempio n. 25
0
 protected virtual void OnApplicationPause(bool pauseStatus)
 {
     if (m_IsPaused != pauseStatus)
     {
         m_IsPaused = pauseStatus;
         //
         XDevicePlugin.setHMDRotation(Quaternion.identity);
         if (m_IsPaused)                 // OnPause()
         {
         }
         else                   // OnResume()
         {
             AlignHmd();
         }
     }
 }
Esempio n. 26
0
        /// <summary>
        /// Initialize all the input controller .
        /// </summary>
        public virtual void InitAllControllerInputs()
        {
            //
            int ret = XDevicePlugin.Init();

            if (ret != 0)
            {
                /*...*/
            }
            //
            if (m_ControllerDataTxt != null)
            {
                s_ControllerDatabase = ControllerInfo.ParseFromText(
                    s_ControllerDatabase, m_ControllerDataTxt.text);
            }
            //
#if XDEVICE_EXT
            InitExternalControllerDevices();
#endif
            //
            int    whichBufferSize = XDevicePlugin.GetInputDeviceCount();
            int[]  whichBuffer     = new int[whichBufferSize];
            string name;
            int    handle, i = 0, imax = XDevicePlugin.GetInputDevices(1, whichBuffer, whichBufferSize);
            //
            if (controllerInputs == null)
            {
                controllerInputs = new Dictionary <string, ControllerInput>(imax);
            }
            else
            {
                controllerInputs.Clear();
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("ControllerInput List:");
            for (; i < imax; ++i)
            {
                handle = whichBuffer[i];
                name   = XDevicePlugin.GetInputDeviceName(handle);
                AddControllerInput(name, new ControllerInput(handle, name));
                //
                sb.AppendLine("\t{ControllerInput name=\"" + name + "\" handle=\"" + handle + "\"}");
            }
            Log.i("ControllerInputManager", sb.ToString());
            //
            m_OnInitialized.Invoke();
        }
Esempio n. 27
0
        public virtual int ExitInput()
        {
            int ret;

            //
            for (int i = 0, imax = inputModules.Length; i < imax; ++i)
            {
                if (inputModules[i] != null)
                {
                    ret = inputModules[i].ExitInput();
                }
            }
            //
            XDevicePlugin.Exit();
            //
            return(0);
        }
Esempio n. 28
0
        public override void Recenter()
        {
            switch ((XDevicePlugin.GetInt(-1, XDevicePlugin.kField_CtxDeviceVersion, 0x4000) & 0xF000))
            {
            case 0x3000:
                break;

            case 0x4000:
                Recenter_DK4();
                break;
            }
            //
            if (onRecenter != null)
            {
                onRecenter.Invoke();
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Gets marker tracking state, if marker is not tracked, return false.
        /// If tracked, out tracked raw position + rotation.
        /// SubMarkerMask : the bitmask of sub markers. Each submark takes 1 bit.
        /// </summary>
        /// <returns><c>true</c>, if marker state was gotten, <c>false</c> otherwise.</returns>
        /// <param name="markerID">Marker I.</param>
        /// <param name="rawPos">Raw position.</param>
        /// <param name="rawRotation">Raw rotation.</param>
        /// <param name="SubMarkerMask">Sub marker mask.</param>
        internal static bool GetMarkerState(int markerID, out Vector3 rawPos, out Quaternion rawRotation, out ulong SubMarkerMask)
        {
            if (IsSupported)
            {
                XDevicePlugin.XAttrTrackingInfo marker_info = new XDevicePlugin.XAttrTrackingInfo(0, markerID);
                XDevicePlugin.GetObject(DevicerHandle.HmdHandle, XDevicePlugin.XVpuAttributes.kXVpuAttr_Obj_TrackingInfo, ref marker_info);
                //                XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_GetMarkerInfo, ref marker_info);
                rawPos        = Vector3.zero;
                rawRotation   = Quaternion.identity;
                SubMarkerMask = 0;
                if (marker_info.state == (int)TrackingResult.PoseTracked)
                {
                    var XYZIndex = RawPositionindex;
                    var QIndex   = RawRotationIndex;
                    var XYZMul   = RawPositionFieldMultiplier;
                    var QMul     = RawRotationFieldMultiplier;

                    rawPos = new Vector3(
                        marker_info.position[XYZIndex.x] * XYZMul.x,
                        marker_info.position[XYZIndex.y] * XYZMul.y,
                        marker_info.position[XYZIndex.z] * XYZMul.z);

                    rawRotation = MarkerPosePreTilt * new Quaternion(
                        marker_info.rotation[QIndex.x] * QMul.x,
                        marker_info.rotation[QIndex.y] * QMul.y,
                        marker_info.rotation[QIndex.z] * QMul.z,
                        marker_info.rotation[QIndex.w] * QMul.w)
                                  * MarkerPosePostTilt;

                    SubMarkerMask = marker_info.recognized_markers_mask;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                rawPos        = Vector3.zero;
                rawRotation   = Quaternion.identity;
                SubMarkerMask = 0;
                return(false);
            }
        }
Esempio n. 30
0
 protected virtual void OnApplicationPause(bool pauseStatus)
 {
     if (m_IsPaused != pauseStatus)
     {
         m_IsPaused = pauseStatus;
         //
         if (m_IsPaused)
         {
             Log.i("Ximmerse.InputSystem.InputManager", "XDevicePlugin.OnPause()");
             XDevicePlugin.OnPause();
         }
         else
         {
             Log.i("Ximmerse.InputSystem.InputManager", "XDevicePlugin.OnResume()");
             XDevicePlugin.OnResume();
         }
     }
 }