Example #1
0
        public bool RequestMeshAsync(SurfaceData dataRequest, SurfaceObserver.SurfaceDataReadyDelegate onDataReady)
        {
            if (onDataReady == null)
            {
                throw new ArgumentNullException("onDataReady");
            }
            if (dataRequest.outputMesh == null)
            {
                throw new ArgumentNullException("dataRequest.outputMesh");
            }
            if (dataRequest.outputAnchor == null)
            {
                throw new ArgumentNullException("dataRequest.outputAnchor");
            }
            if (dataRequest.outputCollider == null && dataRequest.bakeCollider)
            {
                throw new ArgumentException("dataRequest.outputCollider must be non-NULL if dataRequest.bakeCollider is true", "dataRequest.outputCollider");
            }
            if ((double)dataRequest.trianglesPerCubicMeter < 0.0)
            {
                throw new ArgumentException("dataRequest.trianglesPerCubicMeter must be greater than zero", "dataRequest.trianglesPerCubicMeter");
            }
            bool flag = SurfaceObserver.Internal_AddToWorkQueue(this.m_Observer, onDataReady, dataRequest.id.handle, dataRequest.outputMesh, dataRequest.outputAnchor, dataRequest.outputCollider, dataRequest.trianglesPerCubicMeter, dataRequest.bakeCollider);

            if (!flag)
            {
                Debug.LogError("RequestMeshAsync has failed.  Is your surface ID valid?");
            }
            return(flag);
        }
Example #2
0
        private IntPtr Internal_Create()
        {
            IntPtr result;

            SurfaceObserver.INTERNAL_CALL_Internal_Create(this, out result);
            return(result);
        }
 public void Clear()
 {
     m_Component       = null;
     m_OnDataReady     = null;
     m_GetHighestPri   = null;
     m_SurfaceObserver = null;
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     Observer = new UnityEngine.XR.WSA.SurfaceObserver();
     Observer.SetVolumeAsAxisAlignedBox(Vector3.zero, BoundingVolume);
     surfaces         = new Dictionary <int, GameObject>();
     surfaceDataQueue = new Queue <UnityEngine.XR.WSA.SurfaceData>();
     UpdateSurfaceObserver();
 }
Example #5
0
 public void Update(SurfaceObserver.SurfaceChangedDelegate onSurfaceChanged)
 {
     if (onSurfaceChanged == null)
     {
         throw new ArgumentNullException("onSurfaceChanged");
     }
     SurfaceObserver.Internal_Update(this.m_Observer, onSurfaceChanged);
 }
Example #6
0
 public void Dispose()
 {
     if (this.m_Observer != IntPtr.Zero)
     {
         SurfaceObserver.Destroy(this.m_Observer);
         this.m_Observer = IntPtr.Zero;
     }
     GC.SuppressFinalize(this);
 }
            public SurfaceObserver                             m_SurfaceObserver; // scripting API observer

            SMComponentRecord(
                SpatialMappingBase comp,
                SpatialMappingBase.SurfaceDataReadyCallback onDataReady,
                GetHighestPriorityCallback getHighestPri,
                SurfaceObserver observer)
            {
                m_Component       = comp;
                m_OnDataReady     = onDataReady;
                m_GetHighestPri   = getHighestPri;
                m_SurfaceObserver = observer;
            }
        protected virtual void Start()
        {
            observerId     = s_ObserverIdCounter++;
            surfaceObjects = new Dictionary <int, Surface>();
            selectedCamera = Camera.main;

            // Guarantee we update immediately when the component starts up.
            nextSurfaceChangeUpdateTime = float.MinValue;

            surfaceObserver = new SurfaceObserver();
            SpatialMappingContext.Instance.RegisterComponent(this, OnSurfaceDataReady, TryGetHighestPriorityRequest, surfaceObserver);
            bounds = new Bounds(this.transform.position, halfBoxExtents);

            UpdatePosition();
        }
 private extern static void INTERNAL_CALL_Internal_SetVolumeAsSphere(SurfaceObserver self, IntPtr observer, ref Vector3 origin, float radiusMeters);
 private extern static void INTERNAL_CALL_Internal_SetVolumeAsOrientedBox(SurfaceObserver self, IntPtr observer, ref Vector3 origin, ref Vector3 extents, ref Quaternion orientation);
 private extern static void INTERNAL_CALL_Internal_SetVolumeAsAxisAlignedBox(SurfaceObserver self, IntPtr observer, ref Vector3 origin, ref Vector3 extents);
 private extern static void INTERNAL_CALL_Internal_Create(SurfaceObserver self, out IntPtr value);
Example #13
0
 private void Internal_SetVolumeAsSphere(IntPtr observer, Vector3 origin, float radiusMeters)
 {
     SurfaceObserver.INTERNAL_CALL_Internal_SetVolumeAsSphere(this, observer, ref origin, radiusMeters);
 }
Example #14
0
 private void Internal_SetVolumeAsOrientedBox(IntPtr observer, Vector3 origin, Vector3 extents, Quaternion orientation)
 {
     SurfaceObserver.INTERNAL_CALL_Internal_SetVolumeAsOrientedBox(this, observer, ref origin, ref extents, ref orientation);
 }
Example #15
0
 private void Internal_SetVolumeAsAxisAlignedBox(IntPtr observer, Vector3 origin, Vector3 extents)
 {
     SurfaceObserver.INTERNAL_CALL_Internal_SetVolumeAsAxisAlignedBox(this, observer, ref origin, ref extents);
 }
        private int m_NextIndex = 0;                                                                // next index for the m_InFlightRequests array

        // Add the specified component to the list of components with its delegates
        // and scripting API observer.  Components are required to register with
        // the context prior to their first surface bake request.  This method will
        // throw ArgumentException if this component already exists in the list
        // ArgumentNullException if any of the parameters are missing.
        public void RegisterComponent(SpatialMappingBase smComponent, SpatialMappingBase.SurfaceDataReadyCallback onDataReady, GetHighestPriorityCallback getHighestPri, SurfaceObserver observer)
        {
            if (smComponent == null)
            {
                throw new ArgumentNullException("smComponent");
            }
            if (onDataReady == null)
            {
                throw new ArgumentNullException("onDataReady");
            }
            if (getHighestPri == null)
            {
                throw new ArgumentNullException("getHighestPri");
            }
            if (observer == null)
            {
                throw new ArgumentNullException("observer");
            }
            SMComponentRecord findResult = m_Components.Find(record => record.m_Component == smComponent);

            if (findResult.m_Component != null)
            {
                throw new ArgumentException("RegisterComponent on a component already registered!");
            }
            SMComponentRecord rec;

            rec.m_Component       = smComponent;
            rec.m_OnDataReady     = onDataReady;
            rec.m_GetHighestPri   = getHighestPri;
            rec.m_SurfaceObserver = observer;
            m_Components.Add(rec);
        }