Log in or register to post comments

get the ID of a Vumark

October 16, 2016 - 2:04pm #1

Hello,

I'm newbie in Vumark. I want to make a simple app that get the ID of a trackable Vumark and depending on the ID, It swap the 3D model.

For example :

public VumarkTarget vumark;

public Gameobject teapot;

public Gameobject tower;

 

if (vumark.ID = 1)

{ teapot.setactive(true);

tower.setactive(false);}

else {

teapot.setactive(false);

tower.setactive(true);

}

 

I wonder how can I instantiate my vumark via editor or via script like I can do to Gameobject (teapot and tower) ? I read the vumark sample and the imagetarget sample but I couldn't understand how I instantiate my vumarktarget to get its ID.

 

Thanks for helping

 

get the ID of a Vumark

December 14, 2016 - 7:43am #4

To answer your question directly:



1 - Update() is a continuous loop that runs over and over as long as your application is running.

2 - foreach is another form of loop but these are specific and need direction like "loop through each vumark".

3 - This entire foreach loop is basically saying:

     - For each vumark you find remember it (vumark = bhvr.VuMarkTarget)

     - If its ID is "VuMark00", then turn on the teapot and turn off the tower

     - If its ID IS NOT "VuMark00", then do the opposite (teapot off, tower on)

So, for example, if you wanted to do something ONLY for a vumark with an id of "VuMarkCowFace":

if (vumark.InstanceId.StringValue == "VuMarkCowFace") {

     //do stuff here like show and hide other models

}

Hope this helps.

get the ID of a Vumark

October 24, 2016 - 4:54am #3

After a deep observation of the Vumark Sample app, I come up with this script which works perfectly. Tower and Teapot are two 3D models that I have assigned them in the editor inspector :

 

Quote:

    public GameObject teapot;

    public GameObject tower;

    public VuMarkTarget vumark;

    private VuMarkManager mVuMarkManager;

    void Start () {

        mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager();

    }

void Update () {

        foreach (var bhvr in mVuMarkManager.GetActiveBehaviours())

        {

            vumark = bhvr.VuMarkTarget;

        }

        if (vumark.InstanceId.StringValue == "VuMark00")

        {

            teapot.SetActive(true);

            tower.SetActive(false);

        }

        else

        {

            teapot.SetActive(false);

            tower.SetActive(true);

        }

}

Could someone explain to me what this line of code do in theory :

foreach (var bhvr in mVuMarkManager.GetActiveBehaviours())

        {

            vumark = bhvr.VuMarkTarget;

        }

get the ID of a Vumark

October 18, 2016 - 8:18pm #2

See this post:

https://developer.vuforia.com/forum/vumarks/changing-vumark-id-unity#comment-56660

Log in or register to post comments