Jump to content

Selecting primitive based on angle


dolexd

Recommended Posts

Hello,

I am trying to select two primitives (105 - 106 from the image attached) based on the angle but I am not sure how. I have tried the group and delete but I can't get it to work. Can anyone please help? Since the primitive number changes based on an external attribute (height), I can't just select these two and group them. :(

 

Thank you for your help.

primitiveSelect.thumb.PNG.7923dac916cd5608ad0029b4c77e37a7.PNG

Link to comment
Share on other sites

Hi,

You can first group the edges using a Point Wrangle:

float getAngleBetweenVectors ( vector v0; vector v1 )
{
    vector v0n = normalize ( v0 );
    vector v1n = normalize ( v1 );
    return atan2 ( length ( cross ( v0n, v1n ) ), dot ( v0n, v1n ) );
}

int pts [ ] = neighbours ( 0, @ptnum );
foreach ( int pt; pts )
{
    if ( @ptnum < pt )
        continue;
        
    int prs [ ] = { };
    
    int firsthedge = pointhedge ( 0, @ptnum, pt );
    int count = hedge_equivcount ( 0, firsthedge );
    if ( count == 2 )
    {
        int hedge = firsthedge;
        
        do
        {
            int pr = hedge_prim ( 0, hedge );
            if ( pr != -1 && find ( prs, pr ) < 0 )
                append ( prs, pr );
                
            hedge = hedge_nextequiv ( 0, hedge );
        }
        while ( hedge != firsthedge );
        
        vector n0 = primuv ( 0, "N", prs [ 0 ], 0.5 );
        vector n1 = primuv ( 0, "N", prs [ 1 ], 0.5 );
        
        float angle = getAngleBetweenVectors ( n0, n1 );
        if ( angle >= radians ( ch("minangle") ) )
            setedgegroup ( 0, chs("vex_selectiongroup"), @ptnum, pt, 1 );
    }
}

Then convert this edge group into a primitive group using a Primitive Wrangle after setting the Group parameter to the resulting edge group:

i@group_newprims = 1;

LiWosxB.png

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...