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.
Options

Automatically placing items on the scanned mesh

In this experiment, I want to place a variety of items around the mesh automatically once it's scanned/loaded.

To do this, I'm using the Spatial Mapping Observer, Spatial Mapping Manager and Object Surface Observer from the Academy 230 lesson.

Once the mesh is ready (default 10 second wait for right now), I iterate through all of the meshes using HoloToolkit.Unity.SpatialMappingManager.Instance.GetMeshes(), then iterate through all the vertices in each mesh, randomly picking points. I spawn items at those points.

In the Editor, I use a model of the room Exported from the web interface of the emulator. This works as expected:

But in the emulator and on the device, the objects do not appear to be spawning on the mesh

Any idea what's going on here? Do I need to scale/translate the vertices I read from the SpatialMappingManager before I use them?

Director of Innovation, Helios Interactive

Best Answers

  • Options
    PatrickPatrick mod
    Answer ✓

    Yes, you'll need to transform the position using the meshFilter's transform.

    something like:

    Vector3 worldPos = filter.transform.TransformPoint(meshLocalpoint);

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options
    PatrickPatrick mod
    Answer ✓

    When the meshes are exported from the Developer Portal Website, the transforms are applied. In the Unity environment doing these transforms isn't necessary. On device the transforms become necessary because there is no way to predict where the user will start the application relative to any point in space. To counteract this, spatial mapping meshes have a world anchor component attached to them. The meshes' vertices are then stored locally relative to the world anchor origin.

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

Answers

  • Options
    PatrickPatrick mod
    Answer ✓

    Yes, you'll need to transform the position using the meshFilter's transform.

    something like:

    Vector3 worldPos = filter.transform.TransformPoint(meshLocalpoint);

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options
    edited July 2016

    Thank you, @Patrick, that produced the expected output! I wondered if that was the case but didn't see any translation/scaling of the submeshes in the Inspector. Are they scaled and translated on the device/emulator only, or am I not understanding some other aspect of meshes and their transforms?

    Director of Innovation, Helios Interactive

  • Options
    PatrickPatrick mod
    Answer ✓

    When the meshes are exported from the Developer Portal Website, the transforms are applied. In the Unity environment doing these transforms isn't necessary. On device the transforms become necessary because there is no way to predict where the user will start the application relative to any point in space. To counteract this, spatial mapping meshes have a world anchor component attached to them. The meshes' vertices are then stored locally relative to the world anchor origin.

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options

    @Patrick - thank you for taking the time to explain this to me. That makes sense, and I feel like I've got a better grasp on what's happening in the Editor vs Emulator/Device environments.

    Director of Innovation, Helios Interactive

Sign In or Register to comment.