Пример #1
0
 public override bool AddReconstruction(ReconstructionAbstractBehaviour reconstructionBehaviour)
 {
     if (this.mReconstructionBehaviours.Count == 0)
     {
         ReconstructionImpl reconstructionImpl = reconstructionBehaviour.Reconstruction as ReconstructionImpl;
         if (reconstructionImpl != null)
         {
             bool flag = VuforiaWrapper.Instance.SmartTerrainBuilderAddReconstruction(reconstructionImpl.NativePtr) == 1;
             if (flag)
             {
                 if (reconstructionImpl is ReconstructionFromTargetImpl)
                 {
                     (reconstructionImpl as ReconstructionFromTargetImpl).CanAutoSetInitializationTarget = false;
                 }
                 this.mReconstructionBehaviours.Add(reconstructionBehaviour);
                 SmartTerrainTrackableBehaviour[] componentsInChildren = reconstructionBehaviour.GetComponentsInChildren <SmartTerrainTrackableBehaviour>();
                 for (int i = 0; i < componentsInChildren.Length; i++)
                 {
                     componentsInChildren[i].gameObject.SetActive(false);
                 }
             }
             else
             {
                 Debug.LogError("Could not add Reconstruction to SmartTerrainBuilder");
             }
             return(flag);
         }
     }
     else
     {
         Debug.LogError("Could not add Reconstruction to SmartTerrainBuilder, only one reconstruction can be added at a time");
     }
     return(false);
 }
Пример #2
0
 private void Awake()
 {
     this.mReconstructionBehaviour = base.GetComponent <ReconstructionAbstractBehaviour>();
     if (this.mReconstructionBehaviour == null)
     {
         Debug.LogError("ReconstructionFromTargetAbstractBehaviour: No ReconstructionAbstractBehaviour found!");
     }
     SmartTerrainTrackerARController.Instance.RegisterTrackerStartedCallback(new Action(this.OnTrackerStarted));
 }
Пример #3
0
        public PropAbstractBehaviour AssociateProp(PropAbstractBehaviour templateBehaviour, Prop newProp)
        {
            if (this.mActivePropBehaviours.ContainsKey(newProp.ID))
            {
                Debug.LogWarning("Prop has already an associated behaviour");
                return(null);
            }
            StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl;

            if (templateBehaviour != null)
            {
                if (templateBehaviour.transform.parent == base.transform)
                {
                    PropAbstractBehaviour propAbstractBehaviour = ReconstructionAbstractBehaviour.InstantiatePropBehaviour(templateBehaviour);
                    Transform             transform             = null;
                    if (newProp.Parent == null)
                    {
                        transform = base.transform;
                    }
                    else if (newProp.Parent is Surface)
                    {
                        if (this.mActiveSurfaceBehaviours.ContainsKey(newProp.Parent.ID))
                        {
                            transform = this.mActiveSurfaceBehaviours[newProp.Parent.ID].transform;
                        }
                        else
                        {
                            Debug.LogError("Parent Surface with id " + newProp.Parent.ID + " could not be found");
                        }
                    }
                    else if (newProp.Parent is Prop)
                    {
                        if (this.mActivePropBehaviours.ContainsKey(newProp.Parent.ID))
                        {
                            transform = this.mActivePropBehaviours[newProp.Parent.ID].transform;
                        }
                        else
                        {
                            Debug.LogError("Parent Prop with id " + newProp.Parent.ID + " could not be found");
                        }
                    }
                    if (transform != null)
                    {
                        propAbstractBehaviour.transform.parent = transform;
                    }
                    propAbstractBehaviour.gameObject.SetActive(true);
                    this.AssociatePropBehaviour(newProp, propAbstractBehaviour);
                    this.mActivePropBehaviours.Add(newProp.ID, propAbstractBehaviour);
                    stateManagerImpl.RegisterExternallyManagedTrackableBehaviour(propAbstractBehaviour);
                    return(propAbstractBehaviour);
                }
                Debug.LogError("ReconstructionBehaviour.AssociateProp: provided template needs to be a child of the Reconstruction object.");
            }
            return(null);
        }
Пример #4
0
 public override bool RemoveReconstruction(ReconstructionAbstractBehaviour reconstruction)
 {
     if (this.mReconstructionBehaviours.Contains(reconstruction))
     {
         bool result = false;
         ReconstructionImpl reconstructionImpl = reconstruction.Reconstruction as ReconstructionImpl;
         if (reconstructionImpl != null)
         {
             result = (VuforiaWrapper.Instance.SmartTerrainBuilderRemoveReconstruction(reconstructionImpl.NativePtr) == 1);
         }
         this.mReconstructionBehaviours.Remove(reconstruction);
         reconstruction.OnReconstructionRemoved();
         return(result);
     }
     return(false);
 }
Пример #5
0
 public override bool Deinit()
 {
     if (this.mIsInitialized)
     {
         ReconstructionAbstractBehaviour[] array = this.mReconstructionBehaviours.ToArray();
         for (int i = 0; i < array.Length; i++)
         {
             ReconstructionAbstractBehaviour reconstructionAbstractBehaviour = array[i];
             this.RemoveReconstruction(reconstructionAbstractBehaviour);
             this.DestroyReconstruction(reconstructionAbstractBehaviour.Reconstruction);
         }
         this.mReconstructionBehaviours.Clear();
         bool expr_53 = VuforiaWrapper.Instance.SmartTerrainTrackerDeinitBuilder() == 1;
         if (expr_53)
         {
             this.mIsInitialized = false;
         }
         return(expr_53);
     }
     return(false);
 }
Пример #6
0
        private void UpdateSurfaces(VuforiaManagerImpl.SmartTerrainRevisionData[] smartTerrainRevisions, VuforiaManagerImpl.SurfaceData[] updatedSurfaceData)
        {
            List <Surface> list  = new List <Surface>();
            List <Surface> list2 = new List <Surface>();
            List <Surface> list3 = new List <Surface>();

            for (int i = 0; i < updatedSurfaceData.Length; i++)
            {
                VuforiaManagerImpl.SurfaceData surfaceData = updatedSurfaceData[i];
                bool        flag = false;
                SurfaceImpl surfaceImpl;
                bool        flag2;
                if (!this.mSurfaces.ContainsKey(surfaceData.id))
                {
                    surfaceImpl = new SurfaceImpl(surfaceData.id, this.FindSmartTerrainTrackable(surfaceData.parentID));
                    this.mSurfaces.Add(surfaceData.id, surfaceImpl);
                    list.Add(surfaceImpl);
                    flag2 = true;
                    flag  = true;
                }
                else
                {
                    surfaceImpl = (SurfaceImpl)this.mSurfaces[surfaceData.id];
                    flag2       = (surfaceData.revision != surfaceImpl.MeshRevision);
                }
                if (flag2)
                {
                    Mesh mesh = MeshUtils.UpdateMesh(surfaceData.meshData, surfaceImpl.GetMesh(), false, true);
                    if (flag)
                    {
                        surfaceImpl.SetLocalPose(surfaceData.localPose);
                    }
                    if (mesh != null)
                    {
                        Mesh navMesh = null;
                        if (this.mReconstruction.IsNavMeshUpdating())
                        {
                            navMesh = MeshUtils.UpdateMesh(surfaceData.navMeshData, surfaceImpl.GetNavMesh(), true, true);
                        }
                        int[] meshBoundaries = ReconstructionAbstractBehaviour.ReadMeshBoundaries(surfaceData.numBoundaryIndices, surfaceData.meshBoundaryArray);
                        surfaceImpl.SetMesh(surfaceData.revision, mesh, navMesh, meshBoundaries);
                    }
                    RectangleData boundingBox  = surfaceData.boundingBox;
                    Rect          boundingBox2 = new Rect(boundingBox.leftTopX, boundingBox.leftTopY, boundingBox.rightBottomX - boundingBox.leftTopX, boundingBox.rightBottomY - boundingBox.leftTopY);
                    surfaceImpl.SetBoundingBox(boundingBox2);
                    list2.Add(surfaceImpl);
                }
                else
                {
                    Debug.LogError("Inconsistency: received updated Surface, but mesh revision is unchanged!");
                }
            }
            int[] array = new int[this.mSurfaces.Count];
            this.mSurfaces.Keys.CopyTo(array, 0);
            int[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                int  num   = array2[i];
                bool flag3 = false;
                for (int j = 0; j < smartTerrainRevisions.Length; j++)
                {
                    if (smartTerrainRevisions[j].id == num)
                    {
                        flag3 = true;
                    }
                }
                if (!flag3)
                {
                    list3.Add(this.mSurfaces[num]);
                    ((SurfaceImpl)this.mSurfaces[num]).DestroyMesh();
                    this.mSurfaces.Remove(num);
                }
            }
            this.UnregisterDeletedSurfaces(list3);
            foreach (Surface current in list3)
            {
                if (current.Parent != null)
                {
                    ((SmartTerrainTrackableImpl)current.Parent).RemoveChild(current);
                }
            }
            foreach (Surface current2 in list)
            {
                if (current2.Parent != null)
                {
                    ((SmartTerrainTrackableImpl)current2.Parent).AddChild(current2);
                }
            }
            this.NotifySurfaceEventHandlers(list, list2, list3);
        }
Пример #7
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);
        }
Пример #8
0
 public abstract bool RemoveReconstruction(ReconstructionAbstractBehaviour reconstruction);
Пример #9
0
 public abstract bool AddReconstruction(ReconstructionAbstractBehaviour reconstructionBehaviour);