private void ReconstructMesh() { // Convert buffers from interop to mesh // Get verts and tris IntPtr verts; IntPtr inds; int num_verts; int num_tris; ReconstructionInterop.GetReconstructionMesh( out verts, out num_verts, out inds, out num_tris); if (num_verts <= 0 && num_tris <= 0) { return; } // Copy data into managed buffers double[] result = new double[num_verts]; Marshal.Copy(verts, result, 0, num_verts); int[] triangles = new int[num_tris]; Marshal.Copy(inds, triangles, 0, num_tris); _meshGenerator.UpdateMeshes(result, triangles); }
/// <summary> /// Resets the reconstruction mesh. /// </summary> public void ResetReconstruction() { if (_currentState == ReconstructionState.Scanning && _pause) { _meshGenerator.ResetMeshes(); ReconstructionInterop.ResetReconstruction(); _reconstructionReset.Invoke(); } else { Debug.LogWarning("Reconstruction can only be reset if it is initialized and paused."); } }
private void InitReconstructionForFirstTime() { _reconstruction = new GameObject("Reconstruction"); _reconstruction.transform.position = Vector3.zero; _reconstruction.transform.rotation = Quaternion.identity; _meshGenerator.Parent = _reconstruction.transform; ReconstructionInterop.ConnectReconstruction(); ReconstructionInterop.StartReconstruction(); Scan(); _pause = false; _reconstructionStarted.Invoke(); }
/// <summary> /// Toggles on and off the reconstruction process. /// </summary> public void PauseResumeReconstruction() { if (_currentState == ReconstructionState.Scanning) { ReconstructionInterop.PauseReconstruction(); _pause = !_pause; if (_pause) { _reconstructionPaused.Invoke(); UpdateReconstructionMeshes(); } else { _reconstructionResumed.Invoke(); } } else { Debug.LogWarning("The reconstruction process is not currently initialized."); } }