I come from this question where I have generated a Point Cloud from a simple script which I want to convert into a mesh. I see there is this question and this question, which was unfortunately marked as duplicate even though the thread it supposedly duplicated didn't really have any good answers. And then there is this question where I tried the Point Cloud Skinner addon, but it seems to be outdated for Blender 3.6. I don't see the part where their documentation claims Find the UI of Point Cloud Skinner in Scene panel of Properties window. And the answer that used a Shrink Wrap modifier approach also doesn't work for me for this more complex example.
Then there is MeshLab which seems promising but unfortunately I didn't have any luck because their "latest" documentation seems to be outdated, where many of the methods presented in their documentation don't exist. I tried exporting my point cloud as OBJ and using:
import pymeshlab as ml
ms = ml.MeshSet()
ms.load_new_mesh('C:/Users/harry/Downloads/test.obj')
ms.generate_convex_hull()
ms.save_current_mesh('C:/Users/harry/Downloads/convex_hull.ply')
But that had the same effect as using the Convex Hull node from Geometry Nodes which doesn't really work for a concave shape. You can try installing the module using:
import subprocess
import sys
import os
python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'pymeshlab'])
print('DONE')
It seems like one of the methods could work in pymeshlab
like:
ms = ml.MeshSet()
ms.load_new_mesh('C:/Users/harry/Downloads/test.obj')
ms.generate_surface_reconstruction_screened_poisson()
but that gave me error:
>>> ms.generate_surface_reconstruction_screened_poisson()
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender 3.6\3.6\python\lib\site-packages\pymeshlab\__init__.py", line 41, in foo
res_dict = self.apply_filter(name, **kwargs)
pymeshlab.pmeshlab.PyMeshLabException: Failed to apply filter: generate_surface_reconstruction_screened_poisson
Details: Filter requires correct per vertex normals.<br>E.g. it is necessary that your <b>ALL</b> the input vertices have a proper, not-null normal.<br> Try enabling the <i>pre-clean<i> option and retry.<br><br>To permanently remove this problem:<br>If you encounter this error on a triangulated mesh try to use the <i>Remove Unreferenced Vertices</i> filterIf you encounter this error on a pointcloud try to use the <i>Conditional Vertex Selection</i> filterwith function '(nx==0.0) && (ny==0.0) && (nz==0.0)', and then <i>delete selected vertices</i>.<br>
Is there any other method I can employ to effectively convert a complex point cloud into a mesh albeit Blender's documentation claiming that not much can be done with a Point Cloud?
Editing
Currently, not much can be done with point clouds; however, they can be converted to/from meshes.
By the way if you are interested in generating this point cloud you can generate it from this simple script:
import bpy
import math as m
import bmesh
mesh = bpy.data.meshes.new("point-cloud-mesh")
obj = bpy.data.objects.new("point-cloud", mesh)
scene = bpy.context.scene
scene.collection.objects.link(obj)
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
bm = bmesh.new()
def get_range(start, end, decimal=0.03, step=1):
return [v * decimal for v in range(int(start / decimal), int(end / decimal) + 1, step)]
def equation(x, y, z):
return x**2 + y**2 + z**2 + m.sin(4*x) + m.sin(4*y) + m.sin(4*z) - 1
tolerance = 0.1
for x in get_range(-1, 1):
for y in get_range(-1, 1):
for z in get_range(-1, 1):
result = equation(x, y, z)
if abs(result) < tolerance:
v = bm.verts.new((x, y, z))
bm.to_mesh(mesh)
bm.free()