Access neighboring Primitives.

   2205   1   1
User Avatar
Member
126 posts
Joined: 8月 2010
Online
I'm attempting to set up a sort of sub-division algorithm in Houdini, and I've reached a step where it would be very convenient to get access to the neighboring primitive. Now I'm not sure how to do this, and I would like to know if there is any function from Vex or Python I could use?

I've attached an animated GIF illustrating my problem. I would need a mean to access to pair of “over-stretched” primitives, and divide them along the shortest diagonal.

I define “over-stretched” based on a threshold against the sqrt(area) / perimeter.

Any ideas? Thanks in advance!

Attachments:
Problem-Illustration.gif (71.3 KB)

User Avatar
Member
4521 posts
Joined: 2月 2012
Offline
If you are looping over primitives, you can do it using the geometry functions:
https://www.sidefx.com/docs/houdini13.0/vex/geometry [www.sidefx.com]

Just loop over the vertices of the primitive using vertexindex() and primvertexcount() and convert them into point numbers using vertexpoint (Documentation is wrong in the main page. vertexpoint and pointvertex is swapped, showing wrong signatures. Bug ID# 21599).

Then form a point pair as an edge from this point array: i, i+1.

Then use a function like this:

string GetPrimsFromEdge ( int input; int pt0; int pt1 )
{
    string prims;
    int hedge = pointedge ( input, pt0, pt1 );
    if ( hedge != -1 )
    {
        int count = hedge_equivcount ( input, hedge );
        for ( int i = 0; i < count; ++i )
        {
            int pr = hedge_prim ( input, hedge );
            if ( pr != -1 )
            {
                prims += itoa ( pr ) + "-";
                hedge = hedge_nextequiv ( input, hedge );
            }
        }
    }
    return prims;
}
Edited by animatrix_ - 2023年12月10日 09:28:27
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
  • Quick Links