void SetVuMarkOpticalSeeThroughConfig(VuMarkBehaviour vumarkBehaviour)
    {
        // Check to see if we're running on a HoloLens device.
        if (UnityEngine.XR.XRDevice.isPresent && !UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque)
        {
            MeshRenderer meshRenderer = vumarkBehaviour.GetComponent <MeshRenderer>();

            // If the VuMark has per instance background info, turn off virtual target so that it doesn't cover modified physical target
            if (vumarkBehaviour.VuMarkTemplate.TrackingFromRuntimeAppearance)
            {
                if (meshRenderer)
                {
                    meshRenderer.enabled = false;
                }
            }
            else
            {
                // If the VuMark background is part of VuMark Template and same per instance, render the virtual target
                if (meshRenderer)
                {
                    meshRenderer.material.mainTexture = RetrieveStoredTextureForVuMarkTarget(vumarkBehaviour.VuMarkTarget);
                }
            }
        }
        else
        {
            MeshRenderer meshRenderer = vumarkBehaviour.GetComponent <MeshRenderer>();

            if (meshRenderer)
            {
                meshRenderer.enabled = false;
            }
        }
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        //gets the  vumark manager
        vmm = TrackerManager.Instance.GetStateManager().GetVuMarkManager();

        //connectst to the server & collections
        client = new MongoClient(new MongoUrl(connectionString));
        server = client.GetServer();
        server.Connect();
        db   = server.GetDatabase("documents");
        coll = db.GetCollection <Statue>("Other");

        //queries the database
        List <Statue> query = coll.AsQueryable <Statue>().Where <Statue>(u => u.vumark == num).ToList();

        Debug.Log(query);
        foreach (var x in query)
        {
            Debug.Log(x.name);
        }

        //whenever a new vumark is registered, call SetVumark
        vb = GameObject.Find("VuMark").GetComponent <VuMarkBehaviour> ();
        vb.RegisterVuMarkTargetAssignedCallback(new System.Action(this.SetVumark));
    }
    void Start()
    {
        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);

        this.productImageTextures      = new Dictionary <string, Texture2D>();
        this.vumarkAugmentationObjects = new Dictionary <string, GameObject>();
        this.vumarkProductInfos        = new Dictionary <string, ProductInfo>();

        Button btn1 = addToCartBtn.GetComponent <Button>();

        btn1.GetComponent <UnityEngine.UI.Image>().sprite = addToCartSprite;
        btn1.onClick.AddListener(addToCart);

        foreach (AugmentationObject obj in this.augmentationObjects)
        {
            this.vumarkAugmentationObjects.Add(obj.vumarkID, obj.augmentation);
        }

        // Hide the initial VuMark Template when the scene starts.
        VuMarkBehaviour vumarkBehaviour = FindObjectOfType <VuMarkBehaviour>();

        if (vumarkBehaviour)
        {
            ToggleRenderers(vumarkBehaviour.gameObject, false);
        }

        this.nearestVuMarkScreenPanel = FindObjectOfType <PanelShowHide>();
    }
Example #4
0
    void SetVuMarkOpticalSeeThroughConfig(VuMarkBehaviour vumarkBehaviour)
    {
        if (VuforiaConfiguration.Instance.DigitalEyewear.SeeThroughConfiguration == DigitalEyewearARController.SeeThroughConfiguration.HoloLens)
        {
            MeshRenderer meshRenderer = vumarkBehaviour.GetComponent <MeshRenderer>();

            // If the VuMark has per instance background info, turn off virtual target so that it doesn't cover modified physical target
            if (vumarkBehaviour.VuMarkTemplate.TrackingFromRuntimeAppearance)
            {
                if (meshRenderer)
                {
                    meshRenderer.enabled = false;
                }
            }
            else
            {
                // If the VuMark background is part of VuMark Template and same per instance, render the virtual target
                if (meshRenderer)
                {
                    meshRenderer.material.mainTexture = RetrieveStoredTextureForVuMarkTarget(vumarkBehaviour.VuMarkTarget);
                }
            }
        }
        else
        {
            MeshRenderer meshRenderer = vumarkBehaviour.GetComponent <MeshRenderer>();

            if (meshRenderer)
            {
                meshRenderer.enabled = false;
            }
        }
    }
Example #5
0
    void SetVuMarkInfoForCanvas(VuMarkBehaviour vumarkBehaviour)
    {
        Text canvasText = vumarkBehaviour.gameObject.GetComponentInChildren <Text>();

        UnityEngine.UI.Image canvasImage = vumarkBehaviour.gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2];

        Texture2D vumarkInstanceTexture = RetrieveStoredTextureForVuMarkTarget(vumarkBehaviour.VuMarkTarget);
        Rect      rect = new Rect(0, 0, vumarkInstanceTexture.width, vumarkInstanceTexture.height);

        string vuMarkId       = GetVuMarkId(vumarkBehaviour.VuMarkTarget);
        string vuMarkDesc     = GetVuMarkDataType(vumarkBehaviour.VuMarkTarget);
        string vuMarkDataType = GetNumericVuMarkDescription(vumarkBehaviour.VuMarkTarget);

        canvasText.text =
            "<color=yellow>VuMark Instance Id: </color>" +
            "\n" + vuMarkId + " - " + vuMarkDesc +
            "\n\n<color=yellow>VuMark Type: </color>" +
            "\n" + vuMarkDataType;

        if (vumarkInstanceTexture.width == 0 || vumarkInstanceTexture.height == 0)
        {
            canvasImage.sprite = null;
        }
        else
        {
            canvasImage.sprite = Sprite.Create(vumarkInstanceTexture, rect, new Vector2(0.5f, 0.5f));
        }
    }
    IEnumerator SetVuMarkInfoForCanvas(VuMarkBehaviour vumarkBehaviour)
    {
        Text canvasText = vumarkBehaviour.gameObject.GetComponentInChildren <Text>();

        UnityEngine.UI.Image canvasImage = vumarkBehaviour.gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2];

        Texture2D vumarkInstanceTexture = RetrieveStoredTextureForVuMarkTarget(vumarkBehaviour.VuMarkTarget);
        Rect      rect = new Rect(0, 0, vumarkInstanceTexture.width, vumarkInstanceTexture.height);

        yield return(SetProductDescFromServer(vumarkBehaviour.VuMarkTarget));

        ProductInfo productInfo = RetrieveProductInfoForVuMarkTarget(vumarkBehaviour.VuMarkTarget);

        if (productInfo.golden)
        {
            canvasText.text =
                "<color=black>GOLDEN TICKET!!!</color>\n" +
                "<color=black>Item Name: </color>" + "<color=red>" + productInfo.name + "</color>" + "\n" +
                "<color=black>Price: </color>" + "<color=red>" + string.Format("{0:0.00}", productInfo.price) + "</color>" +
                "\n\n<color=black>Item Description: </color>" +
                "<color=red>" + productInfo.description + "</color>" + "\n";
        }
        else
        {
            canvasText.text =
                "<color=black>Item Name: </color>" + productInfo.name + "\n" +
                "<color=black>Price: </color>" + string.Format("{0:0.00}", productInfo.price) +
                "\n\n<color=black>Product Description: </color>" +
                productInfo.description + "\n" + "\n";
        }
        canvasImage.sprite = Sprite.Create(vumarkInstanceTexture, rect, new Vector2(2.0f, 0.5f));
    }
Example #7
0
    private GameObject control;                  //the control this vumark currently has

    #endregion                                   // PRIVATE_MEMBER_VARIABLES
    #region UNTIY_MONOBEHAVIOUR_METHODS

    void Start()
    {
        mTrackableBehaviour = GetComponent <VuMarkBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }
    }
Example #8
0
    private void OnVuMarkBehaviourFound(VuMarkBehaviour pVuMarkBehaviour)
    {
        //if we hadn't registered yet, we do so now
        registeredBehaviours.Add(pVuMarkBehaviour);

        pVuMarkBehaviour.RegisterVuMarkTargetAssignedCallback(
            () => OnVuMarkTargetAssigned(pVuMarkBehaviour)
            );
    }
 void UnregisterVuMarkTrackableCallbacks()
 {
     if (this.mTrackableBehaviour is VuMarkBehaviour)
     {
         this.vumarkBehaviour = (VuMarkBehaviour)this.mTrackableBehaviour;
         this.vumarkBehaviour.UnregisterVuMarkTargetAssignedCallback(OnVuMarkTargetAssigned);
         this.vumarkBehaviour.UnregisterVuMarkTargetLostCallback(OnVuMarkTargetLost);
     }
 }
Example #10
0
    private void OnVuMarkTargetAssigned(VuMarkBehaviour pVuMarkBehaviour)
    {
        string myID = GetID(pVuMarkBehaviour.VuMarkTarget.InstanceId);

        foreach (Transform child in pVuMarkBehaviour.transform)
        {
            child.gameObject.SetActive(myID.Contains(child.name.Substring(0, 1)));
        }
    }
    IEnumerator OnVuMarkTargetAvailable(VuMarkBehaviour vumarkBehaviour)
    {
        // We need to wait until VuMarkTarget is available
        yield return(new WaitUntil(() => vumarkBehaviour.VuMarkTarget != null));

        VLog.Log("cyan", "VuMarkHandler.OnVuMarkTargetAvailable() called: " + GetVuMarkId(vumarkBehaviour.VuMarkTarget));

        SetVuMarkInfoForCanvas(vumarkBehaviour);
        SetVuMarkAugmentation(vumarkBehaviour);
        SetVuMarkOpticalSeeThroughConfig(vumarkBehaviour);
    }
Example #12
0
    void MarkFond(VuMarkBehaviour markBehaviour)
    {
        if (registerMarkBehaviour.Contains(markBehaviour))
        {
            return;
        }

        registerMarkBehaviour.Add(markBehaviour);

        markBehaviour.RegisterVuMarkTargetAssignedCallback(() => TargetFond(markBehaviour));
    }
 public void OnVuMarkTargetAssigned()
 {
     if (this.mTrackableBehaviour is VuMarkBehaviour)
     {
         this.vumarkBehaviour = this.mTrackableBehaviour as VuMarkBehaviour;
         if (this.vumarkBehaviour.VuMarkTarget != null)
         {
             VLog.Log("cyan", "VuMark ID Tracked: " + this.vumarkBehaviour.VuMarkTarget.InstanceId.NumericValue);
         }
     }
 }
    IEnumerator OnVuMarkTargetAvailable(VuMarkBehaviour vumarkBehaviour)
    {
        // We need to wait until VuMarkTarget is available
        yield return(new WaitUntil(() => vumarkBehaviour.VuMarkTarget != null));

        Debug.Log("<color=green>TRCVuMarkHandler.OnVuMarkTargetAvailable() called: </color>" + GetVuMarkId(vumarkBehaviour.VuMarkTarget));

        //TODO: Make a new SetVuMarkInfoForCanvas as IEnumerator
        SetVuMarkInfoForCanvas(vumarkBehaviour);
        SetVuMarkAugmentation(vumarkBehaviour);
        SetVuMarkOpticalSeeThroughConfig(vumarkBehaviour);
    }
Example #15
0
    void SetVuMarkAugmentation(VuMarkBehaviour vumarkBehaviour)
    {
        GameObject sourceAugmentation = GetValueFromDictionary(this.vumarkAugmentationObjects, GetVuMarkId(vumarkBehaviour.VuMarkTarget));

        if (sourceAugmentation)
        {
            GameObject augmentation = Instantiate(sourceAugmentation);
            augmentation.transform.SetParent(vumarkBehaviour.transform);
            augmentation.transform.localPosition    = Vector3.zero;
            augmentation.transform.localEulerAngles = Vector3.zero;
        }
    }
Example #16
0
    /// <summary>
    ///  Register a callback which is invoked whenever a VuMark-result is newly detected which was not tracked in the frame before
    /// </summary>
    /// <param name="vumarkBehaviour"></param>
    public void OnVuMarkBehaviourDetected(VuMarkBehaviour vumarkBehaviour)
    {
        Debug.Log("<color=cyan>VuMarkHandler.OnVuMarkBehaviourDetected(): </color>" + vumarkBehaviour.TrackableName);

        GenerateVuMarkBorderOutline(vumarkBehaviour);

        ToggleRenderers(vumarkBehaviour.gameObject, true);

        // Check for existance of previous augmentations and delete before instantiating new ones.
        DestroyChildAugmentationsOfTransform(vumarkBehaviour.transform);

        StartCoroutine(OnVuMarkTargetAvailable(vumarkBehaviour));
    }
    public void OnVuMarkTargetAssigned()
    {
        Debug.Log("<color=cyan>VuMarkBehaviour.OnVuMarkTargetAssigned() called.</color>");

        if (this.mTrackableBehaviour is VuMarkBehaviour)
        {
            this.vumarkBehaviour = this.mTrackableBehaviour as VuMarkBehaviour;
            if (this.vumarkBehaviour.VuMarkTarget != null)
            {
                Debug.Log("<color=cyan>VuMark ID Tracked: </color>" + this.vumarkBehaviour.VuMarkTarget.InstanceId.NumericValue);
            }
        }
    }
    protected override void Start()
    {
        base.Start();

        this.canvasGroup = GetComponentInChildren <CanvasGroup>();
        this.fadeRange   = VuforiaRuntimeUtilities.IsPlayMode() ? new Vector2(0.5f, 0.6f) : new Vector2(0.9f, 1.0f);

        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);

        if (this.mTrackableBehaviour is VuMarkBehaviour)
        {
            this.vumarkBehaviour = (VuMarkBehaviour)this.mTrackableBehaviour;
            this.vumarkBehaviour.RegisterVuMarkTargetAssignedCallback(OnVuMarkTargetAssigned);
            this.vumarkBehaviour.RegisterVuMarkTargetLostCallback(OnVuMarkTargetLost);
        }
    }
Example #19
0
    void GenerateVuMarkBorderOutline(VuMarkBehaviour vumarkBehaviour)
    {
        this.lineRenderer = vumarkBehaviour.GetComponentInChildren <LineRenderer>();

        if (this.lineRenderer == null)
        {
            Debug.Log("<color=green>Existing Line Renderer not found. Creating new one.</color>");
            GameObject vumarkBorder = new GameObject("VuMarkBorder");
            vumarkBorder.transform.SetParent(vumarkBehaviour.transform);
            vumarkBorder.transform.localPosition    = Vector3.zero;
            vumarkBorder.transform.localEulerAngles = Vector3.zero;
            vumarkBorder.transform.localScale       =
                new Vector3(
                    1 / vumarkBehaviour.transform.localScale.x,
                    1,
                    1 / vumarkBehaviour.transform.localScale.z);
            this.lineRenderer                   = vumarkBorder.AddComponent <LineRenderer>();
            this.lineRenderer.enabled           = false;
            this.lineRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            this.lineRenderer.receiveShadows    = false;
            // This shader needs to be added in the Project's Graphics Settings,
            // unless it is already in use by a Material present in the project.
            this.lineRenderer.material.shader = Shader.Find("Unlit/Color");
            this.lineRenderer.material.color  = Color.clear;
            this.lineRenderer.positionCount   = 4;
            this.lineRenderer.loop            = true;
            this.lineRenderer.useWorldSpace   = false;
            Vector2        vumarkSize = vumarkBehaviour.GetSize();
            AnimationCurve curve      = new AnimationCurve();
            curve.AddKey(0.0f, 1.0f);
            curve.AddKey(1.0f, 1.0f);
            this.lineRenderer.widthCurve      = curve;
            this.lineRenderer.widthMultiplier = 0.003f;
            float vumarkExtentsX = (vumarkSize.x * 0.5f) + (this.lineRenderer.widthMultiplier * 0.5f);
            float vumarkExtentsZ = (vumarkSize.y * 0.5f) + (this.lineRenderer.widthMultiplier * 0.5f);
            this.lineRenderer.SetPositions(new Vector3[]
            {
                new Vector3(-vumarkExtentsX, 0.001f, vumarkExtentsZ),
                new Vector3(vumarkExtentsX, 0.001f, vumarkExtentsZ),
                new Vector3(vumarkExtentsX, 0.001f, -vumarkExtentsZ),
                new Vector3(-vumarkExtentsX, 0.001f, -vumarkExtentsZ)
            });
        }
    }
Example #20
0
    private void onVuMarkBehaviourFound(VuMarkBehaviour pVuMarkBehaviour)
    {
        if (registeredBehaviours.Contains(pVuMarkBehaviour))
        {
            //    Debug.Log("Previously tracked VumarkBehaviour found (" + pVuMarkBehaviour.name + ")");
        }
        else
        {
            //    Debug.Log("Newly tracked VumarkBehaviour found (" + pVuMarkBehaviour.name + ")");
            //    Debug.Log("Registering for VuMarkTargetAssignedCallbacks from " + pVuMarkBehaviour.name);

            //if we hadn't registered yet, we do so now
            registeredBehaviours.Add(pVuMarkBehaviour);

            pVuMarkBehaviour.RegisterVuMarkTargetAssignedCallback(
                () => vumarkTargetAssigned(pVuMarkBehaviour)
                );
        }
    }
    void Start()
    {
        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);

        this.vumarkInstanceTextures    = new Dictionary <string, Texture2D>();
        this.vumarkAugmentationObjects = new Dictionary <string, GameObject>();

        foreach (AugmentationObject obj in this.augmentationObjects)
        {
            this.vumarkAugmentationObjects.Add(obj.vumarkID, obj.augmentation);
        }

        // Hide the initial VuMark Template when the scene starts.
        VuMarkBehaviour vumarkBehaviour = FindObjectOfType <VuMarkBehaviour>();

        if (vumarkBehaviour)
        {
            ToggleRenderers(vumarkBehaviour.gameObject, false);
        }
    }
Example #22
0
    private void vumarkTargetAssigned(VuMarkBehaviour pVuMarkBehaviour)
    {
        //  Debug.Log("VuMarkTarget assigned to " + pVuMarkBehaviour.name + " with ID:" + pVuMarkBehaviour.VuMarkTarget.InstanceId.ToString());

        string myID = GetID(pVuMarkBehaviour.VuMarkTarget.InstanceId);

        // Debug.Log("Enabling object with ID:" + myID + " ....");

        foreach (Transform child in pVuMarkBehaviour.transform)
        {
            //Debug.Log("Matching gameObject " + child.name + " with ID " + myID + " SetActive (" + (myID == child.name) + ")");
            //child.gameObject.SetActive(myID == child.name);
            //Debug.Log("Matching gameObject " + child.name + " with ID " + myID + " SetActive (true)");
            //Debug.Log("wwwww");
            child.gameObject.SetActive(true);
            script = child.GetComponent <word>();
        }

        IdCheck(myID);
    }
    void Start()
    {
        this.vumarkInstanceTextures    = new Dictionary <string, Texture2D>();
        this.vumarkAugmentationObjects = new Dictionary <string, GameObject>();

        foreach (AugmentationObject obj in this.augmentationObjects)
        {
            this.vumarkAugmentationObjects.Add(obj.vumarkID, obj.augmentation);
        }

        // Hide the initial VuMark Template when the scene starts.
        VuMarkBehaviour vumarkBehaviour = FindObjectOfType <VuMarkBehaviour>();

        if (vumarkBehaviour)
        {
            ToggleRenderers(vumarkBehaviour.gameObject, false);
        }

        this.nearestVuMarkScreenPanel = FindObjectOfType <VuMarkTrackableStatusUI>();
    }
    /// <summary>
    ///  Register a callback which is invoked whenever a VuMark-result is newly detected which was not tracked in the frame before
    /// </summary>
    /// <param name="vumarkBehaviour"></param>
    public void OnVuMarkBehaviourDetected(VuMarkBehaviour vumarkBehaviour)
    {
        VLog.Log("cyan", "VuMarkHandler.OnVuMarkBehaviourDetected(): " + vumarkBehaviour.TrackableName);

        // The GameObject with the VuMarkBehaviour component attached gets duplicated whenever
        // a new VuMark is detected and the augmentations get attached to the new object.
        // Since this GameObject contains a Canvas, we need to reset the Camera reference when
        // duplicating, otherwise the MRTK will throw an exception. The MRTK then assigns the
        // appropriate Camera reference to the Canvas.
        vumarkBehaviour.GetComponentInChildren <Canvas>().worldCamera = null;

        GenerateVuMarkBorderOutline(vumarkBehaviour);

        ToggleRenderers(vumarkBehaviour.gameObject, true);

        // Check for existance of previous augmentations and delete before instantiating new ones.
        DestroyChildAugmentationsOfTransform(vumarkBehaviour.transform);

        StartCoroutine(OnVuMarkTargetAvailable(vumarkBehaviour));
    }
        protected override void Start()
        {
            base.Start();

            m_trackableBehaviour = GetComponent <VuMarkBehaviour>();

            if (m_trackableBehaviour)
            {
                OnTrackingLost();

                m_trackableBehaviour.RegisterVuMarkTargetAssignedCallback(() =>
                {
                    Debug.Log("Trackable assigned " + GetTrackableInstanceId());
                });

                m_trackableBehaviour.RegisterVuMarkTargetLostCallback(() =>
                {
                    Debug.Log("Trackable lost " + GetTrackableInstanceId());
                });
                m_trackableBehaviour.RegisterTrackableEventHandler(this);
            }
        }
Example #26
0
    /// <summary>
    /// Enabled/disabled Extended Tracking mode.
    /// </summary>
    /// <param name="ON"></param>
    public virtual void SwitchExtendedTracking(bool extTrackingEnabled)
    {
        StateManager stateManager = TrackerManager.Instance.GetStateManager();

        // We iterate over all TrackableBehaviours to start or stop extended tracking for the targets they represent.
        bool success = true;

        foreach (var tb in stateManager.GetTrackableBehaviours())
        {
            if (tb is ImageTargetBehaviour)
            {
                ImageTargetBehaviour itb = tb as ImageTargetBehaviour;
                if (extTrackingEnabled)
                {
                    if (!itb.ImageTarget.StartExtendedTracking())
                    {
                        success = false;
                        Debug.LogError("Failed to start Extended Tracking on Target " + itb.TrackableName);
                    }
                }
                else
                {
                    itb.ImageTarget.StopExtendedTracking();
                }
            }
            else if (tb is MultiTargetBehaviour)
            {
                MultiTargetBehaviour mtb = tb as MultiTargetBehaviour;
                if (extTrackingEnabled)
                {
                    if (!mtb.MultiTarget.StartExtendedTracking())
                    {
                        success = false;
                        Debug.LogError("Failed to start Extended Tracking on Target " + mtb.TrackableName);
                    }
                }
                else
                {
                    mtb.MultiTarget.StopExtendedTracking();
                }
            }
            else if (tb is CylinderTargetBehaviour)
            {
                CylinderTargetBehaviour ctb = tb as CylinderTargetBehaviour;
                if (extTrackingEnabled)
                {
                    if (!ctb.CylinderTarget.StartExtendedTracking())
                    {
                        success = false;
                        Debug.LogError("Failed to start Extended Tracking on Target " + ctb.TrackableName);
                    }
                }
                else
                {
                    ctb.CylinderTarget.StopExtendedTracking();
                }
            }
            else if (tb is ObjectTargetBehaviour)
            {
                ObjectTargetBehaviour otb = tb as ObjectTargetBehaviour;
                if (extTrackingEnabled)
                {
                    if (!otb.ObjectTarget.StartExtendedTracking())
                    {
                        success = false;
                        Debug.LogError("Failed to start Extended Tracking on Target " + otb.TrackableName);
                    }
                }
                else
                {
                    otb.ObjectTarget.StopExtendedTracking();
                }
            }
            else if (tb is VuMarkBehaviour)
            {
                VuMarkBehaviour vmb = tb as VuMarkBehaviour;
                if (extTrackingEnabled)
                {
                    if (!vmb.VuMarkTemplate.StartExtendedTracking())
                    {
                        success = false;
                        Debug.LogError("Failed to start Extended Tracking on Target " + vmb.TrackableName);
                    }
                }
                else
                {
                    vmb.VuMarkTemplate.StopExtendedTracking();
                }
            }
        }
        mExtTrackingEnabled = success && extTrackingEnabled;
    }
Example #27
0
    void Start()
    {
        initialCullingMask = Camera.main.cullingMask;
        UpdateTrackingStatus(false);

        this.Delayed(0.5f, () =>
        {
            // Vuforia automatically creates this child, we want it to be on a separate layer so we can render
            // only the background video when tracking is inactive.
            Camera.main.transform.Find("BackgroundPlane").gameObject.layer = LayerMask.NameToLayer("BackgroundPlane");
        });

        bool focusSuccess = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

        Debug.Log("Focus mode continuous auto supported: " + focusSuccess);
        if (!focusSuccess)
        {
            focusSuccess = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
            Debug.Log("Focus mode fallback default success: " + focusSuccess);
        }

        // Through the editor, we can only set VuMarkWorldCenter,
        // which behaves incorrectly when a VuMark is cloned.
        // We need to keep track of which VuMarkBehavior is the main
        // tracker and should be the WorldCenter ourselves!
        VuforiaManager.Instance.WorldCenter       = mainVuMark;
        VuforiaManager.Instance.VuMarkWorldCenter = null;

        var vuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager();

        vuMarkManager.RegisterVuMarkBehaviourDetectedCallback(behavior =>
        {
            if (!this)
            {
                return;
            }
            var numericScript = behavior.GetComponent <VuforiaNumericDetector>();
            if (numericScript == null)
            {
                return;
            }

            // VuMarkTarget was not assigned yet => marker ID not yet known.
            // Need to delay until next frame.
            this.Delayed(0, () =>
            {
                if (numericScript.currentMarkerId == centerTrackerId)
                {
                    UpdateTrackingStatus(true);
                    if (mainVuMark != behavior)
                    {
                        mainVuMark = behavior;
                        mainVuMark.transform.position       = Vector3.zero;
                        mainVuMark.transform.rotation       = Quaternion.identity;
                        VuforiaManager.Instance.WorldCenter = mainVuMark;
                        Debug.Log("#### mainVuMark has changed!", mainVuMark);
                    }
                }
            });
        });
        vuMarkManager.RegisterVuMarkLostCallback(target =>
        {
            if (!this)
            {
                return;
            }
            if ((int)target.InstanceId.NumericValue == centerTrackerId)
            {
                UpdateTrackingStatus(false);
            }
        });
    }
Example #28
0
    void OnTouched(int pin, bool touched)
    {
        // If any pages in the book are tracked
        if (activeVuMarks.Count > 0)
        {
            // There are only one or two pages tracked at once
            VuMarkBehaviour trackablePage0 = activeVuMarks[0];
            VuMarkBehaviour trackablePage1 = activeVuMarks[1];


            // TODO: implement double pages

            print("Touched event on book page number " + trackablePage0.Trackable.ID);

            // Switch condition for each page / tracker ID
            currentPage = trackablePage0.Trackable.ID;
            CheckIfPageChanged();

            // Switch between the detected page
            switch (currentPage)
            {
            case 1:

                break;

            case 2:

                break;

            case 3:     // We're on page 3

                // What pin was touched?
                switch (pin)
                {
                case 0:
                    if (touched)
                    {
                        print("touched 0: now a visual will be activated");
                        visuals[2].SetActive(true);
                    }
                    else
                    {
                        print("UN touched 0: now a visual will be deactivated");
                        visuals[2].SetActive(false);
                    }
                    break;

                case 1:
                    break;

                case 2:
                    break;
                }
                break;

            case 4:     // We're on page 4

                // What pin was touched?
                switch (pin)
                {
                case 0:
                    if (touched)
                    {
                        print("touched 0: now a visual will be activated");
                        visuals[3].SetActive(true);
                    }
                    else
                    {
                        print("UN touched 0: now a visual will be deactivated");
                        visuals[3].SetActive(false);
                    }
                    break;

                case 1:
                    break;

                case 2:
                    break;
                }
                break;
            }
        }
    }
Example #29
0
    void TargetFond(VuMarkBehaviour markBehaviour)
    {
        int targetId = int.Parse(markBehaviour.VuMarkTarget.InstanceId.ToString());

        GrenierTargetFondDelegate(targetId, markBehaviour.transform.GetChild(0));
    }