Search Unity

AR Indoor Navigation using AR Foundation

Discussion in 'AR' started by mohabbadran1998, Mar 22, 2020.

  1. mohabbadran1998

    mohabbadran1998

    Joined:
    Oct 4, 2019
    Posts:
    3
    hello..
    I am working on project to create a navigation system inside buildings(indoor)..and used AR Foundation to map my physical area..
    mapping process: i walked to each position in my physical area and placed an anchor for each to save all positions on cloud , After that i want to load all anchors into 2D floor plan (my physical world plan) and to do that i add each anchor position into a list and make the first anchor is a reference position on 2D Map (start mapping process at this position )and apply this code ..

    Code (CSharp):
    1.  
    2.  
    3. public void loadMap()
    4.         {
    5.      
    6.             if (list == null)
    7.             {
    8.                 Debug.Log("list is empty");
    9.                 return;
    10.             }
    11.             //  Vector3 initialPoint = cam.WorldToScreenPoint(list[0].position);
    12.             Vector3 initialPoint=transform.InverseTransformPoint(list[0].position);// reference point
    13.           //  Vector3 initialPoint = list[0].position;
    14.             Vector3 secondPoint;
    15.             Vector3 newAnc;
    16.             for (int i = 1; i < list.Count; i++)
    17.             {
    18.               // i found the distance vector between each anchor and first anchor(reference) and then add it to the reference position in 2D map in unity scene
    19.                 secondPoint = transform.InverseTransformPoint(list[i].position);//t
    20.        
    21.  
    22.                 float x = (this.transform.position.x + (secondPoint.x- initialPoint.x));//this.transform has the same position of reference
    23.                 float y = (this.transform.position.y + (secondPoint.y - initialPoint.y));
    24.                 float z =100;
    25.                 newAnc = new Vector3(x, y, z);
    26.    
    27.                 Instantiate(sphere, newAnc, Quaternion.identity);
    28.        
    29.             }



    but always loading anchors into wrong position on 2D Map ..
    and i dont know reason ..
    can you solve my problem please ..
    thank you
     
    Last edited: Apr 5, 2020