- Question -
I want to interact with the spatial mesh that I can access via MRTK. I want to instantiate a sphere at the cursor position and get every triangle of the spatial mesh that is inside of the sphere, so I can cut that out and save it for me.
I know how to
But I don't know how to approach this. To better understand what I want to try, I have drawn a small sketch:
- Solution -
TriggerEnter & -Exit
object manipulation script
from MRTK, that has an EndOfManipulation-Event
that triggers, after placing the sphere.MeshFilter
and Meshes
spatialMesh
that are inside the sphere -> indicesList
spatialMesh
get the triangles that have all the vertex indices inside indicesList
-> triangleList
And you have all you need to construct a vertex array and triangle array for the mesh inside the sphere.
Just as an example:
for i = 0 to triangleList.Count
newVertices[i] = spatialMesh.vertices[triangleList[i]];
newTriangles[i] = i;