Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

What is GetBoundaryPolygon (in DetectedPlane class)

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

  1. ShahrukhAzharAhsan


    Aug 2, 2018
    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>();
    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):
    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;
    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
    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);
    18.                 //Instantiate an object as a child of the anchor
    19.                 //var placedObject = Instantiate (environment, hit.Pose.position, Quaternion.identity, anchor.transform);
    21.                 //Turn on the Score Canvas
    22.                 canvas_score.gameObject.SetActive(true);
    24.                 //Turn on the joystick canvas
    25.                 canvas_joystick.gameObject.SetActive(true);
    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);