コード例 #1
0
        public void StartPulse(Vector3 center)
        {
            Debug.Log("Started pulsing");
            _pulseMaterial.SetVector("_Center", new Vector4(center.x, center.y, center.z, -1));
            _pulseMaterial.SetFloat("_Radius", 0);


            _spatialMappingManager.SetSurfaceMaterial(_pulseMaterial);

            _timeSinceLastPulse = 0;
            _isPulsing          = true;
        }
コード例 #2
0
    private void Start()
    {
        // Start scanning with the SpatialUnderstanding module
        m_state = State.Scanning;
        m_spatialMappingManager = SpatialMappingManager.Instance;
        if (!m_spatialMappingManager.IsObserverRunning())
        {
            m_spatialMappingManager.StartObserver();
        }
        if (visualizeSpatialMesh && spatialMeshVisibleMaterial != null)
        {
            m_spatialMappingManager.SetSurfaceMaterial(spatialMeshVisibleMaterial);
            m_spatialMappingManager.DrawVisualMeshes = true;
        }
        m_spatialUnderstanding = SpatialUnderstanding.Instance;
        m_spatialUnderstanding.ScanStateChanged += OnScanStateChanged;
        m_spatialUnderstanding.RequestBeginScanning();

        // Subscribe to tap gesture
        m_gestureRecognizer = new GestureRecognizer();
        m_gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap);
        m_gestureRecognizer.TappedEvent += OnTapEvent;
        m_gestureRecognizer.StartCapturingGestures();

        // Pin the query results memory and get a native pointer
        m_queryResultsPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(m_queryResults);
    }
コード例 #3
0
 public void StartScanning()
 {
     // Start spatial mapping (SpatialUnderstanding requires this, too)
     if (!m_spatialMappingManager.IsObserverRunning())
     {
         m_spatialMappingManager.StartObserver();
     }
     m_spatialMappingManager.DrawVisualMeshes = visualizeSpatialMeshes;
     m_spatialUnderstanding.ScanStateChanged += OnScanStateChanged;
     m_spatialUnderstanding.RequestBeginScanning();
     m_spatialUnderstandingState = SpatialUnderstandingState.Scanning;
     m_spatialMappingManager.SetSurfaceMaterial(renderingMaterial);
 }
コード例 #4
0
    //TODO: if time limited, take an optional callback
    public void StartScanning()
    {
        // Start spatial mapping (SpatialUnderstanding requires this, too)
        if (!m_spatialMappingManager.IsObserverRunning())
        {
            m_spatialMappingManager.StartObserver();
        }

        // If we are only using spatial mapping, visualize the meshes during the scanning
        // phase
        if (useSpatialUnderstanding)
        {
            m_spatialMappingManager.DrawVisualMeshes = visualizeSpatialMeshes;
            m_spatialUnderstanding.ScanStateChanged += OnScanStateChanged;
            m_spatialUnderstanding.RequestBeginScanning();
            m_spatialUnderstandingState = SpatialUnderstandingState.Scanning;
        }
        else
        {
            m_spatialMappingManager.DrawVisualMeshes = true;
        }
        m_spatialMappingManager.SetSurfaceMaterial(renderingMaterial);
    }
コード例 #5
0
    private void OnPlanesComplete(object source, System.EventArgs args)
    {
        SpatialMappingManager mapper = SpatialMappingManager.Instance;

        if (!visualizeSpatialMeshes)
        {
            mapper.SetSurfaceMaterial(spatialMeshOcclusionMaterial);
        }
        SurfacePlaneDeformationManager.Instance.SetSpatialMeshFilters(mapper.GetMeshFilters());
        if (visualizeSurfacePlanes)
        {
            SetPlanesVisible(true);
        }
    }
コード例 #6
0
        void InitializeRoom()
        {
            // if the spatial mapping object doesn't exist, create it
            if (spatialMappingObj == null)
            {
                InstantiateSpatialMappingPrefab();
            }

            // move the room mesh over to the spatialmappingobj
            ObjectSurfaceObserver surfaceObserver = spatialMappingObj.GetComponent <ObjectSurfaceObserver>();

            surfaceObserver.roomModel = Resources.Load <GameObject>(Constants.Folders.RoomMeshFolderPath + Constants.Names.RoomMeshName + Constants.Suffixes.RoomMeshSuffix);
            // set the material that the spatialmapping object will use to render it
            SpatialMappingManager mappingManager = spatialMappingObj.GetComponent <SpatialMappingManager>();

            mappingManager.SetSurfaceMaterial(CreateRoomMeshMaterial());
        }
コード例 #7
0
    private void Start()
    {
        // Start scanning
        m_state = State.Scanning;
        SpatialMappingManager mapper = SpatialMappingManager.Instance;

        if (!mapper.IsObserverRunning())
        {
            mapper.StartObserver();
        }
        mapper.SetSurfaceMaterial(spatialMeshScanningMaterial);

        // Subscribe to tap gesture
        m_gestureRecognizer = new GestureRecognizer();
        m_gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap);
        m_gestureRecognizer.TappedEvent += OnTapEvent;
        m_gestureRecognizer.StartCapturingGestures();
    }
コード例 #8
0
    private void Update()
    {
        if (m_scanningComplete)
        {
            return;
        }
        SpatialUnderstandingDll.Imports.PlayspaceStats stats;
        switch (m_spatialUnderstandingState)
        {
        case State.StartScanning:
            // Start spatial mapping (SpatialUnderstanding requires this, too)
            if (!m_spatialMappingManager.IsObserverRunning())
            {
                m_spatialMappingManager.StartObserver();
            }
            m_spatialMappingManager.DrawVisualMeshes = visualizeSpatialMeshes;
            m_spatialUnderstanding.ScanStateChanged += OnScanStateChanged;
            m_spatialUnderstanding.RequestBeginScanning();
            m_spatialMappingManager.SetSurfaceMaterial(renderingMaterial);
            m_spatialUnderstandingState = State.Scanning;
            break;

        case State.Scanning:
            if (GetStats(out stats))
            {
                Debug.Log("NumFloor=" + stats.NumFloor + ", NumWallX-=" + stats.NumWall_XNeg + ", NumWallX+=" + stats.NumWall_XPos + ", NumWallZ-=" + stats.NumWall_ZNeg + ", NumWallZ+=" + stats.NumWall_ZPos);
            }
            break;

        case State.FinalizeScan:
            //TODO: timeout?
            // Note: this is pretty subtle -- ScanStatsReportStillWorking is *not*
            // automatically updated. It reuses a cached object. GetStats() will
            // fetch the latest object by calling the appropriate query function.
            GetStats(out stats);
            if (!m_spatialUnderstanding.ScanStatsReportStillWorking)
            {
                Debug.Log("Finalizing scan...");
                m_spatialUnderstanding.RequestFinishScan();
                m_spatialUnderstandingState = State.WaitingForScanCompletion;
            }
            break;

        case State.WaitingForMeshImport:
            //TODO: timeout?
            if (m_spatialUnderstanding.UnderstandingCustomMesh.IsImportActive == false)
            {
                List <MeshFilter> meshFilters = m_spatialUnderstanding.UnderstandingCustomMesh.GetMeshFilters();
                Debug.Log("Found " + meshFilters.Count + " meshes (import active=" + m_spatialUnderstanding.UnderstandingCustomMesh.IsImportActive + ")");
                if (!visualizeSpatialMeshes)
                {
                    DisableSpatialMappingMeshes();
                }
                ApplyVisualizationSettings();
                //SurfacePlaneDeformationManager.Instance.SetSpatialMeshFilters(meshFilters);
                if (buildNavMesh)
                {
                    m_navMeshBuilder.AddSourceMeshes(meshFilters, m_spatialUnderstanding.transform);
                }
                m_spatialUnderstandingState = State.WaitingForPlacementSolverInit;
            }
            break;

        case State.WaitingForPlacementSolverInit:
            //TODO: error checking and timeout?
            bool navMeshFinished = !buildNavMesh || (buildNavMesh && m_navMeshBuilder.isFinished);
            if (!m_solverInitCalled)
            {
                m_solverInitCalled = true;
                StartCoroutine(InitSolverCoroutine());
                if (buildNavMesh)
                {
                    m_navMeshBuilder.BuildAsync();
                }
            }
            else if (m_solverInitialized && navMeshFinished)
            {
                ApplyStaticBatching();
                m_scanningComplete          = true;
                m_spatialUnderstandingState = State.Finished;
                if (OnScanComplete != null)
                {
                    OnScanComplete();
                }
            }
            break;

        default:
            break;
        }
    }
コード例 #9
0
    private void Update()
    {
        if (m_scanningComplete)
        {
            return;
        }
        switch (m_spatialUnderstandingState)
        {
        case SpatialUnderstandingState.StartScanning:
            // Start spatial mapping (SpatialUnderstanding requires this, too)
            if (!m_spatialMappingManager.IsObserverRunning())
            {
                m_spatialMappingManager.StartObserver();
            }
            m_spatialMappingManager.DrawVisualMeshes = visualizeSpatialMeshes;
            m_spatialUnderstanding.ScanStateChanged += OnScanStateChanged;
            m_spatialUnderstanding.RequestBeginScanning();
            m_spatialMappingManager.SetSurfaceMaterial(renderingMaterial);
            m_spatialUnderstandingState = SpatialUnderstandingState.Scanning;
            break;

        case SpatialUnderstandingState.FinalizeScan:
            //TODO: timeout?
            if (!m_spatialUnderstanding.ScanStatsReportStillWorking)
            {
                Debug.Log("Finalizing scan...");
                m_spatialUnderstanding.RequestFinishScan();
                m_spatialUnderstandingState = SpatialUnderstandingState.WaitingForScanCompletion;
            }
            break;

        case SpatialUnderstandingState.WaitingForMeshImport:
            //TODO: timeout?
            if (m_spatialUnderstanding.UnderstandingCustomMesh.IsImportActive == false)
            {
                Debug.Log("Found " + m_spatialUnderstanding.UnderstandingCustomMesh.GetMeshFilters().Count + " meshes (import active=" + m_spatialUnderstanding.UnderstandingCustomMesh.IsImportActive + ")");
                if (!visualizeSpatialMeshes)
                {
                    DisableSpatialMappingMeshes();
                }
                ApplyVisualizationSettings();
                //SurfacePlaneDeformationManager.Instance.SetSpatialMeshFilters(m_spatialUnderstanding.UnderstandingCustomMesh.GetMeshFilters());
                m_spatialUnderstandingState = SpatialUnderstandingState.WaitingForPlacementSolverInit;
            }
            break;

        case SpatialUnderstandingState.WaitingForPlacementSolverInit:
            //TODO: error checking and timeout?
            if (!m_placementSolverInitialized)
            {
                m_placementSolverInitialized = (SpatialUnderstandingDllObjectPlacement.Solver_Init() == 1);
                Debug.Log("Placement Solver initialization " + (m_placementSolverInitialized ? "succeeded" : "FAILED"));
                if (m_placementSolverInitialized)
                {
                    if (OnScanComplete != null)
                    {
                        OnScanComplete();
                    }
                    m_scanningComplete          = true;
                    m_spatialUnderstandingState = SpatialUnderstandingState.Finished;
                }
            }
            break;

        default:
            break;
        }
    }