Search Unity

What is GetBoundaryPolygon (in DetectedPlane class)

Discussion in 'AR' started by ShahrukhAzharAhsan, Aug 28, 2018.

  1. ShahrukhAzharAhsan

    ShahrukhAzharAhsan

    Joined:
    Aug 2, 2018
    Posts:
    1
    I have been working on a project in ARCore and I am trying to limit the size of plane that is detected. The documentation says that the function GetBoundaryPolygon takes a list of Vector3 and uses it to make a boundary polygon. However, I tried using it but no success.

    I made a list of Vector3:

    Code (CSharp):
    1. List<Vector3> boundary = new List<Vector3>();
    2.  
    3. boundary.Add (new Vector3(0, 0 ,0 ));
    4.         boundary.Add (new Vector3 (0, 0, 1));
    5.         boundary.Add (new Vector3 (1, 0, 1));
    6.         boundary.Add (new Vector3(1, 0, -1));

    And then I passed it in my "Update Method" like this:

    Code (CSharp):
    1.  
    2. //We have touched the screen. We do a raycast to see that the touch hits a plane
    3.             TrackableHit hit;
    4.             var rayCastFilter = TrackableHitFlags.PlaneWithinBounds | TrackableHitFlags.PlaneWithinPolygon;
    5.  
    6.             if (Frame.Raycast (touch.position.x, touch.position.y, rayCastFilter, out hit) && gameObject != null) {
    7.                 //Create anchor to track the hitpoint (Session Class Used)
    8.                 var anchor = Session.CreateAnchor (hit.Pose, hit.Trackable);
    9.                 //Place the environment at the anchor and make it as anchor's child
    10.  
    11.                 environment.transform.position = anchor.transform.position;
    12.                 //environment.transform.rotation = Quaternion.identity;
    13.                 //environment.transform.Rotate(0, 90, 0, Space.Self);
    14.                 environment.transform.parent = anchor.transform;
    15.                 environment.SetActive (true);
    16.  
    17.  
    18.                 //Instantiate an object as a child of the anchor
    19.                 //var placedObject = Instantiate (environment, hit.Pose.position, Quaternion.identity, anchor.transform);
    20.  
    21.                 //Turn on the Score Canvas
    22.                 canvas_score.gameObject.SetActive(true);
    23.  
    24.                 //Turn on the joystick canvas
    25.                 canvas_joystick.gameObject.SetActive(true);
    26.  
    27.                 //Using Trackable as detectedPlane
    28.                 DetectedPlane dp = hit.Trackable as DetectedPlane;
    29.                 dp.GetBoundaryPolygon (boundary);
    30.                 //Vector3 test_pos = new Vector3(hit.Pose.position.x, hit.Pose.position.y, dp.ExtentZ);