Arfoundation-samples: Infinite plane trackable issue on Android. (Edited: Modifying the bounds of detected plane.)

Created on 28 Jan 2019  路  7Comments  路  Source: Unity-Technologies/arfoundation-samples

Once a plane is detected or updated I want to make that surface have the size of Vector2.positiveInfinity, how ever I cannot modify read-only Plane coming from PlaneUpdatedEventArgs args of ARSubsystemManager.planeAdded or ARSubsystemManager.planeUpdated events.

Is there a way to have the detected AR plane infinite with the current normal of it.

Most helpful comment

Pose hitPose = hits.Last().pose; //get pose of last hit point

Hits are sorted by nearest first, so you are always using the hit with the farthest plane, which might explain why the result is sometimes "lower" than you expect.

The version of Raycast that takes a screen point is implementation defined -- I think on ARCore PlaneWithinInfinity is really more like "a generous approximation", but not necessarily infinity. You might also try the Ray version of Raycast, which fully respects PlaneWithinInfinity. You can construct a similar Ray with camera.ScreenPointToRay

All 7 comments

The detected AR plane is what was _detected_. It's telling you what it found, so changing the incoming data won't have any effect. What are you trying to do with this information?

If you are trying to raycast against an infinite plane, you can use the TrackableType.PlaneWithinInfinity flag. You can treat the plane as infinite by simply using its pose and normal in you calculation. Can you provide more details on your use case?

@tdmowrer Thank you for the response. I have also tried PlaneWithInfinity for ray casting how ever the position of the plane then seems to be wrong, lower that what seems to be detected plane.

I simply want to place my objects anywhere on the same level of detected plane. Since PlaneWithInfinity didn't work for me I was looking into ways of modifying the detected plane.

Given the plane's pose and normal, you can simply use UnityEngine.Plane.Raycast directly.

However, PlaneWithinInfinity should work. Could you post a code snippet showing what you're doing?

Given the plane's pose and normal, you can simply use UnityEngine.Plane.Raycast directly.

However, PlaneWithinInfinity should work. Could you post a code snippet showing what you're doing?

I've noticed that on android planewithininfity only returns a hit when you raycast within a detected plane. On iOS it works as expected.

@tdmowrer Here is the code I have the related logic.

if (sessionOrigin.Raycast(touch.position, hits, TrackableType.PlaneWithinInfinity))
{
    Pose hitPose = hits.Last().pose;   //get pose of last hit point
    Spawn(hitPose);   //spawn the object on this pose
}

@nilsk123 indeed I use an Android 8.1 Huavei P20 for the task. PlaneWithinInfinityacts pretty much like PlaneWithinBounds

Pose hitPose = hits.Last().pose; //get pose of last hit point

Hits are sorted by nearest first, so you are always using the hit with the farthest plane, which might explain why the result is sometimes "lower" than you expect.

The version of Raycast that takes a screen point is implementation defined -- I think on ARCore PlaneWithinInfinity is really more like "a generous approximation", but not necessarily infinity. You might also try the Ray version of Raycast, which fully respects PlaneWithinInfinity. You can construct a similar Ray with camera.ScreenPointToRay

@tdmowrer selecting the farthest plane is an intended behavior in this case. The approach you suggested actually helped and now I can move on an infinite plane, thank you. Here is the code snipped I used that worked.

Ray ray = sessionOrigin.camera.ScreenPointToRay(touch.position);

if (sessionOrigin.Raycast(ray, hits, TrackableType.PlaneWithinInfinity))
{
    Pose hitPose = hits.Last().pose;
    Spawn(hitPose);
 }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Berenice2018 picture Berenice2018  路  3Comments

alessiograncini picture alessiograncini  路  7Comments

jackpr-unity picture jackpr-unity  路  5Comments

ChakreyaYan picture ChakreyaYan  路  5Comments

jessekirbs picture jessekirbs  路  5Comments