private VuMarkAbstractBehaviour CreateOrGetUnusedBehaviour(int templateId)
        {
            if (!this.mBehaviours.ContainsKey(templateId))
            {
                Debug.LogError("Template " + templateId + " is not available in behaviour list");
            }
            VuMarkAbstractBehaviour vuMarkAbstractBehaviour = null;

            foreach (VuMarkAbstractBehaviour current in this.mBehaviours[templateId])
            {
                if (current.VuMarkTarget == null)
                {
                    vuMarkAbstractBehaviour = current;
                }
            }
            if (vuMarkAbstractBehaviour == null)
            {
                vuMarkAbstractBehaviour = this.CopyGameObject(this.mBehaviours[templateId][0]);
                this.mBehaviours[templateId].Add(vuMarkAbstractBehaviour);
            }
            if (this.mOnVuMarkBehaviourDetected != null)
            {
                this.mOnVuMarkBehaviourDetected.InvokeWithExceptionHandling(vuMarkAbstractBehaviour);
            }
            return(vuMarkAbstractBehaviour);
        }
        private VuMarkAbstractBehaviour CopyGameObject(VuMarkAbstractBehaviour bhvr)
        {
            VuMarkAbstractBehaviour expr_10 = UnityEngine.Object.Instantiate <GameObject>(bhvr.gameObject).GetComponent <VuMarkAbstractBehaviour>();

            expr_10.InitializeTarget(bhvr.VuMarkTemplate, false);
            return(expr_10);
        }
Ejemplo n.º 3
0
        private bool TryGetBehaviour(VuforiaManager.TrackableIdPair trackableId, out TrackableBehaviour trackableBehaviour)
        {
            if (trackableId.ResultId >= 0)
            {
                using (List <VuMarkAbstractBehaviour> .Enumerator enumerator = this.mVuMarkManager.GetActiveBehaviours().ToList <VuMarkAbstractBehaviour>().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        VuMarkAbstractBehaviour current = enumerator.Current;
                        if (current.VuMarkResultId == trackableId.ResultId)
                        {
                            trackableBehaviour = current;
                            return(true);
                        }
                    }
                    goto IL_6A;
                }
                goto IL_57;
IL_6A:
                trackableBehaviour = null;
                return(false);
            }
IL_57:
            return(this.mTrackableBehaviours.TryGetValue(trackableId.TrackableId, out trackableBehaviour));
        }
 private void MarkBehaviourUntracked(VuMarkAbstractBehaviour behaviour)
 {
     if (behaviour.VuMarkTarget != null && behaviour.VuMarkResultId != -1)
     {
         behaviour.OnTrackerUpdate(TrackableBehaviour.Status.NOT_FOUND);
         behaviour.UnregisterVuMarkTarget();
         behaviour.VuMarkResultId = -1;
         behaviour.gameObject.SetActive(false);
     }
 }
 internal bool AddTemplateBehaviour(VuMarkAbstractBehaviour behaviour)
 {
     if (!this.mDestroyedBehaviours.Contains(behaviour))
     {
         this.mBehaviours[behaviour.VuMarkTemplate.ID] = new List <VuMarkAbstractBehaviour>
         {
             behaviour
         };
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        private VuMarkAbstractBehaviour CreateVuMarkBehaviour(VuMarkTemplate target)
        {
            GameObject gameObject = new GameObject();
            VuMarkAbstractBehaviour vuMarkAbstractBehaviour = BehaviourComponentFactory.Instance.AddVuMarkBehaviour(gameObject);

            Debug.Log(string.Concat(new object[]
            {
                "Creating VuMark Template with values: \n ID:           ",
                target.ID,
                "\n Name:         ",
                target.Name,
                "\n Path:         ",
                ((VuMarkTemplateImpl)target).DataSet.Path
            }));
            vuMarkAbstractBehaviour.InitializeTarget(target, true);
            return(vuMarkAbstractBehaviour);
        }
        private void UpdateVuMarkResults(VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResults)
        {
            HashSet <int> hashSet = new HashSet <int>();

            VuforiaManagerImpl.VuMarkTargetResultData[] array = vuMarkResults;
            for (int i = 0; i < array.Length; i++)
            {
                VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = array[i];
                hashSet.Add(vuMarkTargetResultData.resultID);
            }
            foreach (VuMarkAbstractBehaviour current in this.GetActiveBehaviours().ToList <VuMarkAbstractBehaviour>())
            {
                if (!hashSet.Contains(current.VuMarkResultId))
                {
                    this.MarkBehaviourUntracked(current);
                }
            }
            array = vuMarkResults;
            for (int i = 0; i < array.Length; i++)
            {
                VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData2 = array[i];
                VuMarkTarget vuMarkTarget = this.GetVuMarkTarget(vuMarkTargetResultData2.targetID);
                if (vuMarkTarget == null)
                {
                    Debug.LogError("Error: Target is not available");
                }
                VuMarkAbstractBehaviour vuMarkAbstractBehaviour = null;
                foreach (VuMarkAbstractBehaviour current2 in this.GetActiveBehaviours(vuMarkTarget).ToList <VuMarkAbstractBehaviour>())
                {
                    if (current2.VuMarkResultId == vuMarkTargetResultData2.resultID)
                    {
                        vuMarkAbstractBehaviour = current2;
                        break;
                    }
                }
                if (vuMarkAbstractBehaviour == null)
                {
                    VuMarkAbstractBehaviour vuMarkAbstractBehaviour2 = this.CreateOrGetUnusedBehaviour(vuMarkTarget.Template.ID);
                    this.AssociateTargetWithBehaviour(vuMarkTarget, vuMarkAbstractBehaviour2);
                    vuMarkAbstractBehaviour = vuMarkAbstractBehaviour2;
                    vuMarkAbstractBehaviour.VuMarkResultId = vuMarkTargetResultData2.resultID;
                }
            }
        }
 internal void UpdateVuMarkPoses(Transform arCameraTransform, VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResults, int originTrackableResultId)
 {
     for (int i = 0; i < vuMarkResults.Length; i++)
     {
         VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = vuMarkResults[i];
         VuMarkAbstractBehaviour activeBehaviour = this.GetActiveBehaviour(vuMarkTargetResultData.targetID, vuMarkTargetResultData.resultID);
         if (activeBehaviour != null)
         {
             if (vuMarkTargetResultData.resultID != originTrackableResultId)
             {
                 StateManagerImpl.PositionTrackable(activeBehaviour, arCameraTransform, vuMarkTargetResultData.pose, vuMarkTargetResultData.timeStamp);
             }
         }
         else
         {
             Debug.Log(string.Format("Have a null behaviour while iterating over VuMarkResults: resultID={0}, targetID={1}", vuMarkTargetResultData.targetID, vuMarkTargetResultData.resultID));
         }
     }
 }
Ejemplo n.º 9
0
 private void CreateMissingDataSetTrackableBehaviours(DataSet dataSet)
 {
     foreach (Trackable current in dataSet.GetTrackables())
     {
         if (!this.mTrackableBehaviours.ContainsKey(current.ID))
         {
             if (current is ImageTarget)
             {
                 ImageTargetAbstractBehaviour imageTargetAbstractBehaviour = this.CreateImageTargetBehaviour((ImageTarget)current);
                 imageTargetAbstractBehaviour.CreateMissingVirtualButtonBehaviours();
                 this.mTrackableBehaviours[current.ID] = imageTargetAbstractBehaviour;
                 this.mAutomaticallyCreatedBehaviours.Add(current.ID);
             }
             else if (current is MultiTarget)
             {
                 MultiTargetAbstractBehaviour value = this.CreateMultiTargetBehaviour((MultiTarget)current);
                 this.mTrackableBehaviours[current.ID] = value;
                 this.mAutomaticallyCreatedBehaviours.Add(current.ID);
             }
             else if (current is CylinderTarget)
             {
                 CylinderTargetAbstractBehaviour value2 = this.CreateCylinderTargetBehaviour((CylinderTarget)current);
                 this.mTrackableBehaviours[current.ID] = value2;
                 this.mAutomaticallyCreatedBehaviours.Add(current.ID);
             }
             else if (current is VuMarkTemplate)
             {
                 if (!this.mVuMarkManager.ContainsVuMarkTemplate(current.ID))
                 {
                     VuMarkAbstractBehaviour behaviour = this.CreateVuMarkBehaviour((VuMarkTemplate)current);
                     this.mVuMarkManager.AddTemplateBehaviour(behaviour);
                 }
             }
             else if (current is ObjectTarget)
             {
                 DataSetTrackableBehaviour value3 = this.CreateObjectTargetBehaviour((ObjectTarget)current);
                 this.mTrackableBehaviours[current.ID] = value3;
                 this.mAutomaticallyCreatedBehaviours.Add(current.ID);
             }
         }
     }
 }
 internal void DestroyBehaviourCopies()
 {
     this.mDestroyedBehaviours.Clear();
     foreach (List <VuMarkAbstractBehaviour> current in this.mBehaviours.Values)
     {
         for (int i = 1; i < current.Count; i++)
         {
             if (!this.mDestroyedBehaviours.Contains(current[i]))
             {
                 this.mDestroyedBehaviours.Add(current[i]);
                 if (current[i] != null)
                 {
                     UnityEngine.Object.Destroy(current[i].gameObject);
                 }
             }
         }
         VuMarkAbstractBehaviour vuMarkAbstractBehaviour = current[0];
         vuMarkAbstractBehaviour.UnregisterVuMarkTarget();
         current.Clear();
         current.Add(vuMarkAbstractBehaviour);
     }
 }
        private void UpdateExtendedTrackedVuMarks()
        {
            StateManagerImpl expr_0F = (StateManagerImpl)TrackerManager.Instance.GetStateManager();

            VuforiaManager.TrackableIdPair[] array = expr_0F.GetExtendedTrackingManager().GetExtendedTrackedBehaviours().ToArray <VuforiaManager.TrackableIdPair>();
            VuMarkManagerImpl vuMarkManagerImpl    = (VuMarkManagerImpl)expr_0F.GetVuMarkManager();
            List <int>        list = new List <int>();

            for (int i = 0; i < this.mVuMarkResultDataArray.Length; i++)
            {
                list.Add(this.mVuMarkResultDataArray[i].resultID);
            }
            Dictionary <int, List <int> > dictionary = new Dictionary <int, List <int> >();

            VuforiaManager.TrackableIdPair[] array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                int resultId = array2[j].ResultId;
                VuMarkAbstractBehaviour behaviourWithResultID = vuMarkManagerImpl.GetBehaviourWithResultID(resultId);
                if (behaviourWithResultID != null)
                {
                    int iD = behaviourWithResultID.VuMarkTarget.ID;
                    if (!list.Contains(resultId))
                    {
                        if (!dictionary.ContainsKey(iD))
                        {
                            dictionary[iD] = new List <int>();
                        }
                        dictionary[iD].Add(resultId);
                    }
                    else
                    {
                        list.Remove(resultId);
                    }
                }
            }
            for (int k = 0; k < this.mVuMarkResultDataArray.Length; k++)
            {
                int targetID = this.mVuMarkResultDataArray[k].targetID;
                int resultID = this.mVuMarkResultDataArray[k].resultID;
                if (list.Contains(resultID) && dictionary.ContainsKey(targetID))
                {
                    List <int> list2 = dictionary[targetID];
                    if (list2.Count > 0)
                    {
                        int num = list2[list2.Count - 1];
                        list2.RemoveAt(list2.Count - 1);
                        Debug.Log(string.Concat(new object[]
                        {
                            "CHANGE RESULT ID ",
                            this.mVuMarkResultDataArray[k].resultID,
                            " => ",
                            num
                        }));
                        this.mVuMarkResultDataArray[k].resultID = num;
                    }
                }
            }
            List <VuforiaManagerImpl.VuMarkTargetResultData> list3 = this.mVuMarkResultDataArray.ToList <VuforiaManagerImpl.VuMarkTargetResultData>();

            array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                VuforiaManager.TrackableIdPair trackableIdPair = array2[j];
                if (trackableIdPair.ResultId >= 0)
                {
                    bool flag = false;
                    VuforiaManagerImpl.VuMarkTargetResultData[] array3 = this.mVuMarkResultDataArray;
                    for (int l = 0; l < array3.Length; l++)
                    {
                        if (array3[l].resultID == trackableIdPair.ResultId)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        VuMarkAbstractBehaviour behaviourWithResultID2 = vuMarkManagerImpl.GetBehaviourWithResultID(trackableIdPair.ResultId);
                        list3.Add(new VuforiaManagerImpl.VuMarkTargetResultData
                        {
                            pose = new VuforiaManagerImpl.PoseData
                            {
                                coordinateSystem = TrackableBehaviour.CoordinateSystem.WORLD,
                                position         = behaviourWithResultID2.transform.position,
                                orientation      = behaviourWithResultID2.transform.rotation * Quaternion.AngleAxis(90f, Vector3.right)
                            },
                            resultID = trackableIdPair.ResultId,
                            targetID = behaviourWithResultID2.VuMarkTarget.ID,
                            status   = TrackableBehaviour.Status.EXTENDED_TRACKED
                        });
                    }
                }
            }
            this.mVuMarkResultDataArray = list3.ToArray();
            HashSet <int> hashSet = new HashSet <int>();

            array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                VuforiaManager.TrackableIdPair trackableIdPair2 = array2[j];
                if (trackableIdPair2.ResultId >= 0)
                {
                    VuMarkAbstractBehaviour behaviourWithResultID3 = vuMarkManagerImpl.GetBehaviourWithResultID(trackableIdPair2.ResultId);
                    if (behaviourWithResultID3 != null && behaviourWithResultID3.VuMarkTarget != null)
                    {
                        hashSet.Add(behaviourWithResultID3.VuMarkTarget.ID);
                    }
                }
            }
            List <VuforiaManagerImpl.VuMarkTargetData> list4 = new List <VuforiaManagerImpl.VuMarkTargetData>();

            for (int m = 0; m < this.mVuMarkDataArray.Length; m++)
            {
                int id = this.mVuMarkDataArray[m].id;
                if (!hashSet.Contains(id))
                {
                    list4.Add(this.mVuMarkDataArray[m]);
                }
            }
            this.mVuMarkDataArray = list4.ToArray();
        }
 private void AssociateTargetWithBehaviour(VuMarkTarget vuMark, VuMarkAbstractBehaviour bhvr)
 {
     bhvr.gameObject.SetActive(true);
     bhvr.RegisterVuMarkTarget(vuMark);
 }
        internal bool IsBehaviourMarkedForDeletion(TrackableBehaviour behaviour)
        {
            VuMarkAbstractBehaviour vuMarkAbstractBehaviour = behaviour as VuMarkAbstractBehaviour;

            return(vuMarkAbstractBehaviour != null && this.mDestroyedBehaviours.Contains(vuMarkAbstractBehaviour));
        }