# How to change the color of target polygon in Point-clouds

I have the Point-Cloud object on the scene, generated from *.Ply.

By leftClick I can create a Polygon from the points on the object, by Right.Click my Polygon becoming closed shape. For example, if I drew by mouse on cloud the green polygons.

BUT the program should have also changed color all of the points, which is inside the green shapes. How to do that? I divided the Polygon on triangle, I know the vertices of the figure, but can’t check which points is inside the Polygon. I have 10 mln point to check, and if to use Triangle method for checking it takes a long time, and the Ply file are not sorting the coordinates by any order.

I would really appreciate any clue or idea.

you had use VertexColor which use color attribute to determine color, rather than using uniform color.

Maybe it’s worth to give this addon a try: Three-mesh-bvh: A plugin for fast geometry raycasting and spatial queries!

1 Like

No, I don’t use VertexColor, I just draw Sphere on that coordinate, where Mouse Clicked. I need to change the color of all dots inside the polygon

I haven’t found any useful sample there. Only rabbit might be useful, but it is mesh object, not point cloud. And sample with point Cloud only intersects with one point, i’ve already done that. I need maybe Polygon intersection or raycast not by rays, by triangles, I can divide the polygon on triangles.

Between the lasso example and the point cloud intersection example there should be enough information to implement a lasso-like query mechanism for point clouds. There’s unlikely to be a prebuilt example that does this out of the box already, especially efficiently, I’d think.

I appreciate your piece of advice. I checked the examples, and have tried to intercorporate to my program. But unfortunately the lasso example just building triangles by dividing the defined area. Other functions just returns whether there is intersection or not, and just vertex coordinates.

Like I said you’ll have to understand and adapt the code to get it to work for points. Fundamentally the lasso code is using the ray crossing algorithm to determine whether a vertex / polygon is inside of the lasso. You can look into that algorithm to get started:

3 Likes

Thank you! I appreciate your help and time. I will get acquainted

Hello.I have tried to get points through that plugin, but unfortunately, it is just dividing the chosen area on equal triangles without giving back the coordinates of points inside the polygon :’(

Would a selection box with append option work for you.
That would increase efficacy dramatically.

How to choose appended part? What if i have triangles? Anyway i would have another shapes which is not a square.