Search Unity

plane anchor centre is not at centre? how to get centre in world space of plane?

Discussion in 'AR' started by MadeFromPolygons, Mar 7, 2018.

  1. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    @jimmya Nothing here or anywhere mentions how to get the actual centre of a plane anchor.

    When using the planeAnchor.centre vector, and using that to place my object, instead of appearing at the centre of the plane it appears at the corner (not even on the plane, just off it). It is the same each time so it thinks this is the centre.

    So how does one use the planeAnchor data to get the actual centre in world space of the plane? It would be nice to be able to loop through tracked planes, and use their actual world space centre to position an object, and its extent to determine the bounds so it can move around on the surface.


    I feel like working this out is the last thing stopping me from really using this properly. it would be great to be able to work out actual world space bounds + positions so I can make things walk around on surfaces.

    Any help will be greatly appreciated!


    EDIT: or should i be using the plane anchor game object rather than plane anchor to position object? If so are you getting the bounds of that simply by checking a collider or is there some XR.iOS function other than the matrix ops needed to get the bounds of a AR anchor bound gameobject?
     
    Last edited: Mar 7, 2018
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    So i have tried:

    1. using the plane anchor centre vector directly
    2. using plane anchor game object transform to place
    3. using plane anchor centre within vector3.ProjectOnPlane
    4. using matrix ops get position on the world transform of the plane


    1. does not give a correct position
    2. provides a good position, making me wonder why we need the ar matrix ops etc at all if the gameobject placement works fine?
    3. project on plane did not help this and positions incorrectly
    4. places correctly, but is no different in accuracy to 2.

    I guess for now I will place using the plane anchor game object position, as the rest seems to be taken care of automatically.

    i do wish this was clearer on what is the best way to do simple things like actually get the bounds in world space of a plane and position on a plane. If there are differences between this and normal unity usage, this should be made clear. Currently it is unclear if getting bounds via normal methods will be accurate.

    Right now it seems there are multiple ways to do this, all with varying degrees of success.

    anyway, takeaway from this is don't over complicate and just use the game objects to position stuff as normal. You should only worry about the other bits if you don't have plane anchor game objects linked to the plane anchors you wish to manipulate. If you are not managing the plane anchors yourself then this is nothing for you to worry about.

    EDIT: also it is not been made clear how and when/if we should use the camera projection matrix and what for. I get the impression using this to transform the matrix4x4 of the returned planes will cause the co-ordinate space to become correct but it really is not clear if this is intended usage or not.
     
    Last edited: Mar 7, 2018
  3. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982