Log in or register to post comments

Enable/Disable a trackable

October 24, 2012 - 3:22pm #1

Hi everybody,

I'm using a code to enable and disable a trackable. But it seems that is not working.

 

Quote:

 ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);

 DataSet dataSet = imageTracker.GetActiveDataSet();

        int numTrackables = dataSet.GetNumTrackables();

        for (int i = 0; i < numTrackables; ++i)

        {

            TrackableBehaviour trackable = dataSet.GetTrackable(i);

            if (trackable != null && trackable.TrackableName == trackName)

            {

                trackable.enabled = enable;

            }

        }

 

Could you tell me if this code should work or not? And maybe some other code that's working?
Thank you ! 

Enable/Disable a trackable

August 12, 2013 - 7:32am #14

Great to hear :)

N

Enable/Disable a trackable

August 12, 2013 - 7:27am #13

Thanks for replying NalinS !

Yes this code works perfectly, and it's far easier.

 

Enable/Disable a trackable

August 12, 2013 - 6:18am #12

To  enumerate TrackableBehaviours, try the code below.

HTH

N

 

 

       StateManager stateManager = TrackerManager.Instance.GetStateManager();
                    
       foreach(TrackableBehaviour tb in stateManager.GetTrackableBehaviours()){
                    
              stateManager.DestroyTrackableBehavioursForTrackable(tb.Trackable);
                          
       }

Enable/Disable a trackable

August 12, 2013 - 6:13am #11

Up !

I'm still looking into scripts but I can't fint it.

Enable/Disable a trackable

August 8, 2013 - 1:35pm #10

Hi everybody !

I just updated an old project (which was using this code) to Vuforia 2.x and I realized that this code totally changed !

I can't found any function into DataSet to retrieve a list of TrackableBehaviours, how can I do that?

 

Thanks !

Enable/Disable a trackable

October 29, 2012 - 12:01pm #9

well I'm glad that you've solved it in any case ;)

[Solved]Enable/Disable a trackable

October 26, 2012 - 7:11am #8

Ok,

I solve the problem, but what a shame...
In my code, I forced the MSIT value a month ago the API to 1...Because the app design was to keep only one trackable at the same time.
So this was not a matters of enable/disable trackables...Sorry for that !

Thanks again for your support DavidBeard ! 

Enable/Disable a trackable

October 25, 2012 - 1:24pm #7

Here some infomations about the game:

We have 45 different trackables, two player game. the first player scans a trackable, and accept it. The second player does the same thing.
After it the player2 will play and only the trackable of the player1 will be active. Then players are switching and the game start again for the player1 with the player2's trackable.

Setting the MSIT value to 1 could be annoying, if the player scans the wrong trackable before the right one, because both trackables are sticked with a toy. And until he lost the wrong one, he won't be able to detect his trackable.

This is why I let the MSIT value to 2/3, to prevent this effect.

There is no way to really disable a trackable?

Enable/Disable a trackable

October 25, 2012 - 12:34pm #6

I've gotten confirmation that though you can disable the trackablebehaviour object, this isn't actually disabling the trackable within the dataset, which is why you're seeing this behavior. Sorry for the confusion. Can you achieve what you are attempting by setting the MSIT value for 1, and defining the necessary behaviour in the event handlers? Is it that the trackables need to be recognized in a sequence?

 

 

Enable/Disable a trackable

October 25, 2012 - 12:02pm #5

Afters some tests I realized that if I use this code (and disable the object too, but it changes nothing) the DefaultTrackableEventHandler will not send anymore events about disabled trackables, but if you have a trackable "disabled" on screen and you scan a trackable that is active, it won't work. Remove the wrong trackable from the view and it magically works. 

In our game we're supposed to scan one trackable at the same time (this is why I disable others trackables) but two of them are sticked (by a toy). If the player scans both trackables the game is broken.

Enable/Disable a trackable

October 25, 2012 - 10:42am #4

I just figured out your answer but I don't think it will change anything because "DataSetTrackableBehaviour" is a child of "TrackableBehaviour".

And the property TrackableName came from the parent.

Maybe if I disable the gameObject too?

Enable/Disable a trackable

October 24, 2012 - 7:21pm #3

Hi DavidBears, as always thanks for your fast answer, I appreciate it :)

In order to test if a marker is active, I just do exactly the same thing, except instead of change the value of enable I just return it.

What do you mean by using "DataSetTrackableBehaviour"? I'm not very familiar with this part of the API, if you could give me a complete example, I'll try to understand it and bring it to tests.

And by "not working" it seems that the markers are not directly recognised by the API (Default message sending is not sent) but it blocks the detection of other trackables.

Enable/Disable a trackable

October 24, 2012 - 6:44pm #2

Try using the DataSetTrackableBehaviour and enabling / disabling that.

e.g.

    int numTrackables = dataSet.GetNumTrackables();

    // Loop over all Trackables.
    
    for (int i = 0; i < numTrackables; ++i)
    {
        DataSetTrackableBehaviour dstb = dataSet.GetTrackable(i);

...


Also how are you determining whether they are being enabled / disabled?
Log in or register to post comments