private void ConfigureSession(bool clearPlanes) { ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); if (mPlaneDetectionToggle.GetComponent <Toggle>().isOn) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) { config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical; } else { config.planeDetection = UnityARPlaneDetection.Horizontal; } mPNPlaneManager.StartPlaneDetection(); } else { config.planeDetection = UnityARPlaneDetection.None; if (clearPlanes) { mPNPlaneManager.ClearPlanes(); } } config.alignment = UnityARAlignment.UnityARAlignmentGravity; config.getPointCloudData = true; config.enableLightEstimation = true; mSession.RunWithConfig(config); }
public JObject GetCurrentPlaneList() { LinkedList <ARPlaneAnchorGameObject> list = placenoteARAnchorManager.GetCurrentPlaneAnchors(); PlaneMeshList saveList = new PlaneMeshList(); saveList.meshList = new ARPlaneMesh[list.Count]; int planeNum = 0; Debug.Log("Creating list of + " + list.Count.ToString() + " planes"); foreach (var plane in list) { ARPlaneMesh planeSaved = new ARPlaneMesh(); planeSaved.transform = plane.planeAnchor.transform; planeSaved.center = plane.planeAnchor.center; planeSaved.extent = plane.planeAnchor.extent; if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) { planeSaved.vertices = plane.planeAnchor.planeGeometry.vertices; planeSaved.texture = plane.planeAnchor.planeGeometry.textureCoordinates; planeSaved.trIndices = plane.planeAnchor.planeGeometry.triangleIndices; planeSaved.boundaryVertices = plane.planeAnchor.planeGeometry.boundaryVertices; } planeSaved.id = plane.planeAnchor.identifier; saveList.meshList[planeNum] = planeSaved; planeNum++; } return(JObject.FromObject(saveList)); }
public void UpdateMesh(ARPlaneAnchor arPlaneAnchor) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) //otherwise we cannot access planeGeometry { if (arPlaneAnchor.planeGeometry.vertices.Length != planeMesh.vertices.Length || arPlaneAnchor.planeGeometry.textureCoordinates.Length != planeMesh.uv.Length || arPlaneAnchor.planeGeometry.triangleIndices.Length != planeMesh.triangles.Length) { planeMesh.Clear(); } //顯示ARKit平面 //if (GroundPlaneManager.instance.Status == GroundPlaneManagerStatus.GetingARKitGroundPlane || // arPlaneAnchor.identifier == GroundPlaneManager.instance.groundPlaneAnchorIdentifier) { // if(GroundPlaneManager.instance.Status == GroundPlaneManagerStatus.FinishCreateGroundMesh){ // }else{ // GetMesh(arPlaneAnchor); // } //} //if(GroundPlaneManager.instance.Status ==GroundPlaneManagerStatus.LoadFromSave){ // GetMesh(arPlaneAnchor); //} if (GroundPlaneManager.instance.Status == GroundPlaneManagerStatus.GetingARKitGroundPlane) { GetMesh(arPlaneAnchor); } planeMesh.RecalculateBounds(); planeMesh.RecalculateNormals(); } }
private void ConfigureSession(bool togglePlaneDetection, bool clearOldPlanes) { ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); if (togglePlaneDetection) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) { config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical; } else { config.planeDetection = UnityARPlaneDetection.Horizontal; } } else { config.planeDetection = UnityARPlaneDetection.None; } if (clearOldPlanes) { mPlaneGenerator.ClearPlanes(); } config.alignment = UnityARAlignment.UnityARAlignmentGravity; config.getPointCloudData = true; config.enableLightEstimation = true; UnityARSessionRunOption options = new UnityARSessionRunOption(); //options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking; options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors; mSession.RunWithConfigAndOptions(config, options); }
// Use this for initialization void Start() { loadedPlaneList = new LinkedList <GameObject>(); if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) { CapturedPlaneUtility.InitializePlanePrefab(meshPrefab); } else { CapturedPlaneUtility.InitializePlanePrefab(planePrefab); } }
public void UpdateMesh(ARPlaneAnchor arPlaneAnchor) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) //otherwise we cannot access planeGeometry { planeMesh.vertices = arPlaneAnchor.planeGeometry.vertices; planeMesh.uv = arPlaneAnchor.planeGeometry.textureCoordinates; planeMesh.triangles = arPlaneAnchor.planeGeometry.triangleIndices; // Assign the mesh object and update it. planeMesh.RecalculateBounds(); planeMesh.RecalculateNormals(); } }
public void UpdateMesh(ARPlaneMesh arPlane) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) //otherwise we cannot access planeGeometry { planeMesh.vertices = arPlane.vertices; planeMesh.uv = arPlane.texture; planeMesh.triangles = arPlane.trIndices; lineRenderer.positionCount = arPlane.boundaryVertices.Length; lineRenderer.SetPositions(arPlane.boundaryVertices); // Assign the mesh object and update it. planeMesh.RecalculateBounds(); planeMesh.RecalculateNormals(); } }
private void ConfigureSession() { #if !UNITY_EDITOR ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) { config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical; } else { config.planeDetection = UnityARPlaneDetection.Horizontal; } config.alignment = UnityARAlignment.UnityARAlignmentGravity; config.getPointCloudData = true; config.enableLightEstimation = true; mSession.RunWithConfig(config); #endif }
public void UpdateMesh(ARPlaneAnchor arPlaneAnchor) { if (UnityARSessionNativeInterface.IsARKit_1_5_Supported()) //otherwise we cannot access planeGeometry { if (arPlaneAnchor.planeGeometry.vertices.Length != planeMesh.vertices.Length || arPlaneAnchor.planeGeometry.textureCoordinates.Length != planeMesh.uv.Length || arPlaneAnchor.planeGeometry.triangleIndices.Length != planeMesh.triangles.Length) { planeMesh.Clear(); } planeMesh.vertices = arPlaneAnchor.planeGeometry.vertices; planeMesh.uv = arPlaneAnchor.planeGeometry.textureCoordinates; planeMesh.triangles = arPlaneAnchor.planeGeometry.triangleIndices; lineRenderer.positionCount = arPlaneAnchor.planeGeometry.boundaryVertexCount; lineRenderer.SetPositions(arPlaneAnchor.planeGeometry.boundaryVertices); // Assign the mesh object and update it. planeMesh.RecalculateBounds(); planeMesh.RecalculateNormals(); } }