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

Changing SpatialUnderstanding mesh material at run-time

After finalizing the playspace, it looks like there is no built-in way to change the spatial understanding material (from visible to occluding, for example). Am I missing something or is the only way to iterate over all the mesh objects that are attached to the SpatialUnderstanding game object, manually changing the material myself?

Best Answer

Answers

  • Options
    james_ashleyjames_ashley ✭✭✭✭
    edited February 2017

    I use the custom mesh script to just stop drawing, like I would with spatial mapping:

    var customMesh = SpatialUnderstanding.Instance.GetComponent<SpatialUnderstandingCustomMesh>();
    
    customMesh.DrawProcessedMesh = false;
    

    You can set a new mesh same way:

    var customMesh = SpatialUnderstanding.Instance.GetComponent<SpatialUnderstandingCustomMesh>();
    
    customMesh.MeshMaterial = yourMaterial;
    

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options
    trzytrzy ✭✭✭

    Thanks for the response, James. This doesn't seem to work for me. Once the playspace is finalized and the meshes are generated, changing MeshMaterial has no effect (note that it's just a public member, and not a property with a setter defined).

    I even tried disabling mesh drawing (DrawProcessedMesh=false) and then on the next frame setting the MeshMaterial and enabling drawing again, but no luck. The new material does not take effect.

  • Options
    trzytrzy ✭✭✭

    Thanks, James. I think I see what you're getting at. But I'm not sure meshes obtained through SpatialMappingManager and SpatialUnderstanding should be used together given the amount of processing that the latter have gone through.

    I haven't yet tried using SpatialUnderstanding's meshes for occlusion but I imagine they should work just as well, if not better, than the underlying spatial mapping meshes.

    I want to use SpatialUnderstanding for easier positioning of objects (it detects planar surfaces much better) but then will want said objects to interact with those surfaces (drive over them, blast holes in them, and hide behind them).

    I guess iterating over the meshes themselves (as SpatialMappingManager does) is the best choice. Surprised, though, that an explicit function for this was not provided.

Sign In or Register to comment.