public static GameObject UpdatePlaneWithAnchorTransform(GameObject plane, ARPlaneMesh arPlane)
        {
            plane.transform.position = UnityARMatrixOps.GetPosition(arPlane.transform);
            plane.transform.rotation = UnityARMatrixOps.GetRotation(arPlane.transform);

            PlacenotePlaneMeshRender ppmr = plane.GetComponent <PlacenotePlaneMeshRender>();

            if (ppmr != null)
            {
                ppmr.UpdateMesh(arPlane);
            }


            MeshFilter mf = plane.GetComponentInChildren <MeshFilter>();

            if (mf != null)
            {
                if (ppmr == null)
                {
                    //since our plane mesh is actually 10mx10m in the world, we scale it here by 0.1f
                    mf.gameObject.transform.localScale = new Vector3(arPlane.extent.x * 0.1f, arPlane.extent.y * 0.1f, arPlane.extent.z * 0.1f);

                    //convert our center position to unity coords
                    mf.gameObject.transform.localPosition = new Vector3(arPlane.center.x, arPlane.center.y, -arPlane.center.z);
                }
            }

            return(plane);
        }
        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(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();
            }
        }
        public void InitializeMesh(ARPlaneMesh arPlane)
        {
            planeMesh = new Mesh();
            UpdateMesh(arPlane);

            MeshRenderer renderer = GetComponentInChildren <MeshRenderer>();

            if (renderer != null)
            {
                renderer.material = placenoteMaterial;
            }
            else
            {
                Debug.Log("Can't find renderer to set alternate material");
            }
            meshFilter.mesh = planeMesh;
        }
        public static GameObject CreatePlaneInScene(ARPlaneMesh arPlane)
        {
            GameObject plane;

            if (planePrefab != null)
            {
                plane = GameObject.Instantiate(planePrefab);
            }
            else
            {
                plane = new GameObject(); //put in a blank gameObject to get at least a transform to manipulate
            }

            plane.name = arPlane.id;

            PlacenotePlaneMeshRender ppmr = plane.GetComponent <PlacenotePlaneMeshRender>();

            if (ppmr != null)
            {
                ppmr.InitializeMesh(arPlane);
            }

            return(UpdatePlaneWithAnchorTransform(plane, arPlane));
        }