konstantin magnus Posted September 10, 2017 Share Posted September 10, 2017 (edited) How can I read the U coordinate (from 0 to 1) of closed primitives in VEX? I tried xyzdist and primuv ... int prim; vector uv; xyzdist(0, @P, prim, uv); v@uv_profile = set(uv.x, 0, 0); ... but I only got results that did not represent the relative distance between the vertices. Edited September 10, 2017 by konstantin magnus Added sketch Quote Link to comment Share on other sites More sharing options...
galagast Posted September 11, 2017 Share Posted September 11, 2017 Hi, would a non-vex approach fit your needs? 1. Convert SOP: Convert to Nurbs; U Order 2. 2. UV Texture SOP: Type Arc Length; Attrib as Point. 3. Use the resulting uv.x point attribute. u_coord.hiplc - H16.0.689 Indie Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 11, 2017 Author Share Posted September 11, 2017 Thank you! But yes, I am more looking for a VEX solution.. Quote Link to comment Share on other sites More sharing options...
galagast Posted September 11, 2017 Share Posted September 11, 2017 No worries, I tried to have go at it in VEX, but I'm not entirely sure if the results are correct or accurate. In the attached file, as it turns out, the initial SOPs method (in red) I suggested does seem to appear incorrect when laid out as a straight line. The VEX method (in green) seems to visually appear more correct. Compare the points 4 to 8.. If I turn off the Closed toggle of the Curve SOP, the RED line will match the GREEN line. Have a look at the setup, and see if it anywhere near the direction you wanted.u_coord2.hiplc - H16.0.689 Indie My head is kinda twirling at the moment, I may need to sleep this through for now :)) Cheers! Jeff 2 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted September 11, 2017 Share Posted September 11, 2017 @galagast, thanks! I updated my own snippet with closure check to work like yours. Here is what I got: // Detail wrangle. float length = primintrinsic(0, "measuredperimeter", 0); // Set to false if value of 1.0 is unwanted for the last point // of closed prims and instead need to be treated as if point with // u=1 is coincident with the first point (like in unrolled prims). int as_open = true; // Compensate for closing auto-edge length. if (as_open && primintrinsic(0, "closed", 0)) { vector auto_edge = point(0, "P", 0) - point(0, "P", @numpt-1); length -= length(auto_edge); } // Compute curve u. float passed = 0; for (int i = 1; i < @numpt; i++) { vector d = point(0, "P", i) - point(0, "P", i-1); passed += length(d); setpointattrib(0, "u", i, passed/length); } Difference between behaviors "as open" and "as unrolled": 2 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 11, 2017 Author Share Posted September 11, 2017 (edited) Alright, thank you both! I mainly wanted to make sure I am not missing something obvious. Like there is no intrinsic U attribute or a dedicated function. Edited September 11, 2017 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
satoru Posted September 12, 2017 Share Posted September 12, 2017 (edited) I think primuvconvert function will be helpful for intrinsic uv attribute. An example of code to get relative distance between the vertices. // Run Over -> Points int prim; vector uv; xyzdist(0, @P, prim, uv); int mode = 4; // PRIMUV_UNIT_TO_UNITLEN u@uv_profile = primuvconvert(@OpInput1, set(uv.x, 0.0), prim, mode); Edited September 12, 2017 by satoru 3 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 12, 2017 Author Share Posted September 12, 2017 8 hours ago, satoru said: I think primuvconvert function will be helpful for intrinsic uv attribute. Really great! Thank you! 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.