Ejemplo n.º 1
0
    public void HandleTargetFinderResult(Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult)
    {
        Debug.Log("<color=blue>HandleTargetFinderResult(): " + targetSearchResult.TargetName + "</color>");
        CloudUploading.currentImageData = targetSearchResult;

        if (targetSearchResult.MetaData.Length > 0)
        {
            ProfileDataList profileDataList = JsonUtility.FromJson <ProfileDataList>(targetSearchResult.MetaData);

            cloudTargetInfo.text =
                "Name: " + profileDataList.profileDatasArray[0].value +
                "\nAge: " + profileDataList.profileDatasArray[1].value +
                "\nPhone: " + profileDataList.profileDatasArray[2].value +
                "\nAddress: " + profileDataList.profileDatasArray[3].value +
                "\nIC: " + profileDataList.profileDatasArray[4].value +
                "\nOccupation: " + profileDataList.profileDatasArray[5].value +
                "\nBiography: " + profileDataList.profileDatasArray[6].value;
        }
        else
        {
            Debug.Log("Target lacks MetaData!");

            cloudTargetInfo.text =
                "Name: " + targetSearchResult.TargetName +
                "\nRating: " + starRatings[targetSearchResult.TrackingRating] +
                "\nMetaData: " + ((targetSearchResult.MetaData.Length > 0) ? targetSearchResult.MetaData : "No") +
                "\nTarget Id: " + targetSearchResult.UniqueTargetId;
        }
    }
Ejemplo n.º 2
0
 public void HandleTargetFinderResult(Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult)
 {
     if (ScreenImageContent.activeInHierarchy || ScreenModelContent.activeInHierarchy || ScreenVideoContent.activeInHierarchy)
     {
         return;
     }
     Debug.Log("<color=yellow>HandleTargetFinderResult(): " + targetSearchResult.TargetName + "</color>");
     Handheld.Vibrate();
     StartCoroutine(CheckUrl(targetSearchResult.MetaData));
 }
    public void HandleTargetFinderResult(Vuforia.TargetFinder.TargetSearchResult stargetSearchResult)
    {
        Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult = (Vuforia.TargetFinder.CloudRecoSearchResult)stargetSearchResult;

        Debug.Log("<color=blue>HandleTargetFinderResult(): " + targetSearchResult.TargetName + "</color>");

        cloudTargetInfo.text =
            "Name: " + targetSearchResult.TargetName +
            "\nSize: " + targetSearchResult.TargetSize +
            "\nRating: " + starRatings[targetSearchResult.TrackingRating] +
            "\nMetaData: " + ((targetSearchResult.MetaData.Length > 0) ? targetSearchResult.MetaData : "No") +
            "\nTarget Id: " + targetSearchResult.UniqueTargetId;

        GameObject augmentation = GetValuefromDictionary(Augmentations, targetSearchResult.TargetName);

        if (augmentation != null)
        {
            if (augmentation.transform.parent != CloudTarget.transform)
            {
                Renderer[] augmentationRenderers;

                if (currentAugmentation != null && currentAugmentation.parent == CloudTarget)
                {
                    currentAugmentation.SetParent(contentManagerParent);
                    currentAugmentation.transform.localPosition = Vector3.zero;
                    currentAugmentation.transform.localScale    = Vector3.one;

                    augmentationRenderers = currentAugmentation.GetComponentsInChildren <Renderer>();
                    foreach (var objrenderer in augmentationRenderers)
                    {
                        objrenderer.gameObject.layer = LayerMask.NameToLayer("UI");
                        objrenderer.enabled          = true;
                    }
                }

                // store reference to content manager's parent object of the augmentation
                contentManagerParent = augmentation.transform.parent;
                // store reference to the current augmentation
                currentAugmentation = augmentation.transform;

                // set new target augmentation parent to cloud target
                augmentation.transform.SetParent(CloudTarget);
                augmentation.transform.localPosition = Vector3.zero;
                augmentation.transform.localScale    = Vector3.one;

                augmentationRenderers = augmentation.GetComponentsInChildren <Renderer>();
                foreach (var objrenderer in augmentationRenderers)
                {
                    objrenderer.gameObject.layer = LayerMask.NameToLayer("Default");
                    objrenderer.enabled          = true;
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void HandleTargetFinderResult(Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult)
    {
        Globals.Global_target = targetSearchResult.TargetName;
        target = targetSearchResult.TargetName;
        Debug.Log("<color=blue>HandleTargetFinderResult(): " + target + "</color>");

        Debug.Log("TARGET1 = " + target);


        StartCoroutine(GetRequest("https://quiet-crag-61602.herokuapp.com/all-pokemons/" + target));
        Debug.Log("TARGET2 = " + target);
        cloudTargetInfo.text =
            "Target: " + target +
            "\nPokemon: " + Globals.Global_model;
        Debug.Log("TARGET GLOBAL = " + Globals.Global_target);
    }
    public void OnNewSearchResult(TargetFinder.TargetSearchResult stargetSearchResult)
    {
        Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult = (Vuforia.TargetFinder.CloudRecoSearchResult)stargetSearchResult;
        Debug.Log("<color=blue>OnNewSearchResult(): </color>" + targetSearchResult.TargetName);

        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)


        m_CloudRecoContentManager.HandleTargetFinderResult(targetSearchResult);


        //Check if the metadata isn't null
        if (targetSearchResult.MetaData == null)
        {
            Debug.Log("Target metadata not available.");
            //return;
        }
        else
        {
            Debug.Log("MetaData: " + targetSearchResult.MetaData);
            Debug.Log("TargetName: " + targetSearchResult.TargetName);
            Debug.Log("Pointer: " + targetSearchResult.TargetSearchResultPtr);
            Debug.Log("TargetSize: " + targetSearchResult.TargetSize);
            Debug.Log("TrackingRating: " + targetSearchResult.TrackingRating);
            Debug.Log("UniqueTargetId: " + targetSearchResult.UniqueTargetId);
        }

        // First clear all trackables
        m_ObjectTracker.GetTargetFinder <TargetFinder>().ClearTrackables(false);

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour =
            m_ObjectTracker.GetTargetFinder <TargetFinder>().EnableTracking(targetSearchResult, m_ImageTargetTemplate.gameObject) as ImageTargetBehaviour;

        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if (m_TrackableSettings && m_TrackableSettings.IsExtendedTrackingEnabled())
        {
            //imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }
    }
Ejemplo n.º 6
0
    public void HandleTargetFinderResult(Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult)
    {
        Debug.Log("<color=blue>HandleTargetFinderResult(): " + targetSearchResult.TargetName + "</color>");

        metadata = targetSearchResult.MetaData;
        metadata = metadata.Trim();

        Debug.Log("<color=red> meta data set to " + metadata + ".</color>");

        if (metadata != null)
        {
            string[] splitStrings = metadata.Split(' ');

            type = Convert.ToInt32(splitStrings[0]);

            if (type == 3)
            {
                if (!optionPanel.activeSelf)
                {
                    optionPanel.SetActive(true);
                }
                noOfQues   = Convert.ToInt32(splitStrings[1]);
                quizDomain = splitStrings[2];
                Debug.Log("<color=red> FROM METADATA : type{" + type + "}, noOfQues{" + noOfQues + "}, quizDomain{ " + quizDomain + "}.</color>");

                //Setting parameter to the QuizHolder

                QuestionsHolder.totalNoOfQuestions = noOfQues;
                QuestionsHolder.domain             = quizDomain.Trim();
                QuestionsHolder.StartCoroutine(QuestionsHolder.LoadQuestionFromDatabase());
            }
            else
            {
                resultUrl = splitStrings[1];
                Debug.Log("<color=red> FROM METADATA : type{" + type + "}, link{" + resultUrl + "}.</color>");
                //Setting parameter to the QuizHolder
                if (type == 1)
                {
                    ImageHolder.imageUrl = resultUrl.Trim();

                    Debug.Log("<color=red> Calling SpriteRenderer from could manager script  </color>");
                    ImageHolder.StartCoroutine(ImageHolder.loadSpriteImageFromUrl(ImageHolder.imageUrl));
                }
                else
                {
                    videoHolder.url = resultUrl.Trim();
                }
            }
        }

        cloudTargetInfo.text =
            "Name: " + targetSearchResult.TargetName +
            "\nRating: " + starRatings[targetSearchResult.TrackingRating] +
            "\nMetaData: " + ((targetSearchResult.MetaData.Length > 0) ? targetSearchResult.MetaData : "No") +
            "\nTarget Id: " + targetSearchResult.UniqueTargetId;



        GameObject augmentation = GetValuefromDictionary(Augmentations, type);

        if (augmentation != null)
        {
            if (augmentation.transform.parent != CloudTarget.transform)
            {
                Renderer[] augmentationRenderers;

                if (currentAugmentation != null && currentAugmentation.parent == CloudTarget)
                {
                    currentAugmentation.SetParent(contentManagerParent);
                    currentAugmentation.transform.localPosition = Vector3.zero;
                    currentAugmentation.transform.localScale    = Vector3.one;

                    augmentationRenderers = currentAugmentation.GetComponentsInChildren <Renderer>();
                    foreach (var objrenderer in augmentationRenderers)
                    {
                        objrenderer.gameObject.layer = LayerMask.NameToLayer("UI");
                        objrenderer.enabled          = true;
                    }
                }

                // store reference to content manager's parent object of the augmentation
                contentManagerParent = augmentation.transform.parent;
                // store reference to the current augmentation
                currentAugmentation = augmentation.transform;

                // set new target augmentation parent to cloud target
                augmentation.transform.SetParent(CloudTarget);
                augmentation.transform.localPosition = Vector3.zero;
                augmentation.transform.localScale    = Vector3.one;

                augmentationRenderers = augmentation.GetComponentsInChildren <Renderer>();
                foreach (var objrenderer in augmentationRenderers)
                {
                    objrenderer.gameObject.layer = LayerMask.NameToLayer("Default");
                    objrenderer.enabled          = true;
                }
            }
        }
    }