microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Create surface object with special tag when using Spatial Mapping #184

Closed ChangweiZhang closed 7 years ago

ChangweiZhang commented 8 years ago

As we all know, there are losts of surface objects which will be ctreated after we use Spatial Mapping. Maybe it will be better if Spatial Mapping create those surface objects with a special tag? Because we always use gestures or gaze, a special tag will help us select the right object

Subere23 commented 8 years ago

Does using a layer and layermasks not work better for the same objective?

jwittner commented 7 years ago

Looking through SpatialMappingSource where SurfaceObjects are added in AddSurfaceObject they are added to the layer specified by SpatialMappingManager.Instance.PhysicsLayer. This looks to be controllable through the editor.

Are these the surface objects you're referring to? If so, can you filter by that physics layer for your use case?

angelaHillier commented 7 years ago

As @jwittner suggests, you can use the collision layer to detect if an object is part of the spatial mapping mesh. For my applications, I like to create an empty game object called 'Spatial Mapping' in my scene, that I then parent all of the spatial mapping game objects to (the 'SpatialMapping' prefab in HoloToolkit will automatically parent the meshes to itself). Then, if I want to get the meshes, I just need to look for that parent object to find them.

Tags are very convenient when working in your own application (and you can certainly modify the SpatialMapping code in your own application to add a tag whenever a new mesh is created). However, tags do not export to other projects. So, even if we were to create a 'SpatialMapping' tag in the 'HoloToolkit', all users would have to manually add that tag to their project to take advantage of it. Because of this limitation, we avoid using tags in prefabs and code that is meant to be shared across multiple projects.

NeerajW commented 7 years ago

Totally agree with @jwittner and @angelaHillier. Tags would break the scenario of create a unity package of the toolkit and import into another project. Or just copy code that depends on tags.

ChangweiZhang commented 7 years ago

Thank you, guys. Layer is actually better than tag. Happy Mid-autumn Festival