Point indexes (PLY)

Feel free to ask any question here
Post Reply
kendal
Posts: 2
Joined: Thu Jul 14, 2022 9:22 am

Point indexes (PLY)

Post by kendal »

Hi all,
I'm working on some animations with point clouds in a game engine (UE4), and there's a morph function which changes the location, point-by-point, of one point cloud to another.
The problem is that it just goes through the list (it only reads ASCII PLY files), moving the first point in cloud A to the location of the first point in cloud B etc.
I really need to be able to change this order, ideally sorting the points using a scalar field so that, for example, points move from denser areas first. I've been trying to work it out for hours, and I'm not even sure of the name of what I'm trying to do (classifying? indexing? re-indexing?) which hasn't helped.
I've tried every kind of operation, and it always saves the file with the points in the same order. The only two things that have worked are modifying the PLY file directly in a database editor, and going in and out of another format (this only worked once, so I might have imagined it) but there must be an easier way?
If I understand correctly, the 'Id' scalar field which can be added from the point indexes is just a regular scalar field named 'Id', and changing it (with arithmetic for example) doesn't actually change the original order, is that right? If so, how would I go about changing the order?
I'm sure this is a very basic question but it would be so useful if there was a quick way to re-order the points based on existing scalar fields, or even just to randomise the order.
Thank you!
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Point indexes (PLY)

Post by daniel »

Interesting...

In CloudCompare, we actually try as much as we can to not change the points order! Therefore, you are right, changing the ID scalar field won't change the point order (it will just change the value associated to each point...).

But you could export the cloud with a density scalar field or similar to an ASCII/TXT file (you can set the options to something that will look like CSV). Then open it in Excel or a similar tool that will let you sort the rows based on a column. Save it, then reopen it in CC and export it to PLY?
Daniel, CloudCompare admin
kendal
Posts: 2
Joined: Thu Jul 14, 2022 9:22 am

Re: Point indexes (PLY)

Post by kendal »

Hi Daniel, thanks for your reply, I thought there must be some reason nothing I did would change them! I mentioned in the post that the only thing that's worked has been doing what you suggest, but with bigger files it can take a while just to load and modify them.

It's still quicker than changing the setup in Unreal, I just wondered if it was possible in CloudCompare. I don't suppose you know which (if any) format(s) re-index the file on save? I have a single .ply file which I somehow managed to re-index from the original by going in and out of another format, but I can't remember which!

If anyone has any tips it would be really useful to find a quick way to do it, the problem with changing the order in Unreal is that it never actually assigns a value to the index number, so there isn't anything there to replace. The PLY values get transposed in the same order onto a material (RGB = XYZ) via a plugin, which can then be exported and re-imported. I'm trying to figure out how to export the image data in a different order, but it looks like it'll be much slower than doing it in Excel or similar.

Thank you for your help!
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Point indexes (PLY)

Post by daniel »

Sorry I don't know of any such format!
Daniel, CloudCompare admin
Post Reply