PDA

View Full Version : How to?: bunch of disconnected parts, want a point at center?



jeric_synergy
03-14-2013, 01:19 AM
Imagine an array of objects, unconnected.

I'd like a second layer full of points, one point per each object, at the center of that object.

How would I do something like that?


THANKS!

jeric_synergy
03-14-2013, 01:23 AM
Answer= "Collapse Polygons"

I didn't know "Collapse Polygons" would do that!

hrgiger
03-14-2013, 07:53 AM
I was unaware of collapse polygons but I would have also said you can just kill the polys (k) and then weld average them, with the same result. But collapse polys is quicker.

jeric_synergy
03-14-2013, 08:53 AM
I was unaware of collapse polygons but I would have also said you can just kill the polys (k) and then weld average them, with the same result. But collapse polys is quicker.
That would have required selecting EACH part point group separately. COLLAPSE POLYGONS will do it on polygon 'islands'.

The idea here is to reduce a scattered array to representative points.

hrgiger
03-14-2013, 09:05 AM
Thats why I said collapse polys is quicker. Are you using this for instancing?

jeric_synergy
03-14-2013, 11:57 AM
Thats why I said collapse polys is quicker.
Well, that's a massive understatement then.


Are you using this for instancing?
Nope: the hope is to generate proxy objects for faster Bullet calculations.

Ideally this would allow me to use proxies for Bullet, bake it, and then attach the full object via HardLink. I'm not sure that's possible.

Something that generated a GOOD bounding box (defined as "one that tilts to accomodate the object") would be welcome too, for arrays that have used some rotation on the full object.

prometheus
09-30-2016, 11:11 PM
This is a longshot, for future reference..
just use create/points/add center point..works on selected poly (single on itīs flat face) or if a whole segment is selected, it adds a center point on that..if you have more unconnected segments, you have to select manually(select connected) each single segment (not single face) and run the add center points, if nothing is selected it would place a center point based on All segments, if there is only one segment and nothing selected, it will place a point in that objects segment center.

Another way would be to use the layer tab and layer panels..send unconnected segments with the connected to layers command, then select the layers in the layer panel and run the add center point.

Now I need to find a simple script that just places a center point on selected faces..add center point only works on one poly, or full segments to put a point in the center of that, but not individual selected faces...weird that I can not find that.

Kryslin
10-01-2016, 12:33 AM
Here ya go...

Copy and Paste to notepad, and save it as whatever.ls


@warnings
@name Add Centers

//Version 1.00
//by Steven Pettit 01 Oct 2016

main{
var i = 0;
var q = nil;
var p = nil;
var cp = <0,0,0>;

selmode(USER);

editbegin();
foreach(p,polygons){
cp = <0,0,0>;
pc = p.pointCount;
for(i=pc;i>0;i--){
cp += pointinfo(p.points[i]);
}
cp /= pc;
q+= addpoint(cp);
}
editend();
selpolygon(CLEAR);
selpoint(CLEAR);
selpoint(SET, POINTID, q);
}

prometheus
10-01-2016, 01:50 AM
Here ya go...

Copy and Paste to notepad, and save it as whatever.ls


@warnings
@name Add Centers

//Version 1.00
//by Steven Pettit 01 Oct 2016

main{
var i = 0;
var q = nil;
var p = nil;
var cp = <0,0,0>;

selmode(USER);

editbegin();
foreach(p,polygons){
cp = <0,0,0>;
pc = p.pointCount;
for(i=pc;i>0;i--){
cp += pointinfo(p.points[i]);
}
cp /= pc;
q+= addpoint(cp);
}
editend();
selpolygon(CLEAR);
selpoint(CLEAR);
selpoint(SET, POINTID, q);
}


Wow...thatīs great, it works as it should for me, in lw 2015.3 32 bit, if nothing is selected and if you have several boxes in the same layer, it creates a point on each face, that may come handy too.
Not always I would use mg ultimate clone or place mesh to place parts on selected polygons, so this is great...many thanks.

for jerics wishes...this also yields a point at the center of every segment object, but ..I think he would like to have it skip the outside faces, should be possible to eliminate some line here in the script for that.

We need to get this to the plugin database as well I think.

jeric_synergy
10-01-2016, 10:23 AM
Here ya go...

Copy and Paste to notepad, and save it as whatever.ls
Wow, thanks Kryslin.

This thread started in 2013-- to tell you the truth, I disremember why I needed this. But I got it now! :bowdown:

Kryslin
10-01-2016, 10:32 AM
I'm glad it's useful... I got tired of manually doing a lot of trivial tasks, so I've a few dozen of these small, fire and forget lScripts lying around. This one I had to rebuild from the ground up, though.

I use a variation of this script to generate the start of hair guides for Sasquatch and FiberFX; That one actually creates a short spline aligned with the polygon normal, at the center.

Ideally, I'd like to do a even distribution of an arbitrary number of points over an equally arbitrary surface, for the same purpose (in roughly the same pattern sunflowers have for seeds on their flowers), but that's beyond the scope and topic of this thread. :)

prometheus
10-01-2016, 05:30 PM
Thanks again kryslin...applying the script makes points at center, and at each polyface as well as center origion of segment, I found this useful toghether with the line pen tool, If I use the line pen and hold shift while hovering over any point..a guide is presented, right middle mouse and drag to draw a line out from itīs normal, or simply select the points created from your script and hit extend and size...this gives me axis guides in straigh normal directions based on the centers in the form of a polyline, that can be used when using axis rotate and simple click on those lines and drag a tiny guide snapping parallell along that guide, then mouse drag and you will be able to rote around any axis you have made this way you could probably use the transform tool as well and right click to snap to a normal, but with this I get precise guides and it feels a bit easier to know there the axis are and how to rotate it.


I will try and record this with your script then using both line pen and axis rotate, though I need to buy me a new keyboard before that since my buttons are screwed up, I want to show more uses of the line pen as well, such as using it to fix ngons, and making polygons and dimension lines.

jeric_synergy
10-01-2016, 10:23 PM
Ideally, I'd like to do a even distribution of an arbitrary number of points over an equally arbitrary surface, for the same purpose (in roughly the same pattern sunflowers have for seeds on their flowers), but that's beyond the scope and topic of this thread. :)
I don't understand how you can have a pattern (the Fibonacci sequence, no?) AND an arbitrary surface. Sounds like it would just be superimposed on the b.box of the selected polys, which shouldn't be too hard. Unless you are talking about each polygon? I'm missing something here.

Kryslin
10-01-2016, 11:55 PM
I would like the pattern to generate across a surface, namely a user defined mesh, with the number of points defined by the person invoking the script. I'm still trying to figure out how to generate the pattern in 2D... It's for a more natural looking way to distribute guides for hairs.

The idea is to generate the pattern in 2D, and project it onto the surface. That gets into triangle-ray intersection, a non-trivial matter. Ray/Plane is easy enough, that give you a coordinate to solve for in a rather messy set of equations to see if your point lies within a triangle...

jeric_synergy
10-02-2016, 12:01 AM
So, would that be a spherical projection? This sounds a lot like the problems any projection is going to have, so maybe the same mathematical (non-trivial) solutions can be applied.

For starters, you could just solve for Ye Olde Traditional projections: planar, spherical, and cylindrical. By the time you go that figured out you'd be familiar w/the math to tackle what sounds like essentially UV projection.