예제 #1
0
        public bool Create()
        {
            var result = NativeApi.NRRGBCameraCreate(ref m_NativeCameraHandle);

            NRDebug.Log("[NativeCamera] Create: " + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #2
0
        public bool Destroy()
        {
            NativeResult result = NativeApi.NRTrackingDestroy(m_TrackingHandle);

            NRDebug.Log("[NativeSession Destroy :]" + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #3
0
        public bool Release()
        {
            var result = NativeApi.NRRGBCameraDestroy(m_NativeCameraHandle);

            NRDebug.Log("[NativeCamera] Release: " + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #4
0
        public bool Resume()
        {
            NativeResult result = NativeApi.NRTrackingResume(m_TrackingHandle);

            NRDebug.Log("[NativeSession Resume :]" + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #5
0
        public bool SetImageFormat(CameraImageFormat format)
        {
            var result = NativeApi.NRRGBCameraSetImageFormat(m_NativeCameraHandle, format);

            NRDebug.Log("[NativeCamera] SetImageFormat: " + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #6
0
        public bool Create()
        {
            NativeResult result = NativeApi.NRHMDCreate(ref m_HmdHandle);

            NRDebug.Log("[NativeHMD Create]:" + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #7
0
        public bool SetTrackingMode(TrackingMode mode)
        {
            NativeResult result = NativeApi.NRTrackingInitSetTrackingMode(m_TrackingHandle, mode);

            NRDebug.Log("[NativeSession SetTrackingMode :]" + mode.ToString() + " result:" + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #8
0
        public bool Init()
        {
            NRDebug.Log("NativeController start init:");
            NativeResult result = NativeApi.NRControllerCreate(ref m_ControllerHandle);

            if (result == NativeResult.Success)
            {
                //manually start controller
                NativeApi.NRControllerStart(m_ControllerHandle);

                int count = GetControllerCount();
                NRDebug.Log("__controller count:" + count);
                for (int i = 0; i < count; i++)
                {
                    result = NativeApi.NRControllerStateCreate(m_ControllerHandle, i, ref m_StateHandles[i]);
                    if (result != NativeResult.Success)
                    {
                        Debug.LogError("Controller State Create Failed!" + result.ToString());
                        return(false);
                    }
                }
                NRDebug.Log("Native Controller Created Sucessed");
                return(true);
            }
            NRDebug.Log("Native Controller Create Failed!");
            return(false);
        }
예제 #9
0
        public bool Create()
        {
            var result = NativeApi.NRHeadTrackingCreate(m_NativeInterface.TrackingHandle, ref headTrackingHandle);

            NRDebug.Log("[NativeHeadTracking Create :]" + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #10
0
        public bool SetCaptureCallback(NRRGBCameraImageCallback callback)
        {
            var result = NativeApi.NRRGBCameraSetCaptureCallback(m_NativeCameraHandle, callback);

            NRDebug.Log("[NativeCamera] SetCaptureCallback: " + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #11
0
        public bool StopCapture()
        {
            var result = NativeApi.NRRGBCameraStopCapture(m_NativeCameraHandle);

            NRDebug.Log("[NativeCamera] StopCapture: " + result.ToString());
            return(result == NativeResult.Success);
        }
예제 #12
0
        public NativeResolution GetResolution(UInt64 imageHandle)
        {
            NativeResolution resolution = new NativeResolution(1280, 720);
            var result = NativeApi.NRRGBCameraImageGetResolution(m_NativeCameraHandle, imageHandle, ref resolution);

            NRDebug.Log("[NativeCamera] GetResolution: " + result.ToString());
            return(resolution);
        }
예제 #13
0
        public bool Create()
        {
            NativeResult result = NativeApi.NRTrackingCreate(ref m_TrackingHandle);

            NRDebug.Log("[NativeSession Create :]" + result.ToString());
            m_NativeInterface.TrackingHandle = m_TrackingHandle;
            return(result == NativeResult.Success);
        }
예제 #14
0
        void Awake()
        {
#if !UNITY_EDITOR
            NRDebug.EnableLog = Debug.isDebugBuild;
#endif
            NRDebug.Log("[SessionBehaviour Awake: CreateSession]");
            NRSessionManager.Instance.CreateSession(this);
        }
예제 #15
0
        public NativeResolution GetEyeResolution(NativeEye eye = NativeEye.LEFT)
        {
            NativeResolution resolution = new NativeResolution(3840, 1080);

            NativeApi.NRHMDGetEyeResolution(m_HmdHandle, (int)NativeEye.LEFT, ref resolution);
            NRDebug.Log("[NativeHMD GetEyeResolution]:" + resolution.ToString());
            return(resolution);
        }
예제 #16
0
        private void FirstFramReady()
        {
            Texture = new Texture2D(Resolution.width, Resolution.height, GetFormatByCamraImageFormat(ImageFormat), false);
            NRDebug.Log("[NRCameraCapture] FirstFramReady : " + Resolution.ToString());

            if (OnFirstFrameReady != null)
            {
                OnFirstFrameReady();
            }
        }
예제 #17
0
        /**
         * @brief Release the rgb camera.
         */
        public static void Release()
        {
            if (m_NativeCamera != null)
            {
                NRDebug.Log("[NRRgbCamera] Start to Release");
#if !UNITY_EDITOR
                m_NativeCamera.Release();
#endif
                CurrentState = CaptureState.UnInitialized;
            }
        }
예제 #18
0
        void CreateRenderTextures()
        {
            var resolution = NRDevice.Instance.NativeHMD.GetEyeResolution();

            NRDebug.Log("[CreateRenderTextures]  resolution :" + resolution.ToString());

            for (int i = 0; i < EyeTextureCount; i++)
            {
                eyeTextures[i] = GenRenderTexture(resolution.width, resolution.height);
                m_RTDict.Add(eyeTextures[i], eyeTextures[i].GetNativeTexturePtr());
            }
        }
예제 #19
0
        public static void SetImageFormat(CameraImageFormat format)
        {
            if (CurrentState == CaptureState.UnInitialized)
            {
                Initialize();
            }
#if !UNITY_EDITOR
            m_NativeCamera.SetImageFormat(format);
#endif
            ImageFormat = format;
            NRDebug.Log("[NRRgbCamera] SetImageFormat : " + format.ToString());
        }
예제 #20
0
        /**
         * @brief Stop the rgb camera.
         */
        public static void Stop()
        {
            if (CurrentState != CaptureState.Running)
            {
                StateError(string.Format("Can not stop in state:{0}", CurrentState));
                return;
            }
            NRDebug.Log("[NRRgbCamera] Start to Stop");
#if !UNITY_EDITOR
            m_NativeCamera.StopCapture();
#endif
            CurrentState = CaptureState.Stopped;
        }
 private void InitNativeController()
 {
     m_NativeController = new NativeController();
     if (m_NativeController.Init())
     {
         Inited = true;
         NRDebug.Log("NRControllerProvider Init Succeed");
     }
     else
     {
         m_NativeController = null;
         Debug.LogError("NRControllerProvider Init Failed !!");
     }
     m_NeedInit = false;
 }
예제 #22
0
        /// @endcond

        public static void Initialize()
        {
            if (CurrentState != CaptureState.UnInitialized)
            {
                return;
            }

            NRDebug.Log("[NRRgbCamera] Initialize");
            m_NativeCamera = new NativeCamera();
#if !UNITY_EDITOR
            m_NativeCamera.Create();
            m_NativeCamera.SetCaptureCallback(Capture);
#endif
            CurrentState = CaptureState.Initialized;
        }
예제 #23
0
        /**
         * @brief Start to play rgb camera.
         */
        public static void Play()
        {
            if (CurrentState == CaptureState.UnInitialized)
            {
                Initialize();
            }
            if (CurrentState == CaptureState.UnInitialized || CurrentState == CaptureState.Running)
            {
                StateError(string.Format("Can not start in state:{0}", CurrentState));
                return;
            }
            NRDebug.Log("[NRRgbCamera] Start to play");
#if !UNITY_EDITOR
            m_NativeCamera.StartCapture();
#endif
            CurrentState = CaptureState.Running;
        }
예제 #24
0
        private void Update()
        {
            if (Trackable == null)
            {
                NRDebug.LogError("NRAnchor components instantiated outside of NRInternel are not supported. " +
                                 "Please use a 'Create' method within NRInternel to instantiate anchors.");
                return;
            }

            if (IsSessionDestroyed())
            {
                return;
            }

            var pose = Trackable.GetCenterPose();

            transform.position = pose.position;
            transform.rotation = pose.rotation;
        }
예제 #25
0
        public void CreateSession(NRSessionBehaviour session)
        {
            if (SessionBehaviour != null)
            {
                NRDebug.LogError("Multiple SessionBehaviour components cannot exist in the scene. " +
                                 "Destroying the newest.");
                GameObject.Destroy(session);
                return;
            }
            NativeAPI        = new NativeInterface();
            SessionStatus    = NativeAPI.NativeTracking.Create() ? SessionState.Created : SessionState.UnInitialize;
            SessionBehaviour = session;

            NRHMDPoseTracker = session.GetComponent <NRHMDPoseTracker>();
            TrackingMode mode = NRHMDPoseTracker.TrackingMode == TrackingType.Tracking3Dof ? TrackingMode.MODE_3DOF : TrackingMode.MODE_6DOF;

            SetTrackingMode(mode);

            this.DeployData();
        }
예제 #26
0
        private void DeployData()
        {
            if (SessionBehaviour.SessionConfig == null)
            {
                return;
            }
            var database = SessionBehaviour.SessionConfig.TrackingImageDatabase;

            if (database == null)
            {
                NRDebug.Log("augmented image data base is null!");
                return;
            }
            string deploy_path = database.TrackingImageDataOutPutPath;

            NRDebug.Log("[TrackingImageDatabase] DeployData to path :" + deploy_path);
            if (Directory.Exists(database.TrackingImageDataPath))
            {
                NRDebug.Log("augmented image data is exit!");
                return;
            }
            ZipUtility.UnzipFile(database.RawData, deploy_path, NativeConstants.ZipKey);
        }
예제 #27
0
        void LateUpdate()
        {
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                UpdateControllerRotateByInput();
            }

            if (Input.GetMouseButtonDown(0))
            {
                SetConfirmButton(true);
                ImageConfirm.SetActive(true);
            }
            if (Input.GetMouseButtonUp(0))
            {
                SetConfirmButton(false);
                ImageConfirm.SetActive(false);
            }
            if (Input.GetMouseButtonDown(2))
            {
                SetAppButton(true);
                ImageApp.SetActive(true);
            }
            if (Input.GetMouseButtonUp(2))
            {
                SetAppButton(false);
                ImageApp.SetActive(false);
            }
            if (Input.GetMouseButtonDown(1))
            {
                SetHomeButton(true);
                ImageHome.SetActive(true);
            }
            if (Input.GetMouseButtonUp(1))
            {
                SetHomeButton(false);
                ImageHome.SetActive(false);
            }
            if (m_TouchAction != TouchActionState.Idle)
            {
                UpdateTouchAction();
            }
            else
            {
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    ImageLeft.SetActive(true);
                    m_TouchAction = TouchActionState.Left;
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    ImageRight.SetActive(true);
                    m_TouchAction = TouchActionState.Right;
                }
                else if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    ImageUp.SetActive(true);
                    m_TouchAction = TouchActionState.Up;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    ImageDown.SetActive(true);
                    m_TouchAction = TouchActionState.Down;
                }
                else if (Input.GetKeyUp(KeyCode.DownArrow)
                         | Input.GetKeyUp(KeyCode.UpArrow)
                         | Input.GetKeyUp(KeyCode.RightArrow)
                         | Input.GetKeyUp(KeyCode.LeftArrow))
                {
                    NREmulatorManager.Instance.NativeEmulatorApi.SetControllerIsTouching(false);
                }
            }

            NREmulatorManager.Instance.NativeEmulatorApi.SetControllerSubmit();


            if (NRInput.GetButtonDown(ControllerButton.TRIGGER))
            {
                NRDebug.Log("Click down Trigger button !!!");
            }
            else if (NRInput.GetButtonDown(ControllerButton.APP))
            {
                NRDebug.Log("Click down App button !!!");
            }
            else if (NRInput.GetButtonDown(ControllerButton.HOME))
            {
                NRDebug.Log("Click down Home button !!!");
            }
        }
예제 #28
0
        public void UpdateConfig(NRSessionConfig config)
        {
            if (m_ConfigHandle == 0)
            {
                m_ConfigHandle = this.Create();
            }

            if (m_ConfigHandle == 0)
            {
                NRDebug.LogError("Faild to Create ARSessionConfig!!!");
                return;
            }

            var plane_find_mode = this.GetPlaneFindMode(m_ConfigHandle);

            if (plane_find_mode != config.PlaneFindingMode)
            {
                SetPlaneFindMode(m_ConfigHandle, config.PlaneFindingMode);
            }

            if (config.ImageTrackingMode != m_ImageTrackingMode)
            {
                //Trackable Image
                switch (config.ImageTrackingMode)
                {
                case TrackableImageFindingMode.DISABLE:
                    if (m_DatabaseHandle != 0)
                    {
                        m_NativeTrackableImage.DestroyDataBase(m_DatabaseHandle);
                        m_DatabaseHandle = 0;
                    }
                    else
                    {
                        var result = SetTrackableImageDataBase(m_ConfigHandle, 0);
                        NRDebug.Log("[Disable trackable image] result : " + result);
                    }
                    break;

                case TrackableImageFindingMode.ENABLE:
                    if (m_DatabaseHandle == 0)
                    {
                        if (config.TrackingImageDatabase != null)
                        {
                            m_DatabaseHandle = m_NativeTrackableImage.CreateDataBase();
                            bool result = m_NativeTrackableImage.LoadDataBase(m_DatabaseHandle, config.TrackingImageDatabase.TrackingImageDataPath);
                            NRDebug.Log("[LoadDataBase] result : " + result);
                            result = SetTrackableImageDataBase(m_ConfigHandle, m_DatabaseHandle);
                            NRDebug.Log("[SetTrackableImageDataBase] result : " + result);
                        }
                        else
                        {
                            var result = SetTrackableImageDataBase(m_ConfigHandle, 0);
                            NRDebug.Log("[Disable trackable image] result : " + result);
                        }
                    }
                    break;

                default:
                    break;
                }

                m_ImageTrackingMode = config.ImageTrackingMode;
            }
        }
예제 #29
0
 void OnDestroy()
 {
     NRDebug.Log("[SessionBehaviour OnDestroy DestroySession]");
     NRSessionManager.Instance.DestroySession();
 }
예제 #30
0
        /// <summary>
        /// only worked at 3dof mode
        /// </summary>
        public void Recenter()
        {
            var result = NativeApi.NRTrackingRecenter(m_TrackingHandle);

            NRDebug.Log("[NativeSession Recenter] :" + result.ToString());
        }