CinnamonMetal Posted April 4, 2018 Share Posted April 4, 2018 I want to loop over all primitives and create a point using addpoint() halfway between vertices 0-1 of the primitive then find the point associated with vertices 0-1. Then create an attribute for the point created with addpoint() and use that within a primitive sop as the pivot of the rotation of the primitive. What I've come up with is this; I've added a condition within the ForLoop SOP to only rotate primitive 0 for starters. Although I'm using the AddyPint attribute for the pivot in the primitive SOP to which the primitive will rotate around. halbetweenpoint_b.hipnc Quote Link to comment Share on other sites More sharing options...
Sean-R Posted April 4, 2018 Share Posted April 4, 2018 (edited) You shouldn't need to create a point, this code will create a pivot attribute in the place that you want it: //Get all points in a primitive and put into an array int foo[] = primpoints(0, @primnum); //Get the average position of the first and second point in the foo array v@pvt = lerp(point(0, "P", foo[0]), point(0, "P", foo[1]), 0.5); In a Primitive Sop you can call the @pvt attribute using the prim expression. The expression in the pivot would look like this: prim(0, @primnum, "pvt", 0) You will need to change the last value to match with each parameter. So x = 0, y = 1 and z = 2. This probably wont rotate the primitives how you want though, check out this section of Matt Estela's website: http://www.tokeru.com/cgwiki/index.php?title=HoudiniVex#Rotate_prims_around_an_edge I can't check your file at the moment as I'm at work but I can look at it tonight Edited April 4, 2018 by Sean-R Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted April 5, 2018 Author Share Posted April 5, 2018 When you analyze my scene; there is one difference. All primitives have a vertices order from zero to two. I don't know how to view the vertices number of a primitive within the viewport; I tried creating a point attribute array of the vertices and attempting to view that using a visualization attribute but it didn't work. If anyone knows what I did wrong or how to view them in the viewport, I'd like to know ? The difference is I'm getting the point associated with the vertices as I strictly want to get specific range of the vertices followed by the vertices corresponding point, rather then getting all the points for the primitive. For example, if a primitive has three vertices along with three points. I may only want vertices 0-1 for the primitive and the corresponding point for those two vertices, rather then all the points for the primitive; followed by finding the middle. As well, I'd prefer to use a forEach SOP, if possible as seen in my scene; should be possible Quote Link to comment Share on other sites More sharing options...
Sean-R Posted April 5, 2018 Share Posted April 5, 2018 Hey! So I think I get what you mean. I used the @vrtList that you created to get the first and second vertices of each prim, blended the positions to get the midpoint and then created a point at that halfway position. I've attached an updated version of your scene with the following code: i[]@vrtList = primvertices(0,@primnum); int vp1 = vertexpoint(0, @vrtList[0]); int vp2 = vertexpoint(0, @vrtList[1]); vector midpoint = lerp(point(0, "P", vp1), point(0, "P", vp2), 0.5); addpoint(0, midpoint); If you're using this as a pivot for the primitive you don't need to create a point, just bind the lerp expression to an attribute to reference in the primitive SOP. To see the vertex numbers in the viewport, hit D to bring up the Display settings and select Numbers from the Vertex checkbox list. I'm not sure why you need the Foreach network, especially set to Count. What are you trying to achieve? halbetweenpoint_b_v2.hipnc 1 Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted April 5, 2018 Author Share Posted April 5, 2018 Yes, that is exactly what I wanted. I was attempting to use half-edges couldn't this also be done using this technique or was I doing something wrong ? The reason at this point for the ForLoop SOP was to loop over all the primitives and with a primitive wrangler within the ForLoop network; simply, color two primitives as such but it isn't working within the ForLoop SOP ? if(@primnum == 0 && @primnum == 4){ @Cd = 1; } Quote Link to comment Share on other sites More sharing options...
Sean-R Posted April 5, 2018 Share Posted April 5, 2018 The code in a wrangle is applied to each prim/point/whatever at the same time. In your code your say that only primitives with a primitive number of 0 and 4 can be white which isn't possible as it can only have one @primnum assigned, try replacing "&&" with "||". You will also need to initialise the @Cd attribute before the if statement, this should work: @Cd = 0; if(@primnum == 0 || @primnum == 4){ @Cd = 1; } If that's all that you are doing in the ForLoop, then I don't think you need it 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.