Exemple #1
0
        private static SurfaceAbstractBehaviour InstantiateSurfaceBehaviour(SurfaceAbstractBehaviour input)
        {
            GameObject expr_0B = UnityEngine.Object.Instantiate <GameObject>(input.gameObject);

            expr_0B.transform.localScale = Vector3.one;
            return(expr_0B.GetComponent <SurfaceAbstractBehaviour>());
        }
Exemple #2
0
 public bool TryGetSurfaceBehaviour(Surface surface, out SurfaceAbstractBehaviour behaviour)
 {
     if (this.mActiveSurfaceBehaviours.ContainsKey(surface.ID))
     {
         behaviour = this.mActiveSurfaceBehaviours[surface.ID];
         return(true);
     }
     behaviour = null;
     return(false);
 }
Exemple #3
0
        private void UnregisterDeletedSurfaces(List <Surface> deletedSurfaces)
        {
            StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl;

            foreach (Surface current in deletedSurfaces)
            {
                if (this.mActiveSurfaceBehaviours.ContainsKey(current.ID))
                {
                    SurfaceAbstractBehaviour surfaceAbstractBehaviour = this.mActiveSurfaceBehaviours[current.ID];
                    if (surfaceAbstractBehaviour != null)
                    {
                        surfaceAbstractBehaviour.OnTrackerUpdate(TrackableBehaviour.Status.NOT_FOUND);
                        surfaceAbstractBehaviour.UnregisterTrackable();
                        UnityEngine.Object.Destroy(surfaceAbstractBehaviour.gameObject);
                    }
                    this.mActiveSurfaceBehaviours.Remove(current.ID);
                    stateManagerImpl.UnregisterExternallyManagedTrackableBehaviour(current.ID);
                }
            }
        }
Exemple #4
0
 private void AssociateSurfaceBehaviour(Surface trackable, SurfaceAbstractBehaviour behaviour)
 {
     behaviour.InitializeSurface(trackable);
 }
Exemple #5
0
        public SurfaceAbstractBehaviour AssociateSurface(SurfaceAbstractBehaviour templateBehaviour, Surface newSurface)
        {
            if (this.mActiveSurfaceBehaviours.ContainsKey(newSurface.ID))
            {
                Debug.LogWarning("Surface has already an associated behaviour");
                return(null);
            }
            StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl;

            if (templateBehaviour != null)
            {
                if (templateBehaviour.transform.parent == base.transform)
                {
                    SurfaceAbstractBehaviour surfaceAbstractBehaviour = ReconstructionAbstractBehaviour.InstantiateSurfaceBehaviour(templateBehaviour);
                    Transform transform = null;
                    if (newSurface.Parent == null)
                    {
                        transform = base.transform;
                    }
                    else if (newSurface.Parent is Surface)
                    {
                        if (this.mActiveSurfaceBehaviours.ContainsKey(newSurface.Parent.ID))
                        {
                            transform = this.mActiveSurfaceBehaviours[newSurface.Parent.ID].transform;
                        }
                        else
                        {
                            Debug.LogError("Parent Surface with id " + newSurface.Parent.ID + " could not be found");
                        }
                    }
                    else if (newSurface.Parent is Prop)
                    {
                        if (this.mActivePropBehaviours.ContainsKey(newSurface.Parent.ID))
                        {
                            transform = this.mActivePropBehaviours[newSurface.Parent.ID].transform;
                        }
                        else
                        {
                            Debug.LogError("Parent Prop with id " + newSurface.Parent.ID + " could not be found");
                        }
                    }
                    if (transform != null)
                    {
                        surfaceAbstractBehaviour.transform.parent = transform;
                    }
                    surfaceAbstractBehaviour.gameObject.SetActive(true);
                    this.AssociateSurfaceBehaviour(newSurface, surfaceAbstractBehaviour);
                    this.mActiveSurfaceBehaviours.Add(newSurface.ID, surfaceAbstractBehaviour);
                    stateManagerImpl.RegisterExternallyManagedTrackableBehaviour(surfaceAbstractBehaviour);
                    if (VuforiaManager.Instance.WorldCenterMode == VuforiaARController.WorldCenterMode.SPECIFIC_TARGET)
                    {
                        if (VuforiaManager.Instance.WorldCenter == (WorldCenterTrackableBehaviour)templateBehaviour)
                        {
                            VuforiaManager.Instance.WorldCenter           = surfaceAbstractBehaviour;
                            this.mPreviouslySetWorldCenterSurfaceTemplate = templateBehaviour;
                        }
                        else if ((VuforiaManager.Instance.WorldCenter == null || VuforiaManager.Instance.WorldCenter.Equals(null)) && this.mPreviouslySetWorldCenterSurfaceTemplate == templateBehaviour)
                        {
                            VuforiaManager.Instance.WorldCenter = surfaceAbstractBehaviour;
                        }
                    }
                    return(surfaceAbstractBehaviour);
                }
                Debug.LogError("ReconstructionBehaviour.AssociateSurface: provided template needs to be a child of the Reconstruction object.");
            }
            return(null);
        }