PDA

View Full Version : creating groups of connected polygons



stib
02-03-2008, 01:13 AM
I'm trying to apply random transforms on groups of connected polygons, like they were separate objects. I've got it working, but it's as slow as a wet week when you've got a lot of polygons (which is when you really want to use it). Here's the code I use for separating the polygons into groups



editbegin();
SelectedPolys = polygons; //we'll keep this array for later when we tidy up

leftoverPolys = SelectedPolys;
i=1;
editend();
//a bit of juggling here
while(leftoverPolys)
{
//find first polygon we haven't connected yet
firstPoly = leftoverPolys[1];
selpolygon(CLEAR);
selpolygon(SET, POLYID, firstPoly); //select only that poly
selpolygon(SET, CONNECT); //select all connected polys
editbegin();
//create a new poly group of all connected polys
polyGroups[i]=polygons;
editend();
selpolygon(CLEAR);
//select the original group of polygons
selpolygon(SET,POLYID,leftoverPolys);
//remove any polygons in this new group
selpolygon(CLEAR, POLYID, polyGroups[i]);
selmode(DIRECT);
//have to go into direct mode here or the loop never ends,
//because no polys = all polys in user mode
editbegin();
//and this is the leftovers we have to work with
leftoverPolys = polygons;
editend();
selmode(USER);

i += 1;
}

I'm sure someone has done this before, is there a better way of doing it?

By the way if you feel like beta testing it for me you can get it here (http://pureandapplied.com.au/the_scaterator.zip)
-stib

stib
02-05-2008, 05:35 PM
Surely there is a way of doing that with array manipulation, without actually having to select and deselect the polygons? I'm taking the silence to be a resounding no.

When I run this I can actually see the selecting and de-selecting happen. It's entertaining to watch, but it's almost slower than I could it manually. Why is selecting and de-selecting so slow with lscript?