Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to get World position of LiDAR mesh?

Discussion in 'AR' started by metigel94, Mar 19, 2021.

  1. metigel94

    metigel94

    Joined:
    Oct 11, 2019
    Posts:
    12
    Hi :)

    So I'm working on a project for which I need to know the positional and rotational values of meshes that are created using the LiDAR scanner and the camera of the device in Unity World coordinates.

    I understand that I can utilize ARSessionOrigin to get the position and orientation of trackables in Unity World Space, as the component maps from device / session space to Unity World space.

    However, when writing the values of the transform components of the children of ARSessionOrigin.trackableParent to the debug log of Xcode, I can see that only the ARPlanes which ARFoundation detects actually have positional and rotational values. I can see that there are in fact GameObjects names "Mesh XXX" under "Trackables" but the transform values of those objects are 0 (except the scale property which is 1 in every dimension).

    Now, is there a way to get the transform of scanned meshes relative to the ARSessionOrigin, i.e. in Unity world space? I want to project some textures onto the mesh and therefore I need both the camera's position (which is not a problem) and the position of the mesh relative to ARSessionOrigin.
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,128
    Meshes will always have zero position/rotation if you're using the ARMeshManager.
    But you can get the position of each vertex in a scanned mesh by accessing the Mesh.vertices property.
     
    viknesh2020, Furtin and metigel94 like this.
  3. metigel94

    metigel94

    Joined:
    Oct 11, 2019
    Posts:
    12
    Thank you, that helped immensely!
     
    KyryloKuzyk likes this.