Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

What is GetBoundaryPolygon (in DetectedPlane class)

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

  1. superboy1876

    superboy1876

    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);