NoSOPforStupidity Posted May 5, 2022 Share Posted May 5, 2022 Top level goal is that I want to take incoming objects that are quads and triangulate each polygon, but alternating direction of the triangulation from one poly face to the next. This is easy for clean meshes generated in houdini. My issues is I'm importing a wide variety of objects from other DCCs and often the primid and vert order is totally randomized. I have tried to get a perfectly clean selection of alternating faces by all kinds of sort methods, I tried and failed to proceedurally generate a uv and set the prim id's based on the uvs, and nothing seems to work. Imagine a flared cylinder for the simplest example but each vert and prim id totally randomized, how would you get a group defined of every other prim like a checkerboard? Thanks! Quote Link to comment Share on other sites More sharing options...
animatrix Posted May 5, 2022 Share Posted May 5, 2022 Hi, If your geometry's topology is uniform without poles unlike the one I am using, here is one way you could do it: function int [ ] getPrimNeighbours ( int input; int pr ) { int allprims [ ] = { }; int hedge = primhedge ( input, pr ); for ( int i = 0; i < primvertexcount ( input, pr ); ++i ) { for ( int f = 0; f < hedge_equivcount ( input, hedge ); ++f ) { int hedgeNext = hedge_nextequiv ( input, hedge ); int primindex = hedge_prim ( input, hedgeNext ); if ( primindex != pr ) append ( allprims, primindex ); hedge = hedgeNext; } hedge = hedge_next ( input, hedge ); } return allprims; } int firstprim = chi("first_prim"); setprimgroup ( 0, "prims1", firstprim, 1 ); int allprims [ ] = array ( firstprim ); int lastprims [ ] = array ( firstprim ); int index = 1; int primcount = -1; while ( primcount != 0 ) { string groupname = index % 2 ? "prims2" : "prims1"; int newprims [ ] = { }; foreach ( int pr; lastprims ) { int connected [ ] = getPrimNeighbours ( 0, pr ); foreach ( int c; connected ) { if ( find ( allprims, c ) < 0 ) { append ( allprims, c ); append ( newprims, c ); } } } lastprims = newprims; foreach ( int pr; newprims ) setprimgroup ( 0, groupname, pr, 1 ); primcount = len ( newprims ); ++index; } 1 Quote Link to comment Share on other sites More sharing options...
NoSOPforStupidity Posted May 5, 2022 Author Share Posted May 5, 2022 (edited) Thanks a ton! I really appreciate you sharing this! Is there any way to leverage this to understanding of what's connected to unify the direction that a divide operation would be applied in? My goal is to turn quads into alternating triangles like below: Your vex helps me isolate every other poly even if the primids are randomized, but not sure how to make sure the divide orientation is uniform... likely should be its own thread but figured i'd ask: Edited May 5, 2022 by NoSOPforStupidity Quote Link to comment Share on other sites More sharing options...
animatrix Posted May 5, 2022 Share Posted May 5, 2022 (edited) Did you try Reverse SOP -> Shift -> U Offset = 1 for one of the primitive groups, and then adding a Divide SOP after? Edited May 5, 2022 by animatrix Quote Link to comment Share on other sites More sharing options...
NoSOPforStupidity Posted May 5, 2022 Author Share Posted May 5, 2022 (edited) 16 minutes ago, animatrix said: Did you try Reverse SOP -> Shift -> U Offset = 1 for one of the primitive groups, and then adding a Divide SOP after? I just did and that works to flip them! unfortunately my issue is that the orientation of the divide is not unified for the group to begin with. I think I need help unifying the direction for all of the prims on the object, and then im good to reverse the direction for just one of the prim groups. Edited May 5, 2022 by NoSOPforStupidity Quote Link to comment Share on other sites More sharing options...
NoSOPforStupidity Posted May 5, 2022 Author Share Posted May 5, 2022 Was able to solve this in the alternate thread I'd created! Thanks again for your help Animatrix!! https://forums.odforce.net/topic/50800-how-to-unify-orientation-of-a-divide-sop/ 1 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.