-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
could you help out converting it to .obj, please? #293
Comments
Hola @AndreV84 , I'm afraid that pyntcloud does not currently support reading/writing to/from As far as I remember when adding the Looking at how it appears to be implemented in Meshlab (https://gamedev.stackexchange.com/a/66270) it might be feasible to add support to vertex coloring for the |
Hola again @AndreV84 I was feeling hacky so I think that you could use the following: def write_obj(filename, points=None, mesh=None, save_vertex_colors=False):
"""
Parameters
----------
filename: str
The created file will be named with this
points: pd.DataFrame
mesh: pd.DataFrame
save_vertex_colors: bool, optional
Defaul False.
If True, include per-vertex color info following:
https://gamedev.stackexchange.com/a/66270
Returns
-------
boolean
True if no problems
"""
if not filename.endswith('obj'):
filename += '.obj'
if points is not None:
points = points.copy()
columns_to_save = ["x", "y", "z"]
if save_vertex_colors:
columns_to_save.extend(["red", "green", "blue"])
points["red"] /= 255.
points["blue"] /= 255.
points["green"] /= 255.
points = points[columns_to_save]
points.insert(loc=0, column="obj_v", value="v")
points.to_csv(
filename,
sep=" ",
index=False,
header=False,
mode='a',
encoding='ascii')
if mesh is not None:
mesh = mesh.copy()
mesh = mesh[["v1", "v2", "v3"]]
mesh += 1 # index starts with 1 in obj file
mesh.insert(loc=0, column="obj_f", value="f")
mesh.to_csv(
filename,
sep=" ",
index=False,
header=False,
mode='a',
encoding='ascii')
return True
cloud = PyntCloud.from_file("examples/data/ankylosaurus_mesh.ply")
write_obj("output.obj", points=cloud.points, mesh=cloud.mesh, save_vertex_colors=True) |
Thank you very much! Could you elaborate on how to visualize from terminal with the python tool? I never got any window to pop up |
If you want to visualize directly from the terminal, you need to first install matplotlib ( from pyntcloud import PyntCloud
cloud = PyntCloud.from_file("examples/data/ankylosaurus_mesh.ply")
cloud.plot(backend="matplotlib") |
Thank you very much! |
https://storage.googleapis.com/nvidia-dev/113620.ply
At my end I either get the points lost or the color lost with conversion
`[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
The text was updated successfully, but these errors were encountered: