/// <summary>
    /// Takes a new trackable source and adds it to the dataset
    /// This gets called automatically as soon as you 'BuildNewTarget with UserDefinedTargetBuildingBehaviour
    /// </summary>
    public void OnNewTrackableSource(TrackableSource trackableSource)
    {
        mTargetCounter++;

        // deactivates the dataset first
        mObjectTracker.DeactivateDataSet(mBuiltDataSet);

        // Destroy the oldest target if the dataset is full
        if (mBuiltDataSet.HasReachedTrackableLimit())
        {
            IEnumerable <Trackable> trackables = mBuiltDataSet.GetTrackables();
            Trackable oldest = null;
            foreach (Trackable trackable in trackables)
            {
                if (oldest == null || trackable.ID < oldest.ID)
                {
                    oldest = trackable;
                }
            }

            if (oldest != null)
            {
                Debug.Log("Destroying oldest trackable in UDT dataset: " + oldest.Name);
                mBuiltDataSet.Destroy(oldest, true);
            }
        }

        // get predefined trackable and instantiate it
        ImageTargetBehaviour imageTargetCopy = (ImageTargetBehaviour)Instantiate(ImageTargetTemplate);

        imageTargetCopy.gameObject.name = "UserDefinedTarget-" + mTargetCounter;
        textMesh      = imageTargetCopy.gameObject.GetComponentInChildren <TextMesh>();
        textMesh.text = "Target #" + mTargetCounter;


        // add the duplicated trackable to the data set and activate it
        mBuiltDataSet.CreateTrackable(trackableSource, imageTargetCopy.gameObject);


        // activate the dataset again
        mObjectTracker.ActivateDataSet(mBuiltDataSet);

        //Extended Tracking with user defined targets only works with the most recently defined target.
        //If tracking is enabled on previous target, it will not work on newly defined target.
        //Don't need to call this if you don't care about extended tracking.
        //StopExtendedTracking();
        bool persist = mObjectTracker.PersistExtendedTracking(true);

        if (persist)
        {
            mObjectTracker.Stop();
            mObjectTracker.ResetExtendedTracking();
            mObjectTracker.Start();
        }
    }
Exemple #2
0
    /// <summary>
    /// Takes a new trackable source and adds it to the dataset
    /// This gets called automatically as soon as you 'BuildNewTarget with UserDefinedTargetBuildingBehaviour
    /// </summary>
    public void OnNewTrackableSource(TrackableSource trackableSource)
    {
        mTargetCounter++;

        // Deactivates the dataset first
        mObjectTracker.DeactivateDataSet(mBuiltDataSet);

        // Destroy the oldest target if the dataset is full or the dataset
        // already contains five user-defined targets.
        if (mBuiltDataSet.HasReachedTrackableLimit() || mBuiltDataSet.GetTrackables().Count() >= MAX_TARGETS)
        {
            IEnumerable <Trackable> trackables = mBuiltDataSet.GetTrackables();
            Trackable oldest = null;
            Debug.Log(" text 123456789");
            foreach (Trackable trackable in trackables)
            {
                if (oldest == null || trackable.ID < oldest.ID)
                {
                    oldest = trackable;
                }
            }

            if (oldest != null)
            {
                Debug.Log("Destroying oldest trackable in UDT dataset: " + oldest.Name);
                mBuiltDataSet.Destroy(oldest, true);
            }
        }


        // Get predefined trackable and instantiate it
        ImageTargetBehaviour imageTargetCopy = (ImageTargetBehaviour)Instantiate(ImageTargetTemplate);

        imageTargetCopy.gameObject.name = "UserDefinedTarget-" + mTargetCounter;

        // Add the duplicated trackable to the data set and activate it
        mBuiltDataSet.CreateTrackable(trackableSource, imageTargetCopy.gameObject);

        // Activate the dataset again
        mObjectTracker.ActivateDataSet(mBuiltDataSet);

        // Extended Tracking with user defined targets only works with the most recently defined target.
        // If tracking is enabled on previous target, it will not work on newly defined target.
        // Don't need to call this if you don't care about extended tracking.
        StopExtendedTracking();
        mObjectTracker.Stop();
        mObjectTracker.ResetExtendedTracking();
        mObjectTracker.Start();

        // Make sure TargetBuildingBehaviour keeps scanning...
        mTargetBuildingBehaviour.StartScanning();
    }
        public void OnNewTrackableSource(TrackableSource trackableSource)
        {
            _objectTracker.DeactivateDataSet(_udtDataSet);
            _udtDataSet.DestroyAllTrackables(true);
            var instance = Instantiate(_imageTargetTemplate);

            instance.gameObject.name = string.Format("{0}_instance", _imageTargetTemplate.TrackableName);
            instance.gameObject.SetActive(true);
            //TODO make more abstract
            MainSceneController.Instance.SceneContainer = instance.GetComponent <SceneContainer>();
            _udtDataSet.CreateTrackable(trackableSource, instance.gameObject);
            _objectTracker.ActivateDataSet(_udtDataSet);
            StopExtendedTracking();
            _objectTracker.Stop();
            _objectTracker.ResetExtendedTracking();
            _objectTracker.Start();
            _targetBuildingBehaviour.StartScanning();
        }
    /// <summary>
    /// Takes a new trackable source and adds it to the dataset
    /// This gets called automatically as soon as you 'BuildNewTarget with UserDefinedTargetBuildingBehaviour
    /// </summary>
    public void OnNewTrackableSource(TrackableSource trackableSource)
    {
        mTargetCounter++;

        // Deactivates the dataset first
        mObjectTracker.DeactivateDataSet(mBuiltDataSet);

        // Destroy the oldest target if the dataset is full or the dataset
        // already contains five user-defined targets.
        if (mBuiltDataSet.HasReachedTrackableLimit() || mBuiltDataSet.GetTrackables().Count() >= MAX_TARGETS)
        {
            IEnumerable <Trackable> trackables = mBuiltDataSet.GetTrackables();
            Trackable oldest = null;
            foreach (Trackable trackable in trackables)
            {
                if (oldest == null || trackable.ID < oldest.ID)
                {
                    oldest = trackable;
                }
            }

            if (oldest != null)
            {
                Debug.Log("Destroying oldest trackable in UDT dataset: " + oldest.Name);
                mBuiltDataSet.Destroy(oldest, true);
            }
        }

        // Get predefined trackable and instantiate it
        ImageTargetBehaviour imageTargetCopy = (ImageTargetBehaviour)Instantiate(ImageTargetTemplate);

        imageTargetCopy.gameObject.name = "UserDefinedTarget-" + mTargetCounter;

        // Add the duplicated trackable to the data set and activate it
        mBuiltDataSet.CreateTrackable(trackableSource, imageTargetCopy.gameObject);

        // Activate the dataset again
        mObjectTracker.ActivateDataSet(mBuiltDataSet);

        mObjectTracker.Stop();
        mObjectTracker.ResetExtendedTracking();
        mObjectTracker.Start();
    }
        public void OnNewTrackableSource(TrackableSource trackableSource)
        {
            _objectTracker.DeactivateDataSet(_udtDataSet);
            _udtDataSet.DestroyAllTrackables(true);
            var instance = Instantiate(_imageTargetTemplate);

            instance.gameObject.name = string.Format("{0}_instance", _imageTargetTemplate.TrackableName);
            instance.gameObject.SetActive(true);
            _udtDataSet.CreateTrackable(trackableSource, instance.gameObject);
            _objectTracker.ActivateDataSet(_udtDataSet);
            StopExtendedTracking();
            _objectTracker.Stop();
            _objectTracker.ResetExtendedTracking();
            if (OnTargetBuilt != null)
            {
                OnTargetBuilt(this, new TargetBuiltEventArgs(instance.GetComponent <TrackableObject>()));
            }
            _objectTracker.Start();
            _targetBuildingBehaviour.StartScanning();
        }
Exemple #6
0
    /// <summary>
    /// Takes a new trackable source and adds it to the dataset
    /// This gets called automatically as soon as you 'BuildNewTarget with UserDefinedTargetBuildingBehaviour
    /// </summary>
    public void OnNewTrackableSource(TrackableSource trackableSource)
    {
        // Deactivates the dataset first
        m_ObjectTracker.DeactivateDataSet(m_UDT_DataSet);

        // Destroy the oldest target in the dataset if a new target is created
        IEnumerable <Trackable> trackables = m_UDT_DataSet.GetTrackables();
        Trackable oldest = null;

        //fetch for the last target to destroy it
        foreach (Trackable trackable in trackables)
        {
            if (oldest == null || trackable.ID < oldest.ID)
            {
                oldest = trackable;
            }
        }
        if (oldest != null)
        {
            Debug.Log("Destroying oldest trackable in UDT dataset: " + oldest.Name);
            m_UDT_DataSet.Destroy(oldest, true);
        }


        // Get predefined trackable and instantiate it
        ImageTargetBehaviour imageTargetCopy = Instantiate(ImageTargetTemplate);

        imageTargetCopy.gameObject.name = "USERTARGET";
        // Add the duplicated trackable to the data set and activate it
        m_UDT_DataSet.CreateTrackable(trackableSource, imageTargetCopy.gameObject);

        // Activate the dataset again
        m_ObjectTracker.ActivateDataSet(m_UDT_DataSet);

        m_ObjectTracker.Stop();
        m_ObjectTracker.ResetExtendedTracking();
        m_ObjectTracker.Start();

        // Make sure TargetBuildingBehaviour keeps scanning...
        m_TargetBuildingBehaviour.StartScanning();
    }
        public void OnNewTrackableSource(TrackableSource trackableSource)
        {
            _objectTracker.DeactivateDataSet(_udtDataSet);
            _udtDataSet.DestroyAllTrackables(true);
            var instance = Instantiate(_imageTargetTemplate);

            instance.gameObject.name = $"{_imageTargetTemplate.TrackableName}_instance";
            instance.gameObject.SetActive(true);
            _udtDataSet.CreateTrackable(trackableSource, instance.gameObject);
            _objectTracker.ActivateDataSet(_udtDataSet);
            StopExtendedTracking();
            _objectTracker.Stop();
            _objectTracker.ResetExtendedTracking();
            //TODO make more abstract
            SceneControllerTurbine.Instance.HookOnTrackingChanged();
            _objectTracker.Start();
            //TODO: make more abstract
            SceneControllerTurbine.Instance.SceneState = TurbineState.Default;
            _targetBuildingBehaviour.StartScanning();
            //TODO: make more abstract
            TurbineViewModel.Instance.RefreshProperties();
        }
Exemple #8
0
    /// <summary>
    /// Takes a new trackable source and adds it to the dataset
    /// This gets called automatically as soon as you 'BuildNewTarget with UserDefinedTargetBuildingBehaviour
    /// </summary>
    public void OnNewTrackableSource(TrackableSource trackableSource)
    {
        mTargetCounter++;

        // Deactivates the dataset first
        mObjectTracker.DeactivateDataSet(mBuiltDataSet);

        // Destroy the oldest target if the dataset is full or the dataset
        // already contains five user-defined targets.
        if (mBuiltDataSet.HasReachedTrackableLimit() || mBuiltDataSet.GetTrackables().Count() >= MAX_TARGETS)
        {
            IEnumerable <Trackable> trackables = mBuiltDataSet.GetTrackables();
            foreach (Trackable trackable in trackables)
            {
                mBuiltDataSet.Destroy(trackable, true);
            }
        }


        // Get predefined trackable and instantiate it       -----  Add more targets

        /*ImageTargetBehaviour imageTargetCopy = (ImageTargetBehaviour)Instantiate(ImageTargetTemplate);
         * imageTargetCopy.gameObject.name = "UserDefinedTarget-" + mTargetCounter;*/

        // Add the duplicated trackable to the data set and activate it
        mBuiltDataSet.CreateTrackable(trackableSource, ImageTargetTemplate.gameObject);

        // Activate the dataset again
        mObjectTracker.ActivateDataSet(mBuiltDataSet);

        // Extended Tracking with user defined targets only works with the most recently defined target.
        // If tracking is enabled on previous target, it will not work on newly defined target.
        // Don't need to call this if you don't care about extended tracking.
        StopExtendedTracking();
        mObjectTracker.Stop();
        mObjectTracker.ResetExtendedTracking();
        mObjectTracker.Start();
    }
Exemple #9
0
    /// <summary>
    /// Takes a new trackable source and adds it to the dataset
    /// This gets called automatically as soon as you 'BuildNewTarget with UserDefinedTargetBuildingBehaviour
    /// </summary>
    public void OnNewTrackableSource(TrackableSource trackableSource)
    {
        mTargetCounter++;

        // Deactivates the dataset first
        mObjectTracker.DeactivateDataSet(mBuiltDataSet);

        // Destroy the oldest target if the dataset is full or the dataset
        // already contains five user-defined targets.
        if (mBuiltDataSet.HasReachedTrackableLimit() || mBuiltDataSet.GetTrackables().Count() >= MAX_TARGETS)
        {
            IEnumerable <Trackable> trackables = mBuiltDataSet.GetTrackables();
            Trackable oldest = null;
            foreach (Trackable trackable in trackables)
            {
                if (oldest == null || trackable.ID < oldest.ID)
                {
                    oldest = trackable;
                }
            }

            if (oldest != null)
            {
                Debug.Log("Destroying oldest trackable in UDT dataset: " + oldest.Name);
                mBuiltDataSet.Destroy(oldest, true);
            }
        }

        // Get predefined trackable and instantiate it
        ImageTargetBehaviour imageTargetCopy = (ImageTargetBehaviour)Instantiate(ImageTargetTemplate);

        imageTargetCopy.gameObject.name = "UserDefinedTarget-" + mTargetCounter;

        // Add the duplicated trackable to the data set and activate it
        mBuiltDataSet.CreateTrackable(trackableSource, imageTargetCopy.gameObject);

        // Activate the dataset again
        mObjectTracker.ActivateDataSet(mBuiltDataSet);

        // Extended Tracking with user defined targets only works with the most recently defined target.
        // If tracking is enabled on previous target, it will not work on newly defined target.
        // Don't need to call this if you don't care about extended tracking.
        StopExtendedTracking();
        mObjectTracker.Stop();
        mObjectTracker.ResetExtendedTracking();
        mObjectTracker.Start();

        //Edited part according to application requirements
        Button     settings_button;
        GameObject BuildPanel;
        GameObject click_button;

        GameObject[] created_target;
        click_button        = GameObject.Find("BuildButton");
        click_button.active = false;
        BuildPanel          = GameObject.Find("BuildPanel");
        BuildPanel.active   = false;
        ImageTargetTemplate.gameObject.active = false;
        settings_button = GameObject.FindGameObjectWithTag("settings_button").GetComponent <Button>();
        settings_button.onClick.Invoke();
        //Edited part ends here

        // Make sure TargetBuildingBehaviour keeps scanning...
        mTargetBuildingBehaviour.StartScanning();
    }