Exemplo n.º 1
0
    public void ToggleVideo()
    {
        UnityARVideo arVideo = m_camera.gameObject.GetComponent <UnityARVideo>();
        ARKitWorldTrackingSessionConfiguration _config = new ARKitWorldTrackingSessionConfiguration();

        if (arVideo.enabled && arVideo != null)
        {
            _config.enableAutoFocus       = false;
            _config.planeDetection        = UnityARPlaneDetection.None;
            _config.enableLightEstimation = false;
            _config.getPointCloudData     = false;
            m_session.Pause();
            arVideo.enabled = false;
        }
        else
        {
            _config.planeDetection        = planeDetection;
            _config.alignment             = startAlignment;
            _config.getPointCloudData     = getPointCloud;
            _config.enableLightEstimation = enableLightEstimation;
            _config.enableAutoFocus       = enableAutoFocus;
            m_camera.clearFlags           = CameraClearFlags.SolidColor;
            m_session.RunWithConfig(_config);
            arVideo.enabled = true;
        }
    }
Exemplo n.º 2
0
    private void RunARkit(ARKitFaceTrackingConfiguration configuration)
    {
        if (configuration.IsSupported && m_currentARkitStatus == false)
        {
            onSessionIsReady?.Invoke();

            m_session.RunWithConfig(configuration);
            m_currentARkitStatus = true;
        }
    }
Exemplo n.º 3
0
    private void StartARKit()
    {
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = UnityARPlaneDetection.Horizontal;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        mSession.RunWithConfig(config);
    }
Exemplo n.º 4
0
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
        Application.targetFrameRate = 60;
        ARKitWorldTackingSessionConfiguration config = new ARKitWorldTackingSessionConfiguration();
        config.planeDetection        = UnityARPlaneDetection.Horizontal;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#else
        //put some defaults so that it doesnt complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif

        initRotation = handler.initRotation;
        initPosition = handler.initPosition;
        Vuforia.TrackerManager.Instance.GetTracker <Vuforia.ObjectTracker>().Stop();
        //Vuforia.VuforiaBehaviour.Instance.enabled = false;
        m_camera.transform.localPosition = initPosition;
        sin = Mathf.Sin(Mathf.Deg2Rad * initRotation.eulerAngles.y);
        cos = Mathf.Cos(Mathf.Deg2Rad * initRotation.eulerAngles.y);
    }
Exemplo n.º 5
0
    void Start()
    {
        UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (!config.IsSupported)
        {
            return;
        }

        session.RunWithConfig(config);

        UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdd;
        UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdate;
        UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemove;

        RightEye = Instantiate(BasePosition);
        LeftEye  = Instantiate(BasePosition);

        LeftEye.SetActive(false);
        RightEye.SetActive(false);
    }
Exemplo n.º 6
0
        // Token: 0x0600BF9A RID: 49050 RVA: 0x00357244 File Offset: 0x00355444
        protected override void OnStop()
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_OnStop_hotfix != null)
            {
                this.m_OnStop_hotfix.call(new object[]
                {
                    this
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            base.OnStop();
            InviteNotifyUITask.EnableDispaly();
            NoticeUIController.IsForceHide = false;
            UnityARSessionNativeInterface          arsessionNativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTrackingSessionConfiguration config = default(ARKitWorldTrackingSessionConfiguration);

            config.planeDetection        = UnityARPlaneDetection.Horizontal;
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = false;
            config.enableLightEstimation = false;
            if (config.IsSupported)
            {
                arsessionNativeInterface.RunWithConfig(config);
            }
            arsessionNativeInterface.Pause();
        }
Exemplo n.º 7
0
        void Start()
        {
            // ComputeShader側に渡す各種パラメータ
            _vertexCountID    = Shader.PropertyToID("VertexCount");
            _transformID      = Shader.PropertyToID("Transform");
            _positionBufferID = Shader.PropertyToID("PositionBuffer");
            _positionMapID    = Shader.PropertyToID("PositionMap");

            // 以下はARKit周りの初期化
            _session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            Application.targetFrameRate = 60;
            var config = new ARKitFaceTrackingConfiguration();

            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.enableLightEstimation = true;

            if (config.IsSupported)
            {
                _session.RunWithConfig(config);
                UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
                UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
                UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
            }
        }
Exemplo n.º 8
0
        public void Start()
        {
            //Debug.Log("ARKitBridge: Start: Setting Input.compensateSensors from " + Input.compensateSensors + " to false.");
            Input.compensateSensors = false;

            UnityARSessionNativeInterface.ARFrameUpdatedEvent             += FrameUpdate;
            UnityARSessionNativeInterface.ARAnchorAddedEvent              += AddAnchor;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent            += UpdateAnchor;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent            += RemoveAnchor;
            UnityARSessionNativeInterface.ARUserAnchorAddedEvent          += AddUserAnchor;
            UnityARSessionNativeInterface.ARUserAnchorUpdatedEvent        += UpdateUserAnchor;
            UnityARSessionNativeInterface.ARUserAnchorRemovedEvent        += RemoveUserAnchor;
            UnityARSessionNativeInterface.ARSessionFailedEvent            += SessionFailed;
            UnityARSessionNativeInterface.ARSessionInterruptedEvent       += SessionInterrupted;
            UnityARSessionNativeInterface.ARSessioninterruptionEndedEvent += SessionInterruptionEnded;
            UnityARSessionNativeInterface.ARSessionTrackingChangedEvent   += SessionTrackingChanged;

            arSession = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
            Application.targetFrameRate = 60;
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.planeDetection        = UnityARPlaneDetection.Horizontal;
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = true;
            config.enableLightEstimation = true;
            arSession.RunWithConfig(config);
#endif
        }
Exemplo n.º 9
0
    private void Awake()
    {
        instance = this;                    // インスタンス取得
        Application.targetFrameRate = 60;   // fpsセット
        DontDestroyOnLoad(gameObject);      // 永続化

        // ARKitセッションの初期化 ----
        session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = UnityARPlaneDetection.Horizontal;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = false;
        session.RunWithConfig(config);  // セッション実行

        // Cameraがなければ取得
        if (trackingCamera == null)
        {
            trackingCamera = Camera.main;
        }
        // Cardboardの自動ヘッドトラッキング停止
        UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(trackingCamera, true);
        // シーン遷移時のイベント登録
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        config.enableAutoFocus       = enableAutoFocus;
        if (detectionImages != null)
        {
            config.arResourceGroupName = detectionImages.resourceGroupName;
        }

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
    }
Exemplo n.º 11
0
    //arkit manager

    //

    void OnEnable()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();


#if !UNITY_EDITOR
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#else
        //put some defaults so that it doesnt complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
    }
Exemplo n.º 12
0
    public void StartSession(ARWorldMap arWorldMap = null)
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration
        {
            planeDetection        = planeDetection,
            alignment             = startAlignment,
            getPointCloudData     = getPointCloud,
            enableLightEstimation = enableLightEstimation,
            enableAutoFocus       = enableAutoFocus,
            worldMap = arWorldMap
        };

        if (detectionImages != null)
        {
            config.referenceImagesGroupName = detectionImages.resourceGroupName;
        }

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }
    }
Exemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }

        leftEyeGo = GameObject.Instantiate(eyePrefab);
        // Debug.Log(peos.leftEye.name);
        // Debug.Log(peos.leftEye.transform.position);
        // Debug.Log(leftEyeGo.transform.position);


        peos.leftEye.transform.SetParent(leftEyeGo.transform);
        rightEyeGo = GameObject.Instantiate(eyePrefab);
        peos.RightEye.transform.SetParent(rightEyeGo.transform);

        leftEyeGo.SetActive(false);
        rightEyeGo.SetActive(false);
    }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }

        UnityARSessionRunOption options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        m_session.RunWithConfigAndOptions(config, options);
    }
Exemplo n.º 15
0
    private void ConfigureSession(bool clearPlanes)
    {
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        if (mPlaneDetectionToggle.GetComponent <Toggle>().isOn)
        {
            if (UnityARSessionNativeInterface.IsARKit_1_5_Supported())
            {
                config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical;
            }
            else
            {
                config.planeDetection = UnityARPlaneDetection.Horizontal;
            }
            mPNPlaneManager.StartPlaneDetection();
        }
        else
        {
            config.planeDetection = UnityARPlaneDetection.None;
            if (clearPlanes)
            {
                mPNPlaneManager.ClearPlanes();
            }
        }

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        mSession.RunWithConfig(config);
    }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if UNITY_EDITOR
        //UNITY EDITOR

        // Set tracking to Tracker or Headset Relay; Calibration/ARKit are not suitable
        // in the Unity Editor as it lacks 6DoF tracking
        tracking = TrackingType.TrackerRelay;

        //put some defaults so that it doesn't complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#else
        //iOS
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.startAlignment        = startAlignment;
        config.getPointCloudData     = false;
        config.enableLightEstimation = true;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#endif
    }
Exemplo n.º 17
0
    //***********  INIT  ***********//

    void Start()
    {
        // Set the target frame rate to be 60FPS
        Application.targetFrameRate = 60;

        // Initialize the bridge between Unity and the ARKit Native functions/structures
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        // Create the configuration struct for this ARKit session
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        // If the config file looks good, start the ARKIT session and add FaceAdded, FaceUpdated, and FaceRemoved as callback functions on ARKit events
        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }

        // Fire the init/start functions necessary for Peertalk
        PTCToCBridge.CallPTConnect();

        // Instantiate the blendshape GUI style
        blendshapeGUIstyle          = new GUIStyle();
        blendshapeGUIstyle.font     = yikes;
        blendshapeGUIstyle.fontSize = 30;
    }
Exemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
        Application.targetFrameRate = 60;
        ARKitWorldTackingSessionConfiguration config = new ARKitWorldTackingSessionConfiguration();
        config.planeDetection        = UnityARPlaneDetection.Horizontal;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#else
        //put some defaults so that it doesnt complain
        float         aspect  = (float)Screen.width / (float)Screen.height;
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, aspect, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
    }
Exemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        //config.alignment = UnityARAlignment.UnityARAlignmentGravity; // using gravity alignment enables orientation (3DOF) tracking of device camera. we don't need it
        config.alignment = UnityARAlignment.UnityARAlignmentCamera;

        config.enableLightEstimation = true;


        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
            //UnityARSessionNativeInterface.ARFrameUpdatedEvent += FrameUpdate; //can't get the light direction estimate to work for some reason, it freezes the app
        }
        else
        {
            Debug.Log("ARKitFaceTrackingConfiguration not supported");
        }
    }
Exemplo n.º 20
0
        void Start()
        {
            _session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            _session.RunWithConfig(new ARKitFaceTrackingConfiguration());

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
Exemplo n.º 21
0
 void PlaneDetectorSwitcher.turn_on_Detector(bool on_off)
 {
     if (!on_off)
     {
         ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
         config.planeDetection = UnityARPlaneDetection.None;
         config = setConfig(config);
         m_session.RunWithConfig(config);
     }
 }
Exemplo n.º 22
0
    public void StopTracking()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = UnityARPlaneDetection.None;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        m_session.RunWithConfig(config);
    }
Exemplo n.º 23
0
    public void StartObjectScanningSession()
    {
        sessionStarted = false;
        var config = objScanSessionConfiguration;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }
    }
Exemplo n.º 24
0
    private void ConfigureSession(bool clearPlanes)
    {
#if !UNITY_EDITOR
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
        config.planeDetection        = UnityARPlaneDetection.None;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        mSession.RunWithConfig(config);
#endif
    }
Exemplo n.º 25
0
    public void PlaneDetectionOFF()
    {
        planeDetection = UnityARPlaneDetection.None;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = false;
        config.enableLightEstimation = false;
        m_session.RunWithConfig(config);
    }
Exemplo n.º 26
0
        // Use this for initialization
        void Start()
        {
            // Initialize some variables
            m_arMode = false;

            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            UnityARSessionNativeInterface.ARImageAnchorAddedEvent   += AddImageAnchor;
            UnityARSessionNativeInterface.ARImageAnchorUpdatedEvent += UpdateImageAnchor;
            UnityARSessionNativeInterface.ARImageAnchorRemovedEvent += RemoveImageAnchor;
            scene = GameObject.Find("Scene");

#if !UNITY_EDITOR
            Application.targetFrameRate = 60;
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.planeDetection        = planeDetection;
            config.alignment             = startAlignment;
            config.getPointCloudData     = getPointCloud;
            config.enableLightEstimation = enableLightEstimation;
            config.enableAutoFocus       = enableAutoFocus;
            //config.maximumNumberOfTrackedImages = maximumNumberOfTrackedImages;
            //config.environmentTexturing = environmentTexturing;
            if (detectionImages != null)
            {
                //config.referenceImagesGroupName = detectionImages.resourceGroupName;
                config.arResourceGroupName = detectionImages.resourceGroupName;
            }

            //if (detectionObjects != null)
            //{
            //    config.referenceObjectsGroupName = "";  //lets not read from XCode asset catalog right now
            //    config.dynamicReferenceObjectsPtr = m_session.CreateNativeReferenceObjectsSet(detectionObjects.LoadReferenceObjectsInSet());
            //}

            if (config.IsSupported)
            {
                m_session.RunWithConfig(config);
                UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
            }

            if (m_camera == null)
            {
                m_camera = Camera.main;
            }
#else
            //put some defaults so that it doesnt complain
            UnityARCamera scamera = new UnityARCamera();
            scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
            Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
            scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

            UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
        }
Exemplo n.º 27
0
        // Use this for initialization
        void Start()
        {
#if !UNITY_EDITOR
            Application.targetFrameRate = 60;
            InitARConfig();
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            m_session.RunWithConfig(m_arconfig);
            UnityARSessionNativeInterface.ARSessionFailedEvent          += ARSessionFailed;
            UnityARSessionNativeInterface.ARSessionTrackingChangedEvent += ARSessionTrackingChanged;
            UnityARSessionNativeInterface.ARAnchorAddedEvent            += ARPlaneAnchorAdded;
#endif
        }
Exemplo n.º 28
0
        void StartRunning()
        {
#if !UNITY_EDITOR
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.planeDetection        = planeDetection;
            config.alignment             = startAlignment;
            config.getPointCloudData     = getPointCloud;
            config.enableLightEstimation = enableLightEstimation;
            m_session.RunWithConfig(config);
#endif

            IsRunning = true;
        }
Exemplo n.º 29
0
    protected void StartArSession()
    {
        if (_sessionStarted)
        {
            return;
        }
        var config = sessionConfiguration;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }
    }
Exemplo n.º 30
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
        //iOS

        tracking = TrackingType.TrackerCalibration;
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
        //config.planeDetection = planeDetection;
        //config.startAlignment = false;
        //config.getPointCloudData = false;
        //config.enableLightEstimation = false;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#else
        //UNITY EDITOR
        tracking = TrackingType.HeadsetRelay;
        //tracking = TrackingType.TrackerCalibration;

        ARKitSessionConfiguration sessionConfig = new ARKitSessionConfiguration(startAlignment, true, true);
        m_session.RunWithConfig(sessionConfig);

        //put some defaults so that it doesnt complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(fovAngle, 1.33f, 0.1f, farClipDist);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
    }