/// <summary>
        /// Sends the observations using the mesh data contained within the configured 3D model.
        /// </summary>
        private void SendMeshObjects()
        {
            if (!sendObservations)
            {
                return;
            }

            if (spatialMeshObject != null)
            {
                MeshFilter[] meshFilters = spatialMeshObject.GetComponentsInChildren <MeshFilter>();
                for (int i = 0; i < meshFilters.Length; i++)
                {
                    SpatialAwarenessMeshObject meshObject = SpatialAwarenessMeshObject.Create(
                        meshFilters[i].sharedMesh,
                        MeshPhysicsLayer,
                        $"Spatial Object Mesh {currentMeshId}",
                        currentMeshId,
                        ObservedObjectParent);

                    meshObject.GameObject.transform.localPosition = meshFilters[i].transform.position;
                    meshObject.GameObject.transform.localRotation = meshFilters[i].transform.rotation;

                    ApplyMeshMaterial(meshObject);

                    meshes.Add(currentMeshId, meshObject);

                    meshEventData.Initialize(this, currentMeshId, meshObject);
                    SpatialAwarenessSystem?.HandleEvent(meshEventData, OnMeshAdded);

                    currentMeshId++;
                }
            }

            sendObservations = false;
        }
        /// <inheritdoc />
        public void RaiseMeshAdded(IMixedRealitySpatialMeshObserver observer, SpatialMeshObject spatialMeshObject)
        {
            // Parent the mesh object
            spatialMeshObject.GameObject.transform.parent = SpatialMeshesParent.transform;

            meshEventData.Initialize(observer, spatialMeshObject.Id, spatialMeshObject);
            HandleEvent(meshEventData, OnMeshAdded);
        }
        /// <inheritdoc />
        public void RaiseSurfaceAdded(int surfaceId, GameObject surfaceObject)
        {
            if (!UseSurfaceFindingSystem)
            {
                return;
            }

            surfaceFindingEventData.Initialize(this, surfaceId, surfaceObject);
            HandleEvent(surfaceFindingEventData, OnSurfaceAdded);
        }
        /// <inheritdoc />
        public void RaiseMeshAdded(int meshId, GameObject mesh)
        {
            if (!UseMeshSystem)
            {
                return;
            }

            // Parent the mesh object
            mesh.transform.parent = MeshParent.transform;

            meshEventData.Initialize(this, meshId, mesh);
            HandleEvent(meshEventData, OnMeshAdded);
        }
 /// <inheritdoc />
 public void RaiseSurfaceAdded(IMixedRealitySurfaceObserver observer, int surfaceId, GameObject surfaceObject)
 {
     surfaceFindingEventData.Initialize(observer, surfaceId, surfaceObject);
     HandleEvent(surfaceFindingEventData, OnSurfaceAdded);
 }
Example #6
0
 /// <inheritdoc />
 public void RaiseMeshAdded(IMixedRealitySpatialAwarenessObserver observer, int meshId, SpatialAwarenessMeshObject meshObject)
 {
     meshEventData.Initialize(observer, meshId, meshObject);
     HandleEvent(meshEventData, OnMeshAdded);
 }
Example #7
0
 /// <summary>
 /// Sends SceneObject Added event via <see cref="IMixedRealitySpatialAwarenessObservationHandler{T}"/>
 /// </summary>
 /// <param name="sceneObj">The <see cref="SpatialAwarenessSceneObject"/> being created</param>
 /// <param name="id">the id associated with the <paramref name="sceneObj"/></param>
 protected virtual void SendSceneObjectAdded(SpatialAwarenessSceneObject sceneObj, Guid id)
 {
     // Send the mesh removed event
     sceneEventData.Initialize(this, id, sceneObj);
     SpatialAwarenessSystem?.HandleEvent(sceneEventData, OnSceneObjectAdded);
 }