Exemplo n.º 1
0
        public void LoadSharedData(ARSharedData sharedData)
        {
            NDKARStatus status = NDKAPI.HwArSession_load(m_ndkSession.SessionHandle, sharedData.RawData.m_pinAddr,
                                                         sharedData.RawData.DataSize);

            ARExceptionAdapter.ExtractException(status);
        }
Exemplo n.º 2
0
        public void Stop()
        {
            NDKARStatus status = NDKAPI.HwArSession_stop(m_ndkSession.SessionHandle);

            ARDebug.LogInfo("native stop end with value:{0}", status);
            ARExceptionAdapter.ExtractException(status);
        }
Exemplo n.º 3
0
        public IntPtr AcquireDepthImage()
        {
            IntPtr      imageHandle = IntPtr.Zero;
            NDKARStatus status      = NDKAPI.HwArFrame_acquireDepthImage(m_ndkSession.SessionHandle, m_ndkSession.FrameHandle, ref imageHandle);

            ARExceptionAdapter.ExtractException(status);
            return(imageHandle);
        }
Exemplo n.º 4
0
        public long GetSerializeAnchorsLimit()
        {
            long        ret    = 0;
            NDKARStatus status = NDKAPI.HwArSession_getSerializeAnchorsLimit(m_ndkSession.SessionHandle, ref ret);

            ARExceptionAdapter.ExtractException(status);
            return(ret);
        }
        public IntPtr AcquireSceneMesh()
        {
            IntPtr      sceneMeshHandle = IntPtr.Zero;
            NDKARStatus status          = NDKAPI.HwArFrame_acquireSceneMesh(m_ndkSession.SessionHandle, m_ndkSession.FrameHandle, ref sceneMeshHandle);

            ARExceptionAdapter.ExtractException(status);
            return(sceneMeshHandle);
        }
Exemplo n.º 6
0
        public IntPtr AcquirePointCloudHandle()
        {
            IntPtr      pointcouldHandle = IntPtr.Zero;
            NDKARStatus status           = NDKAPI.HwArFrame_acquirePointCloud(m_ndkSession.SessionHandle,
                                                                              m_ndkSession.FrameHandle, ref pointcouldHandle);

            ARExceptionAdapter.ExtractException(status);
            return(pointcouldHandle);
        }
Exemplo n.º 7
0
        public ARInstallStatus RequestInstall(bool userRequestedInstall)
        {
            int         installState = 0;
            NDKARStatus status       = NDKAPI.HwArApk_requestInstall(ARUnityHelper.Instance.GetJEnv(),
                                                                     ARUnityHelper.Instance.GetActivityHandle(), userRequestedInstall, ref installState);

            ARExceptionAdapter.ExtractException(status);
            return((ARInstallStatus)installState);
        }
        //todo changed
        public ARAnchor AcquireNewAnchor(IntPtr hitResultHandle)
        {
            IntPtr      anchorHandle = IntPtr.Zero;
            NDKARStatus status       = NDKAPI.HwArHitResult_acquireNewAnchor(m_ndkSession.SessionHandle, hitResultHandle,
                                                                             ref anchorHandle);

            ARExceptionAdapter.ExtractException(status);
            ARAnchor anchor = m_ndkSession.AnchorManager.ARAnchorFactory(anchorHandle, true);

            return(anchor);
        }
        public IntPtr CreateAugImgDatabaseFromBytes(byte[] databaseBytes)
        {
            IntPtr      databaseHandle = IntPtr.Zero;
            var         bytesHandle    = GCHandle.Alloc(databaseBytes, GCHandleType.Pinned);
            NDKARStatus status         = NDKAPI.HwArAugmentedImageDatabase_deserialize(m_ndkSession.SessionHandle,
                                                                                       bytesHandle.AddrOfPinnedObject(), databaseBytes.Length, ref databaseHandle);

            ARDebug.LogInfo("native AddImageWithPhysicalSize end with status={0}", status);
            ARExceptionAdapter.ExtractException(status);
            bytesHandle.Free();
            return(databaseHandle);
        }
Exemplo n.º 10
0
        public void Config(ARConfigBase unityConfig)
        {
            //ARDebug.LogInfo("native config begin" + unityConfig.ToString());
            IntPtr configHandle = m_ndkSession.ConfigBaseAdapter.Create();

            m_ndkSession.ConfigBaseAdapter.UpdateNDKConfigWithUnityConfig(configHandle, unityConfig);
            NDKARStatus status = NDKAPI.HwArSession_configure(m_ndkSession.SessionHandle, configHandle);

            ARDebug.LogInfo("native config end with value:{0}", status);
            m_ndkSession.ConfigBaseAdapter.UpdateUnityConfigWithNDKConfig(configHandle, unityConfig);
            m_ndkSession.ConfigBaseAdapter.Destroy(configHandle);
            ARExceptionAdapter.ExtractException(status);
        }
Exemplo n.º 11
0
        public ARSharedData SaveSharedData()
        {
            long dataSize = GetSaveLimit();
            long usedSize = 0;

            ARSharedData.ARRawData rawdata = new ARSharedData.ARRawData(dataSize);
            NDKARStatus            status  = NDKAPI.HwArSession_save(m_ndkSession.SessionHandle, rawdata.m_pinAddr, dataSize,
                                                                     ref usedSize);

            ARExceptionAdapter.ExtractException(status);

            rawdata.DataSize = usedSize > 0? usedSize : 0;
            return(new ARSharedData(rawdata));
        }
Exemplo n.º 12
0
        public IntPtr Create()
        {
            IntPtr sessionHandle = IntPtr.Zero;

            ARDebug.LogInfo("native create seesion begin");

            IntPtr      jEnv     = ARUnityHelper.Instance.GetJEnv();
            IntPtr      activity = ARUnityHelper.Instance.GetActivityHandle();
            NDKARStatus status   = NDKAPI.HwArSession_create(jEnv, activity, ref sessionHandle);

            ARDebug.LogInfo("native create seesion returns status {0}", status);
            ARExceptionAdapter.ExtractException(status);
            return(sessionHandle);
        }
Exemplo n.º 13
0
        public ARAnchor CreateAnchor(Pose pose)
        {
            IntPtr poseHandle   = m_ndkSession.PoseAdapter.Create(pose);
            IntPtr anchorHandle = IntPtr.Zero;

            ARDebug.LogInfo("native acquire anchor begin with pose:{0}", pose.ToString());
            NDKARStatus status = NDKAPI.HwArSession_acquireNewAnchor(m_ndkSession.SessionHandle,
                                                                     poseHandle, ref anchorHandle);

            ARDebug.LogInfo("native acquire anchor end with status={0}", status);
            m_ndkSession.PoseAdapter.Destroy(poseHandle);
            ARExceptionAdapter.ExtractException(status);
            var anchor = m_ndkSession.AnchorManager.ARAnchorFactory(anchorHandle, true);

            return(anchor);
        }
Exemplo n.º 14
0
        public void Update()
        {
            //release form handle
            if (m_ndkSession.FrameHandle != IntPtr.Zero)
            {
                m_ndkSession.FrameAdapter.Destroy(m_ndkSession.FrameHandle);
            }

            IntPtr frameHandle = m_ndkSession.FrameAdapter.Create();

            GL.InvalidateState();
            NDKARStatus status = NDKAPI.HwArSession_update(m_ndkSession.SessionHandle, frameHandle);

            GL.InvalidateState();
            ARExceptionAdapter.ExtractException(status);
            m_ndkSession.FrameHandle = frameHandle;
        }
Exemplo n.º 15
0
        public void DeSerializeAnchors(ARSharedData sharedData, List <ARAnchor> anchors)
        {
            IntPtr      anchorListHandle = m_ndkSession.AnchorAdapter.CreateList();
            NDKARStatus status           = NDKAPI.HwArSession_deserializeAnchors(m_ndkSession.SessionHandle,
                                                                                 sharedData.RawData.m_pinAddr, sharedData.RawData.DataSize, anchorListHandle);

            ARExceptionAdapter.ExtractException(status);
            int anchorListSize = m_ndkSession.AnchorAdapter.GetListSize(anchorListHandle);

            for (int i = 0; i < anchorListSize; i++)
            {
                IntPtr   anchorHandle = m_ndkSession.AnchorAdapter.AcquireListItem(anchorListHandle, i);
                ARAnchor anchor       = m_ndkSession.AnchorManager.ARAnchorFactory(anchorHandle, true);
                anchors.Add(anchor);
            }
            m_ndkSession.AnchorAdapter.DestroyList(anchorListHandle);
        }
Exemplo n.º 16
0
        public ARSharedData SerializeAnchors(List <ARAnchor> anchorList, bool isNeedAlign)
        {
            long   dataSize         = GetSerializeAnchorsLimit();
            long   usedSize         = 0;
            IntPtr anchorListHandle = m_ndkSession.AnchorAdapter.CreateList();

            foreach (ARAnchor anchor in anchorList)
            {
                m_ndkSession.AnchorAdapter.AddListItem(anchorListHandle, anchor.m_anchorHandle);
            }
            ARSharedData.ARRawData rawData = new ARSharedData.ARRawData(dataSize);
            NDKARStatus            status  = NDKAPI.HwArSession_serializeAnchors(m_ndkSession.SessionHandle,
                                                                                 anchorListHandle, isNeedAlign, rawData.m_pinAddr, dataSize, ref usedSize);

            ARExceptionAdapter.ExtractException(status);
            rawData.DataSize = usedSize;
            return(new ARSharedData(rawData));
        }
Exemplo n.º 17
0
        public void Update()
        {
            //release form handle
            if (m_ndkSession.FrameHandle != IntPtr.Zero)
            {
                m_ndkSession.FrameAdapter.Destroy(m_ndkSession.FrameHandle);
            }

            //IntPtr frameHandle = m_ndkSession.FrameAdapter.Create();
            //GL.InvalidateState();
            //NDKARStatus status = NDKAPI.HwArSession_update(m_ndkSession.SessionHandle, frameHandle);
            //GL.InvalidateState();
            IntPtr frameHandle = IntPtr.Zero;

            NDKAPI.SetCurrentSessionHandle(m_ndkSession.SessionHandle);
            GL.IssuePluginEvent(NDKAPI.GetRenderEventFunc(), 1);
            NDKAPI.WaitForRenderingThreadFinished();
            NDKARStatus status = NDKARStatus.HWAR_SUCCESS;

            NDKAPI.GetCurrentFrameHandleAndStatus(ref frameHandle, ref status);
            ARExceptionAdapter.ExtractException(status);
            m_ndkSession.FrameHandle = frameHandle;
        }
Exemplo n.º 18
0
        public void Resume()
        {
            NDKARStatus status = NDKAPI.HwArSession_resume(m_ndkSession.SessionHandle);

            ARExceptionAdapter.ExtractException(status);
        }