- Home /
Generate a Point Cloud from a Mesh
Alright, so here's what I'd like to do:
I need to somehow calculate or generate a Point Cloud from a given 3D mesh, and I need the positions of those points for further calculations. I'd also like to use this to then represent those points visually.
To be honest, I have no idea where to start with this problem. On my research I've seen a lot of renderer stuff, but that doesn't work for me. I just need the x,y,z-Coordinates of the points. Note: I do not need millions and millions of points, if that is an issue.
If anybody has an idea how to approach this, please give me a hint! Thank you!
Answer by termway · Dec 11, 2014 at 02:57 PM
Look at SetIndices method to change mesh topology. It will render your mesh vertices.
Mesh mesh = GetComponent<MeshFilter>().mesh;
mesh.SetIndices(mesh.GetIndices(0), MeshTopology.Points, 0);
If you need more points I suggest you to subdivide your mesh faces with external software like MeshLab (Filters > Remeshing > Subdivision) or Blender (in edit mode : 'w' > subdivide)
For more information (to change points size) : http://www.kamend.com/2014/05/rendering-a-point-cloud-inside-unity/
Check this one too : https://www.assetstore.unity3d.com/en/#!/content/19811