CinnamonMetal Posted March 30, 2018 Share Posted March 30, 2018 How do I access the first point of a primitive; simply using point() doesn't seem to access the correct point; for example, if a primitive has numbers 1,11,0,10 for example I want to access or explicitly access a specific point of a primitive within a forLoop SOP ? Each primitive from my understanding appears to have a center point, can this center point be re-positioned for a primitive ? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 30, 2018 Share Posted March 30, 2018 http://www.sidefx.com/docs/houdini/vex/functions/primpoints.html Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted March 30, 2018 Author Share Posted March 30, 2018 Aye but, I assume if want to sort each primitive number from 0-n in a clockwise fashion; I have to use the SortSOP, correct ? And if so, how do I sort primitive numbers in a clockwise fashion ? Outside the forEach SOP look, the primitive numbers revert to their default, if my theory is correct ? Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted March 30, 2018 Share Posted March 30, 2018 You should read this : http://www.sidefx.com/docs/houdini/vex/halfedges There are lots of functions that allow you to play with geo and iterate over each primitive vertex or point (pointhedgenext etc. see the list on the link). If what you want to access is the barycentre of each primitive, you can use a primitive Wrangle node and have it for free using @P in your expressions (but you can't modify it : if you want to move a primitive, you have to move the points themselves). What do you want to achieve ? Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted March 30, 2018 Author Share Posted March 30, 2018 Those functions are not available in H15; is there a method without those functions ? I want to sort each primitive from 0-n based on how many points there are per primitive counter clockwise. Second from my understanding a primitive always rotates around it's barycentre / pivot; but I want to change that per primitive. Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted March 30, 2018 Share Posted March 30, 2018 For the first problem (see the other post we discuss on), that’s indeed not a tricky problem... For changing the pivot point of a primitive, that’s easy : you just create a vector attribute that will store the pivot coordinates you want to play with, then just use that attirbute into a Primitive node to transform each of them (with its own pivot) Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted March 30, 2018 Author Share Posted March 30, 2018 The other post being the functions which are only in H16 as you mentioned here ? I have to get access to the pivot coordinates Which is why I want to know how I can sort all primitives from 0-n in a clockwise method ? Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted March 30, 2018 Share Posted March 30, 2018 Sorry, my bad : sorting primitives in a clockwise manner is not easy (and not tricky), I would need to think more about it.. The other problem, accessing each primitive barycenter through the primitive Wrangle, is easy (depending what you need to do with it). And using the Primitive SOP node allow you to change the pivot of each primitve and use it for rotation (on a per primitive base). I don’t think you need to sort the primitives to find/change their pivot :-) Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted March 30, 2018 Author Share Posted March 30, 2018 Quote Sorry, my bad : sorting primitives in a clockwise manner is not easy (and not tricky), I would need to think more about it.. I hope you can Remember re-sort so it's sorted clockwise from 0-n (n being the total number of points for the primitive) I attempted the PrimitiveSOP turning off the expressions for the Pivot channel then re-positioning the pivot; the results were not exactly, good How do you access each primitive barycenter though a primitive wrangler ? Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted March 31, 2018 Share Posted March 31, 2018 Ok, so as I did not really understood what you aim to achieve, and based of the different posts where we talked, I have prepared a small file where you can see what I meant. I am really not sure this is what you want, but maybe it's a start :-) I haven't sorted the prim numbers, as I did not understood you last sentence ("n being the total number of points for the primitive" : does that mean that your problem is how the points are "ordered" into your primitive ? I thought you wanted each prim number to change in spiral around one center primitive...). Anyway, about how to rotate each primitive around a center of gravity you want to play with, please find a file with an example. It is in Houdini 15.5, I did not have 15, so I hope you can open it... But that's simple : I have a sphere node setup on polygon, then I add a ForEach Subnetwork (not the loop) setup on "Each Primitive/Points", then a Primitive Wrangle node with a single line v@cog = @P; , then a Primitive SOP node, setup with Do Tranfsormation and for each component of the pivot I have @cog.x then @cog.y and @cog.z and you can add some rotation and see the result. Basically, the ForEach Subnetwork allow to merge each primitive at each step, which means that I have much more points than for the initial geometry (I have the same number of points than I had vertex in the sphere node). This allow to move/rotate each primitive individually : if you don't do that, it means that some primitives will share common points (because a primitive is a bunch of vertices that refer to "physical" points), and therefore, if you move one point, you move it for both primitives... Once this is done, I add a Prim Wrangle node to create an attribute called cog (short for center of gravity :-)) that I make equal to @P, who is the center of the primitive. But once you are in the wrangle, you are free to put this attribute elsewhere, depending on your needs. Then I use a Primitve SOP node to transform each primitve, based on the pivot defined by this new attribute that I called cog earlier. Hope this is clear :-) rotatePrim.hip Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted March 31, 2018 Author Share Posted March 31, 2018 7 hours ago, StepbyStepVFX said: I haven't sorted the prim numbers, as I did not understood you last sentence ("n being the total number of points for the primitive" : does that mean that your problem is how the points are "ordered" into your primitive ? I thought you wanted each prim number to change in spiral around one center primitive...). I'll explain, when I said "n being the total number of points for the primitive" what I meant was, if the primitive should so happen to have 5 points or 6 points etc then I want the point order to be clockwise based on how many points exist for the primitive. For each primitive, assuming it's a quad, make the point order begin in the lower left hand corner and go around the quad primitive in a clock wise motion; the top left hand corner would be point 1 etc etc. Remember point 0 was in the lower left hand corner. Each primitive has the same point order, only within the forLoop sop. I still do want each primitive number to be sorted based on a spiral, with primitive 1 being somewhere in the center. I'm going to take your last suggestion specifically related to this question and try to create something in hope it works; I'll post hoping I make some progress. Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted March 31, 2018 Share Posted March 31, 2018 Ok, that's more clear. Look at the file I joined, because I think that after the ForEach Subnetwork, the point are ordered clockwise naturally, as it recreate points for each primitive. By the way, the vertices are ordered, so maybe using the vertices instead of points can help you. And there are VEX functions to find points behind vertices. Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted March 31, 2018 Share Posted March 31, 2018 On 30/03/2018 at 7:58 PM, CinnamonMetal said: Those functions are not available in H15; is there a method without those functions ? I believe those functions are already available in H15 : http://www.sidefx.com/docs/houdini15.0/vex/halfedges#functions You should have a look at them, very useful for what you intend to do :-) Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted March 31, 2018 Author Share Posted March 31, 2018 In your scene you posted RotatePrim.hip; when viewing the object in the geometry spreadsheet vertices tab; you see there is a primitive face which has three vertices followed by the point number. When looking at face 0, there is 0,1,2 but when you look at face 1 it's point number is 5,4,3. If each primitive is separate from the next primitive then rather then primitive or face 1 having a point number of 5,4,3 it too has a point number of 0,1,2 and the same is said for primitive 3 and 4 and 5 and so on ? Actually come to think of it, unless there is a method using points, vertices seem to follow the pattern to which I want, as I believe you were pointing at @StepbyStepVFX. Question is, how do I view vertex number; and how do I find the center between to vertices ? Secondly if primitives have centers(pivots) by default how can I view them ? Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted April 1, 2018 Share Posted April 1, 2018 (edited) 11 hours ago, CinnamonMetal said: Actually come to think of it, unless there is a method using points, vertices seem to follow the pattern to which I want, as I believe you were pointing at @StepbyStepVFX. Question is, how do I view vertex number; and how do I find the center between to vertices ? Secondly if primitives have centers(pivots) by default how can I view them ? Vertices should indeed helps you find the points of a primitive in a clockwise manner, because if not, it means your primitive is self-intersecting. In your geometry spreadsheet, when you click on the little dot that says "Vertices", you see they are ordered using the pattern primitve:vertexnumber, and then for each vertex you have the point number to which the vertex refer to (in the file I sent, you have one point for one vertex, but for the standard sphere, you'll see that one points appears several times, for several vertices). If you want to work through VEX : for each primitive you can find the list of its vertices using the primvertices function http://www.sidefx.com/docs/houdini15.0/vex/functions/primvertices Then you can use vertexpoint to find the point behind a vertex : http://www.sidefx.com/docs/houdini15.0/vex/functions/vertexpoint Once you have two vertices, you can search their respective points, average those two positions and then you have your center between two vertices. As mentionned in another post : you can't view the primitive center in the geometry spreadsheet, but you can easily create an attribute for each primitives that contain its center : it is what I have done in the file I shared with you with the attribute "cog". Hope this helps you ! :-) Edited April 1, 2018 by StepbyStepVFX Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted April 1, 2018 Author Share Posted April 1, 2018 I wrote comments in the vex code in the scene file. I hope it's understood. halbetweenpoint.hipnc Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted April 2, 2018 Author Share Posted April 2, 2018 i[]@vrtList = primvertices(0,@primnum); i@btween = vertexpoint(0,0); i@btweenagain = vertexpoint(0,1); i@halff = @btween - @btweenagain/2; i@MidWayPoint_for_Primitive = addpoint(0,@halff); i@midway = @halff; The first line get the list of all the vertices, second line gets the point of vertex (0). The third line gets the point of vertex (1). Not sure if the math is correct for the forth line as I want to find the middle of two vertices; the second last line adds a point where the middle of the two vertices are found. Finally I'm assigning all this to an attribute. I'm not getting a point in the middle of specifically the two vertices in the code visually seen in the viewport as a visual guide ? 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.