kleer001 Posted October 16, 2007 Share Posted October 16, 2007 Is there anyway to connect all given points to eachother with nurbs curves? 1-2, 1-3, 1-4, 2-3, 2-4, 3-4 and no more. It must not be a "by-hand" solution as this needs to happen hundreds of times to an arbitrary number of points. I can kind of do it by hand with the addSOP. I think the foreachSOP may be productive, but I'm not sure, I think with two nested forEach I could probably do it. Any ideas? Quote Link to comment Share on other sites More sharing options...
jhiggins Posted October 16, 2007 Share Posted October 16, 2007 set $numCurves = 0 for i = 1 to `npoints("yourPonits")` $numCurves = $numCurves + $i end set $idx = 0 for i = 0 to `npoints("yourPoints")-1` for j = $i to `npoints("yourPoints")-1` # connect point $i to point $j $idx = $idx +1 end end the connecting part is the tricky bit. but you could create an add SOP and append it to "yourPoints", turn "delete geometry but keep points" on and set the number of polys to $numCurves properly and then each entry to $i-$j hope this is enough detail to get you going you would set the each entry in the add sop to $i $j (minus the minus ) and you would probably want your second loop to start at $i+1 my bad, but you get the jist i hope! Quote Link to comment Share on other sites More sharing options...
kleer001 Posted October 16, 2007 Author Share Posted October 16, 2007 Thanks. It's the proceduraly connecting an arbitrary number of groups of two points that gets me frazzled. I guess the question now is how do I create a new SOP with hscript in its guts? OR How do I create curveSOPs from the command line? I'm starting to think this isn't something I can do with OPs and that I'll have to create one from scratch. set $numCurves = 0for i = 1 to `npoints("yourPonits")` $numCurves = $numCurves + $i end set $idx = 0 for i = 0 to `npoints("yourPoints")-1` for j = $i to `npoints("yourPoints")-1` # connect point $i to point $j $idx = $idx +1 end end the connecting part is the tricky bit. but you could create an add SOP and append it to "yourPoints", turn "delete geometry but keep points" on and set the number of polys to $numCurves properly and then each entry to $i-$j hope this is enough detail to get you going you would set the each entry in the add sop to $i $j (minus the minus ) and you would probably want your second loop to start at $i+1 my bad, but you get the jist i hope! Quote Link to comment Share on other sites More sharing options...
jhiggins Posted October 16, 2007 Share Posted October 16, 2007 you can use "opadd" to create new ops. you have to be aware of where you are as its context sensitive (ie. "opadd curve" will only work if your current directory is under sops ) cannot remember how to set expressions, but the best thing to do is buid something by hand then run opscript on your nodes to get the hscript wackiness and then use that to build your script around it. you shouldn't have to use groups for this, its all a matter of how you iterate over the points. you can then use the OPmenu to source your script, so that anybody who uses your script can just select the node right or ctrl-right click and select it to run it and build your fancy network! if your h9 savy python and the shelf would be the way to go. if your c++ inclined and want something more dynamic and compact, you might want to take a stab at writing a SOP in HDK to do your magic Quote Link to comment Share on other sites More sharing options...
edward Posted October 16, 2007 Share Posted October 16, 2007 Does it matter if the result is a single primitive or not? Quote Link to comment Share on other sites More sharing options...
kleer001 Posted October 17, 2007 Author Share Posted October 17, 2007 My heart says it shouldn't matter, but my brain says its a good idea because I'll need to cull out curves not between a certain limit after they're made. What were you thinking of? I'm open to all possibilities. Does it matter if the result is a single primitive or not? Quote Link to comment Share on other sites More sharing options...
edward Posted October 17, 2007 Share Posted October 17, 2007 All in the same primitive, it's easy with a single Add SOP. connect_all.hip Quote Link to comment Share on other sites More sharing options...
kleer001 Posted October 18, 2007 Author Share Posted October 18, 2007 Cool, thanks Edward! That's kind of it. A good step in the right direction for my purposes. It seems like a lot of my problem is not knowing the syntax for expressions and how to return values. Now that I've got an example I just need to figure out what it means and how to expand on it. The created values look right, but there's some addSOP funkyness. The expression give us: 0-6 0-1 0-2 0-3 0-4 0-5 1-2 1-3 1-4 1-5 2-3 2-4 2-5 3-4 3-5 4-5 but the essential groups are: 0-6 0-2 0-4 0-5 1-3 1-4 1-5 2-3 2-4 2-5 3-4 It seems that the addSOP insists on going through all intervening numbers of points and not just the points given. For interested parties this is the essential expression plugged in the Polygon 0 channel of the addSOP: n = 6 result = '%d-%d ' % (0, n) for i in range(0, n): for j in range(i+1, n): result += '%d-%d ' % (i, j) return result That's Python, right? With a little more thinking I have realized that I will need the results as sepereate primitives. All in the same primitive, it's easy with a single Add SOP. Quote Link to comment Share on other sites More sharing options...
edward Posted October 18, 2007 Share Posted October 18, 2007 Oops, I didn't realize that. I guess the easiest way is to do two nested ForEach SOPs then with a line segment inside. Quote Link to comment Share on other sites More sharing options...
kleer001 Posted October 19, 2007 Author Share Posted October 19, 2007 Pretty darn close. It is a forEachSOP in another forEachSOP with a curveSOP at the bottom with points referenced from each loop. The First loop goes from 0 to the number of prims, the second loop goes from the number being processed in the first loop to the max number in the first loop minus 1. The start and end points of the curve is an XYZ and XYZ of each given primitive. What a tricky little monster. The good are attached. Oops, I didn't realize that. I guess the easiest way is to do two nested ForEach SOPs then with a line segment inside. connectAll01.hip 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.