PDA

View Full Version : How to select random Polygons that are not neighbours?


mogh
05-24-2008, 08:13 AM
How to select random Polygons - that are not neighbours?

I am searching for aneasy solution for this selectingproblem. Is there a Plugin or script out there whichdoes the trick?

I tried the plugin called "reeselector" but it jut selects random polygons.points.edges ...

I would be a huge timesaver for me if there was a solution for selecting plygons randomly but not any neighbours (lets say edges and/or point neighbours).

I have a random, organic chaos structure which needs to have holes ...

thanks in advance
regards mogh

govinda
05-24-2008, 08:55 AM
Chestnuts (http://c4dplugs.com/viewPlug.php?RECORD_KEY%28PluginsRec%29=ID&ID%28PluginsRec%29=258&PHPSESSID=6f71bc128c75ec5bed9d1c3fb76e7fad) does that. Look for the Chestnuts Selector, or whatever it's called, in the plugin menu.

mogh
05-24-2008, 09:48 AM
hm Chestnut does also just select random polygons, but i need random polygons selected which are not neighbours to each other ...

so chestnut does more or less do the same than reselector ...
Thanks anyway. Anybody else an idea?

regards mogh

Darter
05-24-2008, 12:28 PM
This script seems to work okay. Let me know if there are any issues.

EDIT: See below for updated script.

Darter
05-24-2008, 01:10 PM
Here's an update which has an option to allow sharing of common points.

The script now has two different behaviours:
Shared edges are not allowed but shared points are allowed.
Shared edges are not allowed and shared points are not allowed.

EDIT: See below for updated script.

mogh
05-24-2008, 04:10 PM
Darter, oh so cool, and exactly what i was thinking off, thanks for that script ist will save me so much time in further artistic modeling aproaches ...

a big big timesaver ..
thank you, thank you, thank you,
if my proff lets me ill post some results soon ...

regards mogh

EDIT: How to get the script selecting every available "free" polygon it seems to miss some polys regardless how high i set the iterations number?

soccerrprp
05-24-2008, 05:00 PM
Thank you, Darter!


Richard

heathivan
05-24-2008, 10:55 PM
Hey, that is awesome. Thanks Darter!

---h

Cartesius
05-24-2008, 11:18 PM
Very useful!

/Anders

Darter
05-25-2008, 02:09 AM
Thanks to everyone for the feedback, I'm glad to see that the script is being found useful.

How to get the script selecting every available "free" polygon it seems to miss some polys regardless how high i set the iterations number?Well-spotted, this has helped me to refine the script.

When commonPoints is set to FALSE and the maximum selection size has been reached, you'll notice that it's not possible to select any additional poly without a common point being shared.

In the previous script, commonPoints = TRUE meant that at maximum selection size, selecting any additional poly would result in a total of two points being shared with *one or more* other polys. This was fine for smaller selections but meant that saturation occurred prematurely.

I've updated the script so that a candidate must share two points (i.e. an edge) with *a single poly* before being excluded.

The script now seems to have robust kahunas but feedback is always welcome.

EDIT: I was wrong about the kahunas.

mogh
05-25-2008, 09:57 AM
Hm with "commonPoints" set to FALSE its seems to still miss some polys, i think its about 8/ 2500 polys, so no big deal really ... juts to let you know ...

thanks for the script again !

And if you are in a coding mood ;-) just an idea for making it a real plugin, there could be a toggle for quads / triangles to be included or excluded ....

regards Mogh

Darter
05-25-2008, 10:54 AM
Thanks for the feedback. It's a lot easier to find and fix problems when others are also actively testing.

Using various meshes, I was unable to find any missed polys with commonPoints set to FALSE and an adequate number of iterations. If you're able to provide me with the mesh and settings, I'll fix any problems.

There are issues with triangles when commonPoints is set to TRUE and I'm working on this now. I'll be posting an updated version of the script when the problems have been resolved. The ability to toggle inclusion of quads and triangles should emerge as a by-product of this work.

Development of a plugin would depend on the level of interest in this tool and time constraints.

Darter
05-25-2008, 03:40 PM
Here's an updated version of the script. Version 1.1 had issues with triangles e.g. with commonPoints set to TRUE, only one poly would ever be selected in the ring at the top of a default sphere. This has been corrected and changes have been made which will hopefully see reliable behaviour in a variety of situations.

The script would benefit from extensive testing on meshes with various combinations of quads and tris. Any resulting feedback would be appreciated.

Options have been added to include/exclude quads and tris from selections. This makes five user-adjustable options, which is getting a bit clunky for a script.

Darter
05-25-2008, 10:35 PM
Still more issues with the script. Fixing one thing has again broken another.

Back into dry dock for a couple of days.

Rantin Al
05-25-2008, 10:59 PM
Seems to be working well.

I've tried the Common Points option with all flavours of Sphere and Platonic Objects.
Quads or Tris option works with a mixture of quads and manually triangulated selections on Platonic.
Variations of Sub-divide, Triangulate and Untriangulate all respond to the script.

Cheers, Alan.

Darter
05-25-2008, 11:34 PM
Thanks Alan, this is valuable feedback. I appreciate your taking the time to run the script through its paces and it's good to know that it's working in those situations.

Here's an example of the problem I discovered this morning. On a randomly triangulated plane, tris and quads are sharing common edges. This didn't happen with the previous version.

There was an old lady who swallowed a fly...

LemonNado
05-25-2008, 11:55 PM
I'm sure that you'll give that old lady a good swat on the back so she spit's that bug right out.... Would it be asked to much if there would be an angle option? So it randomly selects only poly's facing away a certain amount of degrees. Hope the old lady does not get sick hearing about this request.

Cheers
Rainer

Rantin Al
05-26-2008, 02:59 AM
I don't know if this is much help, but here goes anyway.

Using platonic objects, there is a bit of a pattern to the common edge problem.
The Green is the random selection with Red marking the faulty edge. It seems to be localized to two pairs of polygons. Depending on running the script with either no or one polygon selected, then 2 or 1 common edges get selected.

The Blue is an initial 2 polygon selection, adjacent to one of the faulty pairs.
This seems to 'fix' the problem, or at least break the selection sequence.

Notice the similarity of the selection patterns in the Top & Front views.
I don't know if this is a topology or index 'thing'.
Maybe it is the wrong track, but it's interesting in a geekish sort of way. :D

My file attached anyway. Alan.
But there's a hole in my bucket, dear Lisa. A hole!

Darter
05-26-2008, 05:41 AM
I'm sure that you'll give that old lady a good swat on the back so she spit's that bug right out.... Too late, the old lady's parrot has just disappeared.

Would it be asked to much if there would be an angle option? So it randomly selects only poly's facing away a certain amount of degrees.Thanks for the suggestion. An angle option should be doable, I'll look into it once I'm sure the current features are working properly. The need for a gui is increasing by the day...

Using platonic objects, there is a bit of a pattern to the common edge problem. Thanks for taking the time to do some systematic testing, this sort of feedback is greatly valued.

I think I've sorted out the problem. I've tested the latest version on objects with different combinations of quads and tris, including your platonic objects, and it seems to be working properly now.

Please download on the understanding that this may not be the final version.

Gunter
05-26-2008, 07:19 AM
wow ... works like a charm :thumbsup: Thanks a lot Darter.

tcastudios
05-26-2008, 12:13 PM
Took the liberty to add a rudamentary dialog for your cool script Darter.
Might be of help for further setups.

Cheers
Lennart

SilverCity
05-26-2008, 12:36 PM
Thanks for all your work on these scripts, Darter and tcastudios. I'm surprised a plugin never was developed for such a purpose. I know I could have used this for past projects.

LemonNado
05-26-2008, 01:40 PM
Amazing! And what a nice script sample to pick apart and learn!
Rainer

mogh
05-27-2008, 07:07 AM
This is really a showcase of the C4D community... thanks to all.

Keep in mind that the Iterations can be much higher than your Objects Polycount, to catch all free "floating" Polygons

(tcastudios your dialogue max setting is way to low respective to that; 2000 max iterations is easily reached)

i think this thread should be linked in the scripts subforum so it doesn't get lost.

Thanks to all that helped and especially Darter.
regards mogh

tcastudios
05-27-2008, 08:36 AM
First , all cred is Darters, I just added the dialog for myself.
As for max iteration, go to line 62 in the script and change the max (currently 2000)
to the value you need. Use "Save All" on top of ScriptManager or accept changes upon
closedown of Cinema to keep the new settings.



MyDialog::Init()
{
SetCheckbox(IDC_P, 0);
SetCheckbox(IDC_Q, 1);
SetCheckbox(IDC_T, 1);
SetInt(IDC_I, 200,0,2000,1); // <- change the max (currently 2000) to a new value
SetInt(IDC_R, 2,0,2000,1);
}


Cheers
Lennart

Darter
05-27-2008, 09:16 AM
Thanks to everyone for their input into the script, which wouldn't have come about without mogh's initial concept.

As the random function will generate a given number more than once, iterations may have to be several times the poly count before all poly indices have been tested. If a sparser selection is desired, the iterations setting can be much lower.

There are diminishing returns as iterations are increased.

Rantin Al
05-27-2008, 02:36 PM
Another discovery. :lightbulb

If you simply drag the Script Editor icon in to the viewport, it adds it as a HUD element which instantly opens the Dialogue window with a single click.

Thanks to all for the idea and creation of another handy tool. :beer:
Cheers, Alan.

Ernest Burden
12-01-2008, 03:47 PM
I finally had a chance to try this out. I use random selections quite often, so I'm really glad to have it. Previously I've used a free plugin called 'RandomMaterial'. It lacks the ability to avoid shared-edge polygons and tends to select clumps. This great script solves that problem.

But what that old plugin does offer that this script does not seem to is the ability to force a certain number of selections. You set some number, let's say six, and it randomly selects all polys forcing them into six selection tags. Sometimes there is overlap, which causes problems, and the clumping I mentioned which requires manual editing. Is it possible to have a script like this use all polys and create selection tags?

What I did testing this was to do the random selection, split then delete...repeat until I had a number of random groups. That works fine, just wondering if its a simple matter to add that function to this script. I'm not skilled in coding these things, so I can't add it myself.

The reason I use random a lot is to add variation to tiles in architectural scenes. I make a few copies of the material and slightly alter color, bump or simply move the texture mapping so a stone pattern does not cross to a neighbor tile.

Darter
12-01-2008, 08:12 PM
Were you using my Random Materials to Polygons (http://forums.cgsociety.org/showthread.php?f=182&t=289449&page=3&pp=15) script? There's no overlapping of textures but as mentioned, it does allow shared-edge polys.

I'll have a look at combining the functionality of the two scripts. I'm away from my computer till tomorrow.

Ernest Burden
12-01-2008, 08:17 PM
Were you using my Random Materials to Polygons (http://forums.cgsociety.org/showthread.php?f=182&t=289449&page=3&pp=15) script?

No, actually, though that does look good, also. I have a plugin that I think came from a Japanese site a long time ago. It's not a script.

Here's the listing, though the site has gone 404:
www.c4dplugs.com/viewPlug.php?RECORD_KEY(PluginsRec)=ID&ID(PluginsRec)=356&PHPSESSID=e4cf3b9cc821c5c7d532e7f471b7aa5c (http://forums.cgsociety.org/c4dplugins%20page)

Hummm....the link doesn't seem to work once I paste it in. Doesn't really matter, the site hosting the plug is gone anyway. The search is for Random Material.

CGTalk Moderation
12-01-2008, 08:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.