예제 #1
0
    public void Start()
    {
        surfaceObserver = new SurfaceObserver();

        surfaceObserver.SetVolumeAsAxisAlignedBox(Vector3.zero, new Vector3(3, 3, 3));
        StartCoroutine(UpdateLoop());
    }
 /// <summary>
 /// Standard initialization method creating our properties
 /// </summary>
 protected virtual void Start()
 {
     surfaceObserver = new SurfaceObserver();
     UpdateSurfaceObserverPosition();
     StartCoroutine(UpdateLoop());
     bounds = new Bounds(transform.position, Extents);
 }
예제 #3
0
 // Use this for initialization
 void Awake()
 {
     observer = new SurfaceObserver();
     observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Vector3.one * 3);
     spatialMeshObjects = new Dictionary <SurfaceId, GameObject>();
     StartCoroutine(OracleUpdate());
 }
        /// <summary>
        /// Cleans up all memory and objects associated with the observer.
        /// </summary>
        public void CleanupObserver()
        {
#if UNITY_WSA
            StopObserving();

            if (observer != null)
            {
                observer.Dispose();
                observer = null;
            }

            if (outstandingMeshRequest != null)
            {
                CleanUpSurface(outstandingMeshRequest.Value);
                outstandingMeshRequest = null;
            }

            if (spareSurfaceObject != null)
            {
                CleanUpSurface(spareSurfaceObject.Value);
                spareSurfaceObject = null;
            }

            Cleanup();
#endif
        }
예제 #5
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
#if UNITY_METRO && !UNITY_EDITOR
            if (observer == null)
            {
                observer = new SurfaceObserver();
                try
                {
                    observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Extents);
                }
                catch (Exception e)
                {
                }
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
#endif
        }
예제 #6
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                // on device, this isn't necessary, but sometimes in the emulator the observer
                // won't realize that it hasn't already sent you the surfaces, and since the surfaces
                // don't really get updated in the emulator you'll end up getting no surfaces at all.
                if (surfaces.Count == 0)
                {
                    if (observer != null)
                    {
                        observer.Dispose();
                        observer = null;
                    }

                    observer = new SurfaceObserver();
                }

                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
        }
        /// <summary>
        /// Cleans up all memory and objects associated with the observer.
        /// </summary>
        public void CleanupObserver()
        {
            if (observer != null)
            {
                StopObserving();

                // Clear out all memory allocated the observer
                observer.Dispose();
                observer = null;

                foreach (KeyValuePair <int, GameObject> surfaceRef in surfaces)
                {
                    CleanupSurface(surfaceRef.Value);
                }

                // Get all valid mesh filters for observed surfaces and destroy them
                List <MeshFilter> meshFilters = GetMeshFilters();
                for (int i = 0; i < meshFilters.Count; i++)
                {
                    Destroy(meshFilters[i].sharedMesh);
                }
                meshFilters.Clear();

                // Cleanup all available surfaces
                foreach (GameObject availableSurface in availableSurfaces)
                {
                    Destroy(availableSurface);
                }
                availableSurfaces.Clear();
                surfaces.Clear();
            }
        }
예제 #8
0
        protected override void Awake()
        {
            base.Awake();

            observer       = new SurfaceObserver();
            ObserverState  = ObserverStates.Stopped;
            observerOrigin = Vector3.zero;
        }
        private void Setup()
        {
#if UNITY_WSA
            Debug.Assert(observer == null, "Setting up an already setup FrozenSpatialMapping");
            observer = new SurfaceObserver();
            observer.SetVolumeAsSphere(Vector3.zero, Radius);
#endif // UNITY_WSA
        }
 /// <summary>
 /// Implements proper cleanup of the SurfaceObserver.
 /// </summary>
 private void DisposeObserver()
 {
     if (observer != null)
     {
         observer.Dispose();
         observer = null;
     }
 }
예제 #11
0
 // Use this for initialization
 void Start()
 {
     Observer = new SurfaceObserver();
     Observer.SetVolumeAsAxisAlignedBox(Vector3.zero, BoundingVolume);
     surfaces         = new Dictionary <int, GameObject>();
     surfaceDataQueue = new Queue <SurfaceData>();
     UpdateSurfaceObserver();
 }
예제 #12
0
    // Use this for initialization
    void Start()
    {
        observer = new SurfaceObserver();
        // define a huge scan area to get every update
        observer.SetVolumeAsAxisAlignedBox(Vector3.zero, new Vector3(10000, 10000, 10000));

        lastUpdateTime = Time.realtimeSinceStartup;
    }
        protected override void Awake()
        {
            base.Awake();

            observer      = new SurfaceObserver();
            ObserverState = ObserverStates.Stopped;
            observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Extents);
        }
예제 #14
0
 void Start()
 {
     m_Observer = new SurfaceObserver();
     m_Observer.SetVolumeAsAxisAlignedBox(new Vector3(0.0f, 0.0f, 0.0f),
                                          new Vector3(SurfaceEntry.c_Extents, SurfaceEntry.c_Extents, SurfaceEntry.c_Extents));
     m_Surfaces       = new Dictionary <int, SurfaceEntry>();
     m_WaitingForBake = false;
     m_lastUpdateTime = 0.0f;
 }
예제 #15
0
 void Start()
 {
     m_Observer = new SurfaceObserver();
     m_Observer.SetVolumeAsSphere(new Vector3(0.0f, 0.0f, 0.0f), 200.0f);
     SurfacesList     = new List <SurfaceEntry>();
     m_Surfaces       = new Dictionary <int, SurfaceEntry>();
     m_WaitingForBake = false;
     m_lastUpdateTime = 0.0f;
 }
예제 #16
0
 void Start()
 {
     PMT        = PhotonMeshTransfer.getSingleton();
     m_Observer = new SurfaceObserver();
     m_Observer.SetVolumeAsSphere(new Vector3(0.0f, 0.0f, 0.0f), 200.0f);
     SurfacesList     = new List <SurfaceEntry>();
     m_Surfaces       = new Dictionary <int, SurfaceEntry>();
     m_WaitingForBake = false;
     m_lastUpdateTime = 0.0f;
     S = this;
 }
예제 #17
0
 private void Teardown()
 {
     Debug.Assert(observer != null, "Tearing down FrozenSpatialMapping that isn't set up.");
     foreach (var surface in surfaces.Values)
     {
         Destroy(surface.surfaceObject);
     }
     surfaces.Clear();
     observer.Dispose();
     observer = null;
 }
예제 #18
0
 public void Startup(NetworkService service)
 {
     // Convert the layer into a mask so it can be used to Raycast against.
     PhysicsRaycastMask = 1 << PhysicsLayer;
     Observer           = new SurfaceObserver();
     Observer.SetVolumeAsAxisAlignedBox(Vector3.zero, BoundingVolume);
     surfaces         = new Dictionary <int, GameObject>();
     surfaceDataQueue = new Queue <SurfaceData>();
     UpdateSurfaceObserver();
     status = ManagerStatus.Started;
 }
        /// <summary>
        /// Called when the GameObject is unloaded.
        /// </summary>
        private void OnDestroy()
        {
            // Stop the observer.
            StopObserving();

            observer.Dispose();
            observer = null;

            // Clear our surface mesh collection.
            surfaces.Clear();
        }
        public void Initialize(
            [Inject] ISpatialSurfaceFactory surfaceEntryFactory)
        {
            _surfaceObserver = new SurfaceObserver();

            UpdateBoundingVolume();

            _surfaceEntries      = new Dictionary <int, ISpatialSurface>();
            _surfaceEntryFactory = surfaceEntryFactory;

            _previousUpdate        = 0.0f;
            _meshRequestInProgress = false;
        }
예제 #21
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="priority"></param>
        /// <param name="profile"></param>
        public WindowsMixedRealitySpatialMeshObserver(string name, uint priority, WindowsMixedRealitySpatialMeshObserverProfile profile) : base(name, priority, profile)
        {
            if (MixedRealityToolkit.SpatialAwarenessSystem == null)
            {
                throw new Exception("Missing a registered spatial awareness system!");
            }

#if UNITY_WSA
            observer = new SurfaceObserver();

            // Apply the initial observer volume settings.
            ConfigureObserverVolume(ObserverOrigin, ObservationExtents);
#endif // UNITY_WSA
        }
예제 #22
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="priority"></param>
        /// <param name="profile"></param>
        public WindowsMixedRealitySpatialMeshObserver(string name, uint priority, WindowsMixedRealitySpatialMeshObserverProfile profile) : base(name, priority, profile)
        {
#if UNITY_WSA
#if UNITY_EDITOR
            if (!UnityEditor.PlayerSettings.WSA.GetCapability(UnityEditor.PlayerSettings.WSACapability.SpatialPerception))
            {
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.SpatialPerception, true);
            }
#endif // UNITY_EDITOR
            if (observer == null)
            {
                observer = new SurfaceObserver();
            }
#endif // UNITY_WSA
        }
예제 #23
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        surfaceObserver = new SurfaceObserver();
        surfaceObserver.SetVolumeAsAxisAlignedBox(Vector3.zero, new Vector3(4.0f, 4.0f, 4.0f));
        //surfaceObserver.SetVolumeAsSphere(Vector3.zero, 2.0f);
    }
예제 #24
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new SurfaceObserver();
                SwitchObservedVolume();
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
        }
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new SurfaceObserver();
                observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Extents);
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
        }
        /// <summary>
        /// Creates the surface observer and handles the desired startup behavior.
        /// </summary>
        private void CreateObserver()
        {
            if (SpatialAwarenessSystem == null)
            {
                return;
            }

            if (observer == null)
            {
                observer = new SurfaceObserver();
                ConfigureObserverVolume();

                if (StartupBehavior == AutoStartBehavior.AutoStart)
                {
                    Resume();
                }
            }
        }
예제 #27
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new SurfaceObserver();
                observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Extents);
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }

            PhotonNetwork.Instantiate("MyPrefabName", new Vector3(0, 0, 0), Quaternion.identity, 0);
        }
예제 #28
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
#if UNITY_WSA
            if (observer == null)
            {
                observer = new SurfaceObserver();
                SwitchObservedVolume();
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = -timeBetweenUpdates;
            }
#endif
        }
예제 #29
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new SurfaceObserver();
                //Vector3 sceneOrigin = Camera.main.transform.position;
                //observer.SetVolumeAsAxisAlignedBox(sceneOrigin, Extents);
                observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Extents);
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
        }
        /// <summary>
        /// Creates the surface observer and handles the desired startup behavior.
        /// </summary>
        protected override void CreateObserver()
        {
            if (SpatialAwarenessSystem == null)
            {
                return;
            }

#if UNITY_WSA
            if (observer == null)
            {
                observer = new SurfaceObserver();
                ConfigureObserverVolume();

                if (StartupBehavior == AutoStartBehavior.AutoStart)
                {
                    Resume();
                }
            }
#endif // UNITY_WSA
        }