Пример #1
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
    }
Пример #2
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
    }
Пример #3
0
        public void Initialize()
        {
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
            Application.targetFrameRate = 60;

            //StartRunning();

            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

            IsInitialized = true;
        }
Пример #4
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
    }
Пример #5
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);
    }
Пример #6
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
        }
Пример #7
0
    private void UpdateCameraFrame(MessageEventArgs mea)
    {
        serializableUnityARCamera serCamera = mea.data.Deserialize <serializableUnityARCamera> ();

        UnityARCamera scamera = new UnityARCamera();

        scamera = serCamera;

        InitializeTextures(scamera);

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
        UnityARSessionNativeInterface.RunFrameUpdateCallbacks();
        SaveData(_timeCount, CallMethodTypeId.UpdateCameraFrame, mea, false);
    }
Пример #8
0
    private void Awake()
    {
        _providerStatus = ProviderStatus.Initializing;

        //Configure ArKit
        UnityARSessionNativeInterface arKitSession = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
        // config
        //Application.targetFrameRate = 60;

        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration
        {
            planeDetection        = UnityARPlaneDetection.Horizontal,
            alignment             = UnityARAlignment.UnityARAlignmentGravity,
            getPointCloudData     = true,
            enableLightEstimation = true,
            enableAutoFocus       = false
        };

        if (!config.IsSupported)
        {
            Debug.LogError("Tracking is not supported on this device");
            ToastManager.Instance.ShowToast(" Session Error : ArKit is not supported on this device.");
            _providerStatus = ProviderStatus.NotSupported;
        }
        else
        {
            _providerStatus = ProviderStatus.Ready;
            arKitSession.RunWithConfigAndOptions(config, UnityARSessionRunOption.ARSessionRunOptionResetTracking);
        }
#else
        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);
        _providerStatus = ProviderStatus.Ready;
        #endif
    }
    private void Awake()
    {
        //Configure ArKit
        _arKitSession = UnityARSessionNativeInterface.GetARSessionNativeInterface();


        #if !UNITY_EDITOR
        // config
        Application.targetFrameRate = 60;

        _config = new ARKitWorldTrackingSessionConfiguration();

        _config.planeDetection        = UnityARPlaneDetection.Horizontal;
        _config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        _config.getPointCloudData     = true;
        _config.enableLightEstimation = true;
        _config.enableAutoFocus       = true;
        UnityARSessionRunOption tracking = UnityARSessionRunOption.ARSessionRunOptionResetTracking;
        _arKitSession.RunWithConfigAndOptions(_config, tracking);

        if (!_config.IsSupported)
        {
            Debug.LogError("Tracking is not supported on this device");
            //Delete the VideoCamera. Default providers will create its own video camera
            Destroy(GetComponent <Camera>());
        }
        else
        {
            ProviderHelper.ArKitSupported = true;
        }
        #else
        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
    }
Пример #10
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
    }