Search Unity

Augment object onto wall

Discussion in 'AR' started by davejones1, Mar 26, 2018.

  1. davejones1

    davejones1

    Joined:
    Jan 19, 2018
    Posts:
    183
    Is there a way to augment an object onto a wall using ARCore?
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    With ARCore 1.0, raycasts against feature points include an orientation meant to approximate the surface. See https://developers.google.com/ar/discover/concepts#oriented_points

    You can see how Google's Unity plugin does this in their HelloARController.cs:
    Code (csharp):
    1. TrackableHit hit;
    2. TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
    3.     TrackableHitFlags.FeaturePointWithSurfaceNormal;
    4.  
    5. if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
    6. {
    7.     var andyObject = Instantiate(AndyAndroidPrefab, hit.Pose.position, hit.Pose.rotation);
    8.     ...
    Note if the raycast hits a FeaturePointWithSurfaceNormal, then the hit.Pose.rotation will include the orientation of the surface.
     
    davejones1 likes this.