Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

How to get 3d-points(x, y, z) data of Spatial Mapping Mesh??

Hi, I'm doing some projects for HoloLens

I want to get data for all points of Spatial Mapping Meshes

Does anyone have any idea for this?

Thanks

Best Answer

  • trzytrzy ✭✭✭
    Answer ✓

    @Buster Sounds like you want to get the mesh data, which will give you all vertices. Assuming you've scanned your space using the SpatialMappingManager, you can get all the mesh filter objects like so:

    List< MeshFilter > meshFilters = SpatialMappingManager.Instance.GetMeshFilters();

    Then, you can access the mesh or sharedMesh (they will be the same for spatial mapping meshes, although I think accessing sharedMesh will prevent a needless copy from being made by Unity internally) property of each spatial mesh filter:

    foreach (MeshFilter meshFilter in meshFilters)
    {
    DoSomething(meshFilter.sharedMesh);
    }

    As for how the mesh object itself works, the Unity scripting reference is your friend: https://docs.unity3d.com/ScriptReference/Mesh.html

    Long story short, you can simply access the vertices property (which will create a copy of the data for you). This is an array of points (Vector3). Spatial meshes don't have any transforms applied, if I remember correctly, so the points should already be in world space but you might want to check that to be sure.

    If you want the raw point cloud from the depth camera, you're out of luck. Meshes is all we're allowed to get.

Answers

  • ReeleyReeley ✭✭✭
    edited July 2017

    The SpatialMapping creates a gameobject for each face found with the naming convention "Surface-" + someId. So you could Find all gameobjects which start with the name "Surface-"

  • trzytrzy ✭✭✭
    Answer ✓

    @Buster Sounds like you want to get the mesh data, which will give you all vertices. Assuming you've scanned your space using the SpatialMappingManager, you can get all the mesh filter objects like so:

    List< MeshFilter > meshFilters = SpatialMappingManager.Instance.GetMeshFilters();

    Then, you can access the mesh or sharedMesh (they will be the same for spatial mapping meshes, although I think accessing sharedMesh will prevent a needless copy from being made by Unity internally) property of each spatial mesh filter:

    foreach (MeshFilter meshFilter in meshFilters)
    {
    DoSomething(meshFilter.sharedMesh);
    }

    As for how the mesh object itself works, the Unity scripting reference is your friend: https://docs.unity3d.com/ScriptReference/Mesh.html

    Long story short, you can simply access the vertices property (which will create a copy of the data for you). This is an array of points (Vector3). Spatial meshes don't have any transforms applied, if I remember correctly, so the points should already be in world space but you might want to check that to be sure.

    If you want the raw point cloud from the depth camera, you're out of luck. Meshes is all we're allowed to get.

  • BusterBuster
    edited July 2017

    @trzy Thank you for reply. As I checked your reply so late, I'd found to get vertices like you said, use MeshFilter.sharedMesh.vertices

    this method can read/write vertices So is what I've been looking for.

  • @trzy said:
    @Buster Sounds like you want to get the mesh data, which will give you all vertices. Assuming you've scanned your space using the SpatialMappingManager, you can get all the mesh filter objects like so:

    List< MeshFilter > meshFilters = SpatialMappingManager.Instance.GetMeshFilters();

    Then, you can access the mesh or sharedMesh (they will be the same for spatial mapping meshes, although I think accessing sharedMesh will prevent a needless copy from being made by Unity internally) property of each spatial mesh filter:

    foreach (MeshFilter meshFilter in meshFilters)
    {
    DoSomething(meshFilter.sharedMesh);
    }

    As for how the mesh object itself works, the Unity scripting reference is your friend: https://docs.unity3d.com/ScriptReference/Mesh.html

    Long story short, you can simply access the vertices property (which will create a copy of the data for you). This is an array of points (Vector3). Spatial meshes don't have any transforms applied, if I remember correctly, so the points should already be in world space but you might want to check that to be sure.

    If you want the raw point cloud from the depth camera, you're out of luck. Meshes is all we're allowed to get.

    Spatial Meshes do indeed have WorldAnchors on them though. If you want to capture and reload them, you will need to save off the world anchor that corresponds to the mesh.

Sign In or Register to comment.