void UpdateClosestTarget()
    {
        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && VuforiaARController.Instance.HasStarted)
        {
            float closestDistance = Mathf.Infinity;

            foreach (VuMarkBehaviour vumarkBehaviour in this.vumarkManager.GetActiveBehaviours())
            {
                Vector3 worldPosition = vumarkBehaviour.transform.position;
                Vector3 camPosition   = this.vuforiaCamera.transform.InverseTransformPoint(worldPosition);

                float distance = Vector3.Distance(Vector2.zero, camPosition);
                if (distance < closestDistance)
                {
                    closestDistance    = distance;
                    this.closestVuMark = vumarkBehaviour.VuMarkTarget;
                }
            }

            if (this.closestVuMark != null &&
                this.currentVuMark != this.closestVuMark)
            {
                var vuMarkId       = GetVuMarkId(this.closestVuMark);
                var vuMarkDataType = GetVuMarkDataType(this.closestVuMark);
                var vuMarkImage    = GetVuMarkImage(this.closestVuMark);
                var vuMarkDesc     = GetNumericVuMarkDescription(this.closestVuMark);

                this.currentVuMark = this.closestVuMark;

                StartCoroutine(ShowPanelAfter(0f, vuMarkId, vuMarkDataType, vuMarkDesc, vuMarkImage));
            }
        }
    }
Example #2
0
        IEnumerator LoadUpdate()
        {
            while (!isLoaded)
            {
                yield return(new WaitForSeconds(.1f));

                if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && !isLoaded)
                {
                    if (tracker == null)
                    {
                        tracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
                    }
                    if (TotalDatas == null && tracker != null)
                    {
                        TotalDatas = tracker.CreateDataSet();
                    }

                    if (File.Exists(dataPath) && TotalDatas.Load(dataPath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE))
                    {
                        isLoaded = true;
                        tracker.ActivateDataSet(TotalDatas);
                        ReadDataSet();
                        Debug.Log("Load DataSet Succeed!");
                    }
                    else
                    {
                        Debug.Log("Load DataSet fail!");
                    }
                }
            }
        }
Example #3
0
 public void Awake()
 {
     if (VuforiaRuntimeUtilities.IsVuforiaEnabled())
     {
         // We remove the mesh components at run-time only, but keep them for
         // visualization when running in the editor:
         MeshRenderer targetMeshRenderer = this.GetComponent <MeshRenderer>();
         Destroy(targetMeshRenderer);
         MeshFilter targetMesh = this.GetComponent <MeshFilter>();
         Destroy(targetMesh);
     }
 }
Example #4
0
    void Update()
    {
        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && !mLoaded)
        {
            mLoaded = true;
            VuforiaARController.Instance.RegisterVuforiaStartedCallback(StartStart);
        }

        if (loadImage.activeSelf)
        {
            loadText.text = "Загрузка базы " + Mathf.RoundToInt(www1.progress * 100) + "%";
        }
    }
Example #5
0
    void Awake()
    {
        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && DestroyTrackableBehaviourMeshAndRenderer)
        {
            MeshRenderer meshRenderer = GetComponent <MeshRenderer>();
            MeshFilter   meshFilter   = GetComponent <MeshFilter>();

            if (meshRenderer)
            {
                Destroy(meshRenderer);
            }
            if (meshFilter)
            {
                Destroy(meshFilter);
            }
        }
    }
Example #6
0
    // Disable image target rendering
    private void TurnOffImage()
    {
        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() &&
            turnOffRendering != TurnOffRendering.Neither &&
            (turnOffRendering == TurnOffRendering.PlayModeAndDevice ||
             Application.isEditor))
        {
            MeshRenderer meshRenderer = GetComponent <MeshRenderer>();
            MeshFilter   meshFilter   = GetComponent <MeshFilter>();

            if (meshRenderer)
            {
                Destroy(meshRenderer);
            }
            if (meshFilter)
            {
                Destroy(meshFilter);
            }
        }
    }
Example #7
0
    void Update()
    {
        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && !mLoaded)
        {
            string externalPath = Application.persistentDataPath;

            if (mDataset == null)
            {
                // First, create the dataset
                ObjectTracker tracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
                mDataset = tracker.CreateDataSet();
            }

            if (mDataset.Load(externalPath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE))
            {
                mLoaded = true;
            }
            else
            {
                Debug.LogError("Failed to load dataset!");
            }
        }
    }
    void UpdateClosestTarget()
    {
        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && VuforiaARController.Instance.HasStarted)
        {
            Camera cam = DigitalEyewearARController.Instance.PrimaryCamera ?? Camera.main;

            float closestDistance = Mathf.Infinity;

            foreach (VuMarkBehaviour vumarkBehaviour in this.vumarkManager.GetActiveBehaviours())
            {
                Vector3 worldPosition = vumarkBehaviour.transform.position;
                Vector3 camPosition   = cam.transform.InverseTransformPoint(worldPosition);

                float distance = Vector3.Distance(Vector2.zero, camPosition);
                if (distance < closestDistance)
                {
                    closestDistance    = distance;
                    this.closestVuMark = vumarkBehaviour.VuMarkTarget;
                }
            }

            if (this.closestVuMark != null &&
                this.currentVuMark != this.closestVuMark)
            {
                ProductInfo productInfo = new ProductInfo();
                productInfo = RetrieveProductInfoForVuMarkTarget(this.closestVuMark);
                string name        = productInfo.name;
                string price       = string.Format("${0:0.00}", decimal.Parse(productInfo.price));
                string description = productInfo.description;
                Sprite image       = GetProductImage(this.closestVuMark);
                bool   isGold      = productInfo.golden;
                this.currentVuMark = this.closestVuMark;

                StartCoroutine(ShowPanelAfter(0.5f, name, price, description, image, isGold));
            }
        }
    }