PDA

View Full Version : Selection plugin that works for intersecting polygons?



Revanto
09-19-2017, 03:40 AM
I know this sounds like a very weird plugin query but I was wondering if there was a plugin where I can select one or a few polygons and then have the plugin select all connected polygons AND any non-connected intersecting polygons, too?

I'm currently doing a major project and something like this would be soooo frikkin' useful and time saving.

I know it's usual to just be able to select connected geometry but I'm hoping this shot in the dark will hit its mark.

Thanks in advance.

Cheers,
Revanto :p

Sensei
09-19-2017, 04:51 AM
Everybody rather want to avoid intersecting polygons.. ;)

And fix them if such will appear during modeling.

Kryslin
09-19-2017, 09:23 AM
Hmm...
So, Take the polygon selection, and select all the polygons that share edges and points with them, and then any intersection polygons...With the original selection, or the expanded selection?

I think it's do-able, if it doesn't exist already. It might be doable in lscript, even.

Sensei
09-19-2017, 10:52 AM
It might be doable in lscript, even.

It would be extremely slow script. Checking whether one polygon intersects with any other polygon, in the loop. 1000 polys vs 1000 polys = 1 mln intersection routines called. 10k x 10k = 100 mln.
Imagine sphere that has no intersecting polygons with other sphere, and to make sure they don't intersect you have to analyze them all.

In C/C++ you would start it from reading all vertexes, the all polygons, moving data to KD-Tree/Octree.
And then start analyzing.

MonroePoteet
09-19-2017, 11:00 AM
I know this sounds like a very weird plugin query but I was wondering if there was a plugin where I can select one or a few polygons and then have the plugin select all connected polygons AND any non-connected intersecting polygons, too?
...


If such a plugin existed, what would you do with the resulting selection? In other words, what are you actually trying to accomplish?

If you're trying to eliminate the intersections, you might have luck using Construct=>Combine=>SpBool Union. First, select the "primary" geometry, use "]" to expand to include all connected polygons, then use SpBool Union to "chop holes" in intersecting geometry where they overlap the "primary" geometry, then use Merge Points ("m" - Automatic) to merge the results.

You can simply see the intersecting geometry by again selecting the "primary" geometry, use "]" to expand the selection, use SpBool Intersect, CTRL-C to copy the intersection to the clipboard, CTRL-Z to undo the SpBool Intersect, and CTRL-V to paste in the interesection which will be highlighted. It doesn't actually select the original polygons that are intersecting, but you'd be able to identify them relatively easily (depending on the geometry's compexity, of course).

Good luck!
mTp

jasonwestmas
09-19-2017, 12:06 PM
If I needed this level of control I would make "Parts" out of each group of polys(Detail>Parts>Create Part Tab). The down side is that you have to use the 'w' statistics list to select the parts that you created. Otherwise, just select a polygon and hit the ' ] ' Right-Bracket key to select connected an island of polys.

Revanto
09-19-2017, 07:57 PM
OK, I've excepted the fact that there is no such plugin and it would be a pain to make. I though that I might explain more about what I am trying to do. I got one of those kitbash obj sets free online but the objects have come in single objects sets. So, I would load the object and would have to save out the 50 or so meshes separately that make up the object.

I can do this manually, of course, as the objects are in a grid layout and there are spaces between the meshes. It can take from 40 minutes to an hour. The problem is that sometimes the objects are too close together when I have to select them via lasso AND I don't know what meshes are part of the object but are disconnected (EG a gear with separate bolts). If all of the meshes within the objects did not have any disconnected parts then I would easily just be able to select a few polys and then use 'select connected' to pick the rest of the mesh.

It's not that I can't do this - it's just that I want to save the separate meshes out faster for future kitbash sets. The last set I did, I made a mistake by saving out parts of a mesh instead of the whole mesh so I had to restart because I didn't know from which mesh the part was from (after I copy out the mesh piece from the object set, I centre it then save it out so it is hard to find out the solution via mesh alignment).

If there was a workaround then that would be interesting. I was thinking of actually using the drill>stencil tool (projected from the Y axis) using a custom 2d polygon to separate the meshes by giving them custom surface names but it would seem like extra unnecessary work. There are plugins that can separate meshes into new layers and others that can save each layer out as a new object. But it's the part in between which I would like to solve.

Thanks to all for the feedback.

Revanto :p

oliverhotz
09-19-2017, 10:39 PM
if you are talking about the kitbash set that was recently posted online (12 object sets with many items in each).. i have already done all that conversion.. and yes, I wrote a script to do it.. wasnt 100% automated, but almost, and took only 30 mins to scale them, center them, and make each a single item. I dont know if its ok to make them available based on the original authors share, but i've given them to a few people that have shared them

Kryslin
09-19-2017, 11:11 PM
It would be extremely slow script. Checking whether one polygon intersects with any other polygon, in the loop. 1000 polys vs 1000 polys = 1 mln intersection routines called. 10k x 10k = 100 mln.
Imagine sphere that has no intersecting polygons with other sphere, and to make sure they don't intersect you have to analyze them all.

In C/C++ you would start it from reading all vertexes, the all polygons, moving data to KD-Tree/Octree.
And then start analyzing.

I didn't say it would be fast, but that it could be done.

For speed, we cheat a little.

We'll start with the 1st part, a trivial task; expand selection once, there you go.
2nd part : Get the bounding box of each island. Do a point selection based on that bounding box, convert to polygon selection. if the point lies within the selection box, the polygon it belongs to will be selected. You can check from that smaller selection whether or not they intersect or not, using the two points connected to the selected one for your edge pairs.

We're halfway there, now.

It's covering the "edge intersects at one point, and both endpoints are outside the bounding box" case that one has to start doing lots of iterations, which can be reduced by getting rid of data you don't need to work on; we only need to check against the selection from the first part, after all. I agree that you would have to start breaking things down into smaller, more manageable chunks before analysis.

And I shudder to think what an octree implementation in lscript would look like...-

jeric_synergy
09-19-2017, 11:16 PM
if you are talking about the kitbash set that was recently posted online (12 object sets with many items in each)..
::scooby voice:: "Huh??"

Is there a link? ( "Yoinks!")

sk810
09-20-2017, 11:23 AM
Closet you've got now is hitting SHIFT + "]" to select the surrounding plugins.

Revanto
09-20-2017, 08:03 PM
if you are talking about the kitbash set that was recently posted online (12 object sets with many items in each).. i have already done all that conversion.. and yes, I wrote a script to do it.. wasnt 100% automated, but almost, and took only 30 mins to scale them, center them, and make each a single item. I dont know if its ok to make them available based on the original authors share, but i've given them to a few people that have shared them

No, it was someone else's kitbash kit, free on Gum Road. I hope I'm allowed to post this link. It's a free kit so I don't think it should be a problem. http://andrewaverkin.com/projects/6ggB0
There are a few other cool things he's given away for free, too.
I'm glad he cut it up into sets because the object with ALL of the meshes is over 1.5 gig


Closet you've got now is hitting SHIFT + "]" to select the surrounding plugins.

I think you meant 'polygons' not 'plugins' :p And, yes, I do know the 'select connected' process, btw. Thanks anyway.

Anyway, I think it is an interesting puzzle that I'm sure that some bright spark can solve. I just hope that I'm the one that can do it!

Cheers,
Revanto :p

oliverhotz
09-20-2017, 08:30 PM
yeah.. thats the one i was talking about.. i sent you a private message.

jeric_synergy
09-21-2017, 08:28 AM
yeah.. thats the one i was talking about.. i sent you a private message.

Got it, THANKS. --I'm assuming the OBJ/FBX/Max archives are just duplicates?

Revanto
09-21-2017, 06:15 PM
Got it, THANKS. --I'm assuming the OBJ/FBX/Max archives are just duplicates?

Yes, they are because when I got the file from the original Gumroad link, there was a choice of obj.zip, fbx.zip or max.zip so it is safe to assume that all the packs contain the same objects.

Rev. :p

jeric_synergy
09-21-2017, 06:48 PM
Cooolies.

papou
09-22-2017, 06:26 AM
I think there is a 32 bits plugin that select intersect polys.
For sure, i can't remember the name now...
I think demo pictures was a cow, with intersect polys at its hoof.
hmmm.....

Edit: It was SelectPolygonsWithImproperEdge from TrueArt sensei.
And it' not what you are looking too. Sorry.

http://www2.trueart.pl/?URIType=Directory&URI=Products/Plug-Ins/SelectPolygonsWithImproperEdge

gar26lw
09-22-2017, 06:41 PM
I know this sounds like a very weird plugin query but I was wondering if there was a plugin where I can select one or a few polygons and then have the plugin select all connected polygons AND any non-connected intersecting polygons, too?

I'm currently doing a major project and something like this would be soooo frikkin' useful and time saving.

I know it's usual to just be able to select connected geometry but I'm hoping this shot in the dark will hit its mark.

Thanks in advance.

Cheers,
Revanto :p

Why not select connected, then sold drill, then merge points? Then select connected.

Revanto
09-22-2017, 07:25 PM
Why not select connected, then sold drill, then merge points? Then select connected. Because when you have a object with 50 or so meshes AND you don't want to go through each one individually to check whether there are any intersecting meshes, it's a real pain. I'd want to keep the original geometry of the meshes untouched, too, so that's not an option.

Thanks anyway.

Rev. :p

daforum
09-22-2017, 11:06 PM
Can't you select by Surface name? If all the meshes are say "Default" then all can be selected.
Get your Polyfon statistics window open and go to the Surfaces section to choose the surface(s) name(s)

Or even by Part name too!

Hope it helps :)

Revanto
09-23-2017, 03:02 AM
Can't you select by Surface name? If all the meshes are say "Default" then all can be selected.
Get your Polyfon statistics window open and go to the Surfaces section to choose the surface(s) name(s)

Or even by Part name too!

Hope it helps :)

It's not that the polygons can't be selected by part or surface names. If you have a ton of meshes and you have to manually go through and find which mesh part intersects with which mesh and then have to group them together, it can become tedious. Oh, imagine that you have 50 plus meshes on the layer and everything has the same surface and/or part name. That would be even worse, right?

I don't mind to do manual and tedious selections IF there are only a few (say, about 20) meshes on a layer BUT we are talking about way more.

If me or someone else can come up with a way to solve this then I think it will make for a very useful plugin for separating meshes in future kitbash objects.

I thought I had solved the issue (or at least come up with a plugin hypothesis) but I hit a snag. The key here is to use the Drill>Stencil tool to get all the polygon naming done right but all thew steps up to that is a bit of a tangle. There may be one way to do it but it would require to get a UV map made up then use a combination of Photoshop and Illustrator to get the right cutting shape for the Drill>Stencil step. The problem from there, obviously, is to ensure that each 'cutting' shape polygon surface gives the unique name to the meshes.

Now, if any of you are confused at this point, it's OK. I totally understand but if you were inside my head right now, it would all make sense. :p

I just need to experiment until I can come up with a good concept with all steps that are do-able.

Thanks for your feedback anyway.

Cheers,
Rev. :p

MonroePoteet
09-23-2017, 10:40 AM
Try this LScript, see if it does what you want. It expands your selection to all connected, uses SpBool Intersect to determine any polygons which intersect the selection, gets the bounding box of the intersection and then selects any polygons that have one or more points inside that bounding box.

Usage:

1) Select one or more polygons in the "primary" geometry
2) Invoke the script
3) If desired, use "]" to expand the intersection to all connected geometry

NOTE: if you want this done automatically, you could add another selpolygon(SET,CONNECT); after the selpolygon(SET,VOLINCL,...)

Notes:

1) Requires at least one empty layer
2) Replaces the contents of the clipboard

Hope it's what you want / need!
mTp

MonroePoteet
09-23-2017, 10:46 AM
I already found a case where the LScript above won't work: where the CONNECT expanded geometry passes through an intersecting polygon without containing any of that polygon's points. Maybe it'll be useful anyway.

Good luck!

mTp

Rayek
09-23-2017, 11:16 AM
OK, I've excepted the fact that there is no such plugin and it would be a pain to make. I though that I might explain more about what I am trying to do. I got one of those kitbash obj sets free online but the objects have come in single objects sets. So, I would load the object and would have to save out the 50 or so meshes separately that make up the object.

I can do this manually, of course, as the objects are in a grid layout and there are spaces between the meshes. It can take from 40 minutes to an hour. The problem is that sometimes the objects are too close together when I have to select them via lasso AND I don't know what meshes are part of the object but are disconnected (EG a gear with separate bolts). If all of the meshes within the objects did not have any disconnected parts then I would easily just be able to select a few polys and then use 'select connected' to pick the rest of the mesh.

It's not that I can't do this - it's just that I want to save the separate meshes out faster for future kitbash sets. The last set I did, I made a mistake by saving out parts of a mesh instead of the whole mesh so I had to restart because I didn't know from which mesh the part was from (after I copy out the mesh piece from the object set, I centre it then save it out so it is hard to find out the solution via mesh alignment).

If there was a workaround then that would be interesting. I was thinking of actually using the drill>stencil tool (projected from the Y axis) using a custom 2d polygon to separate the meshes by giving them custom surface names but it would seem like extra unnecessary work. There are plugins that can separate meshes into new layers and others that can save each layer out as a new object. But it's the part in between which I would like to solve.

Thanks to all for the feedback.

Revanto :p

Lightwave Modeler is at fault here - or at least, the way it handles the import of the objects: it loads the entire thing as one mesh, which makes no sense whatsoever

If you want to quickly separate all objects as individual FBX files, here's a simple method:

1) open one of the FBX files in Blender. Notice that Blender imports each part as an individual object. Save the blender file.
2) Download this script, and run it in Blender: https://github.com/pjezek/blender/tree/master/unity_tools
3) in the toolshelf, Misc tab, Unity Tools select an export folder.
4) Click "Batch Export"

Wait a bit. Done. You now have a folder with all the individual object files. I tested it.

Btw, in Blender I would not need to do this - the original part file I would save as a Blender file, and then use the Link or Append option to quickly open one of the objects. Or I would use the Asset Management plugin ($) to make my life easier.

Sensei
09-23-2017, 12:15 PM
If me or someone else can come up with a way to solve this then I think it will make for a very useful plugin for separating meshes in future kitbash objects.

TrueArt's Modeling Pack http://modelingpack.trueart.eu has tools for splitting large meshes for ages:

Parts To Layers
https://www.youtube.com/watch?v=_-wXoQm5ZMA

Surfaces To Layers
https://www.youtube.com/watch?v=QB5uKgchh1M

Weight Polygon Groups
http://www2.trueart.pl/?URIType=Directory&URI=Products/Plug-Ins/WeightPolygonGroups

If you can rename separate groups of connected polygons to have different surface/part/weight,
above tools will split them the way you need.

jwiede
09-23-2017, 07:18 PM
There are things you can do to ease the process of checking for intersection (f.e. comparing the two bounding boxes first and if they don't intersect then neither can their contained geometry), but at some point it'll come down to comparing geometry against geometry directly (either as whole meshes, or as some kind of spatially-organized subsections of meshes). Such direct element-by-element checks generally remain a painful, combinatorially-lengthy process involving lots and lots of compare operations.

IIRC, there's a process breaking the container regions into n-trees of ever smaller squares (where the smaller are a power-of-two reduction of the larger's length in one or more dimensions to avoid division ops) which currently is or among the "most efficient" algorithms to check for spatial overlap. If you look in the Graphics Gems book series' algorithms, they have a few different versions of varying efficiency (can't recall if the reducing-squares one is in there, but think it is).

Revanto
09-23-2017, 08:56 PM
OK, there are already plugins that can do stuff like give new surface names to every separate mesh in a layer OR to save out each mesh out as an object based on surface and part name. The big issue here is the intersecting meshes that are related to another mesh but go by another name (surface or part). Unless they can be grouped with their associated meshes then that's the big issue here.

I will post up some screenshots of what I mean if it will make things clearer and I'll also post up my idea as to how it could partially be solved.

Rev. :p

Revanto
09-24-2017, 12:46 AM
I've made a quick sample of objects (yeah, I know, they look like crap)illustrated in the imaged attached to give you an idea of the sort of setup you may expect from a kitbash set saved as one object. Like I've mentioned before, you'll probably get objects with way more meshes but this is just a sample. Imagine an object with 100 or so meshes and not knowing which ones have intersecting geometry!

1) The pink meshes represent intersecting meshes. The green triangle-like mesh is an example of a problem that might prop up.

2) The first idea I had involved creating individual bounding boxes which were flattened, merged and unified so they were simple square polys. I thought of having them resurfaced with individual names for the Drill>Stencil step but, as you can see, there is a problem. The green triangular meshes bounding box overlaps a different bounding box. So, I had to scrap that idea.

3) So, as I mentioned before, I would try something involving Photoshop and Illustrator. I made a UV map of all the objects from the top view (in proportion) and exported out a UV snapshot at about 1024x1024.

4) In Photoshop, I selected the UV islands and expanded my selection and filled it with black. I took the the new image into Illustrator and autotraced the black blobs to make vector shapes. I saved out the vector file.

5) I imported the Illustrator AI file and scaled it to fit my object. It helps to have the object centred and to have a bounding box to help with alignment for when you save out the Illustrator file.

6) I deleted the box and, as you can see, the n-gons surround the background meshes nicely, unlike the stupid bounding box fiasco mentioned in step 1 and 2.

7) All the n-gons were given a separate surface. The only thing to do now would be to do Drill>Stencil to change the surface names.

But, as you may all know, the Drill>Stencil only allows you to stencil using one surface name. But, if that is an issue that can be solved via programming then it would make this process doable.

Of course, the other issue is that I had to use both Photoshop and Illustrator to get those n-gons which nicely enclosed the meshes. Unless anyone can figure out how this could be done inside of Lightwave, this whole idea would be kinda pointless.

137993

I hope this clears up what I want to achieve.

Thanks for everyone's input so far. I'm enjoying the discourse.

Cheers,
Revanto :p

Rayek
09-24-2017, 03:52 AM
...but? Isn't your intention to save all the objects as separate objects? I am being pragmatic here, and I'd say just do this in Blender (or Max). Why go through all the hassle in Modeler when it is solved within minutes in Blender?

Unless, of course, you insist on doing this in Modeler.

Revanto
09-24-2017, 05:39 AM
...but? Isn't your intention to save all the objects as separate objects? I am being pragmatic here, and I'd say just do this in Blender (or Max). Why go through all the hassle in Modeler when it is solved within minutes in Blender?

Unless, of course, you insist on doing this in Modeler.

I don't use Blender or Max. I would like to do this in Lightwave because, some time in the future, someone else who is a Lightwave user (and doesn't use Blender or Max, either) can benefit from it. And if anyone comes up with an Lscript or a plugin to do this then it is a bonus.

Rev.:p

Kryslin
09-24-2017, 03:44 PM
I'm currently away from the workstation, but I can see how this could go together:
1) Get the connected blocks of geometry
2) Determine the bounding boxes of each connected block of geometry.
3) Determine which bounding boxes intersect at this level.
4) For Each group
5) Current Step = 0, Max Steps = 3
6) Divide each volume into 8 smaller volumes
7) check for intersections; those that intersect get added to the list, those that don't get thrown out.
8) Current Step ++
9) If Current Step < Max Steps, Goto 6
10) Using Polygon/Polygon intersection, find the intersecting polygons and select them.
11) Select Connected.
12) Cut this selection, paste into new object, save.
13) Loop back to 4 until no groups are left.

I think the idea is sound, no idea if the code will work until I get back next week.

edit: This might be simplified a great deal, if you don't need to divide, say, the Y dimension at all - the example above is a general purpose one. Once you get to a certain point, you might not even need the poly/poly intersection test. Also, it's a tedious but simple task to select with a lasso and cut and paste each one as you need it.

Revanto
09-26-2017, 08:20 PM
I'm currently away from the workstation, but I can see how this could go together:
1) Get the connected blocks of geometry
2) Determine the bounding boxes of each connected block of geometry.
3) Determine which bounding boxes intersect at this level.
4) For Each group
5) Current Step = 0, Max Steps = 3
6) Divide each volume into 8 smaller volumes
7) check for intersections; those that intersect get added to the list, those that don't get thrown out.
8) Current Step ++
9) If Current Step < Max Steps, Goto 6
10) Using Polygon/Polygon intersection, find the intersecting polygons and select them.
11) Select Connected.
12) Cut this selection, paste into new object, save.
13) Loop back to 4 until no groups are left.

I think the idea is sound, no idea if the code will work until I get back next week.

edit: This might be simplified a great deal, if you don't need to divide, say, the Y dimension at all - the example above is a general purpose one. Once you get to a certain point, you might not even need the poly/poly intersection test. Also, it's a tedious but simple task to select with a lasso and cut and paste each one as you need it.

I kind of have a mental image of what you are trying to do by creating the bounding boxes then subdividing them so that the cross intersecting polygons can be deleted while still maintaining the bounding edge necessary to encompass the meshes in the background (Whew, long sentence...). Is this correct? Maybe an image would be better to explain it, that is, if I'm wrong.

If I am right then I can see a flaw in this in so that any of the intersecting/overlapping polygons that are deleted may actually still be necessary to the boundaries of the mesh. I have to figure this thing inside my head so it's hard to explain verbally.

I do appreciate the lateral thinking and input, though.

Cheers,
Revanto :p

jwiede
09-28-2017, 01:50 AM
As long as the actual polygon "islands" don't intersect, there's an easier way to separate them:

while (poly present in layer != 0)
{
select first poly id present in layer
"select-connected"
move selected to new layer
}

When done, the initial layer will be empty, and each of the new layers should each contain a distinct poly "island" from the original.

Obviously this won't work to separate cases where the actual meshes intersect, but should work regardless of whether bounding boxes overlap between islands. It'll require fix-up if any of the meshes are a collection of two or more distinct "islands" of geo, but once separated into layers that just requires cut-n-paste of layers' contents together.

Sensei
09-30-2017, 12:16 PM
As long as the actual polygon "islands" don't intersect, there's an easier way to separate them:

while (poly present in layer != 0)
{
select first poly id present in layer
"select-connected"
move selected to new layer
}

When done, the initial layer will be empty, and each of the new layers should each contain a distinct poly "island" from the original.


There is built-in tool for this. Layers > Connected To Layers.