[Sidefx-houdini-list] new points at center of poly faces
szymon.kapeniak at gmail.com
Wed Mar 30 05:16:01 EDT 2011
Also prim_attribute() evaluating "P" at s=t=.5 will return centroid of a quad primitive, so this can be handled in pure vex. The only catch is that centroid for a triangle is at 0.3 not 0.5, and for ngons > 4 is at t=1.0... ;)
Dnia 30 mar 2011 o godz. 09:20 sgustafso at gmail.com napisał(a):
> One approach that's reasonably efficient:
> Create a vector primitive attribute called 'center' with values $CEX,$CEY,$CEZ. When creating primitive attribs, the $CE[XYZ] vars refer to the primitive centroid.
> Use a line sop with npoints set to nprims() to create your points, then delete the line prim but keep the points. This can be slightly more efficient that going through a copy sop (especially a copy sop with transforms!) for high point counts if you just need to create a bunch of points and move them later. ymmv.
> Use a primattrib vop inside of a vopsop to apply the 'center' attribute to the points. primattrib expects a geometry file, but you can feed it an op path. I usually set the oppath with an expression like: "op:`oppwf()`/../SOURCE_GEOM[$FF]"
> That should do it. So brief recap: attribcreate to get an attrib holding the centroid, whatever method you want to instantiate a bunch of points to move, then vopsop to set the positions.
> Another trick for getting the centroids is to use attrib promotions. I.e,. create point attrib 'pos' set to $T[XYZ], then promote to a primitive attrib with the mode set to average, leaving you with an attrib holding the centroids. I've used this in the past before I realized that $CE[XYZ] would work, and it seemed to scale pretty well.
> At Wed, 30 Mar 2011 17:33:36 +1000,
> Rangi Sutton wrote:
>> add sop.. copy sop with nprims("../PRIM_SRC") in the num copies, and in
>> translates use prim("../PRIM_SRC", $CY, "P", 0).
>> Make an asset. Forget about it. Maybe python does this better.
>> Actually, I think there's an asset in that toolbox that was posted the other
>> day that does this.
>> scaling prims to zero does work though.. can be a problem if you have
>> identical prims.. since they'll fuse.
>> On 30 March 2011 17:24, Miles Green <Miles.Green at al.com.au> wrote:
>>> I need to efficiently get a new point at the center of all my current poly
>>> i'm sure there are multiple ways to do this, but my current method of :
>>> [input polygons]-->[facet(uniquepoints]->[primitive (scale to 0.001)]->
>>> is a little slow..
>>> any other suggestions appreciated
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
More information about the Sidefx-houdini-list