Smicksus Posted February 21, 2023 Share Posted February 21, 2023 Hi there, I'm working on a setup where I need to find the longest side of a triangle and sort the points based on that. Can someone help me out here with the vex? I've attached an image what needs to happen: - I have triangle with random point order from 0, 1, 2. (eventually in a for each primitive with lots of triangles) - I need the point order to be 0 and 1 on the longest edge and 2 needs to be on the remaining point. I've attached a simple hip scene for practice. Thanks in advance for the help! This would help me a lot Traingle_sort_debug.hip Quote Link to comment Share on other sites More sharing options...
animatrix Posted February 21, 2023 Share Posted February 21, 2023 Hi, You can write some VEX in a Primitive Wrangle SOP like this: int pts [ ] = primpoints ( 0, @primnum ); vector pos [ ] = array ( ); foreach ( int pt; pts ) { vector p = point ( 0, "P", pt ); append ( pos, p ); } int closed = primintrinsic ( 0, "closed", @primnum ); if ( closed ) { append ( pts, pts [ 0 ] ); append ( pos, pos [ 0 ] ); } int count = len ( pts ) - 1; for ( int i = 0; i < count; ++i ) { float s = distance2 ( pos [ i ], pos [ i + 1 ] ); setpointattrib ( 0, "length", pts [ i ], s ); } Then sort points using the length attribute with a Sort SOP, and make sure to turn on Reverse Point Sort. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.