Notifications
Clear all

[Closed] Create a "clean" shape from a selection of points?

I’ve been working on a script and just realized that what I need is a function that that will create an (approximately) optimal contiguous shape based on a number of points, as illustrated in the picture below:

As visible in the illustration, the function needs to be able to deal with concavity. Also (harder to tell from the illustration) the points do not all lie on a flat plane.

The total number of points in each grouping will probably always be under 50 or so. I could theoretically brute force it, making the script try every combination of points and look for… and that’s the problem. I don’t know how to describe what I’m looking for in terms a program could recognize.

I’ve much more comfortable with using MaxScript than I used to be, but from a purely conceptual point of view I’ve got no idea how to go about this. I suspect I may have just wandered into the deep end of the pool. Any ideas?

2 Replies

By name :

create your points in the order you wish to connect them with and give them progressive names ex. point01 , point02 and so on
you can then loop for the points and choose by name
something like

for i in $point* do
if i.name == “point0” + i as string do the rest of your code

By INode :

again this depends on the order of the points , the order of creation
$.inode.handle

now if you already have the points created , that’s a big problem
i don’t know a solution for this . but
sometime ago i had to rename bunch of objects in a specific order , i didn’t create them and they were too many to do by hand
i ended up making a path and a box and test for these objects distance from the box
can’t really remember if i tested for intersection or distance , but that nasty thing worked

the setup was something like
slidertime = 1
for i in $point* if the intersection is true do i.name = “point01”
slidertime = 2
and then you assign a unique name for the rest of the objects (i.name = (uniquename “point0”))

the box will change its pos every frame and make the test etc.

once you have something real to follow about the order of these points , it’s simple to connect them with a spline by their order .
right now and according to the image , there is nothing really to test against .
i mean you obviously can’t test against the distance of the points or you’ll connect them in a wrong order .

Unfortunately, the points are generated by a combination of the script and user interface. So right now the script will always connect the points in the order that the user selects them.

I think I have figured out a way to describe what I’m looking for. The first step would be to find the path that connects all the outermost points (like a convex hull), and then to adjust the line so that it passes through any points it missed. At any rate, I can see making that work for at least a 2 dimensional shape, but once it’s 3D things get kind of murky…