michaelb-01 Posted July 30, 2014 Share Posted July 30, 2014 I posted here (http://forums.odforce.net/topic/20626-flipping-animation/) yesterday but haven't yet received any replies so I will ask a more basic question that should help me solve the problem in my other post. If I have a grid of black points and I colour some of them red, how can I find the nearest red point for the other (black) points. I'm fairly sure it would be: - pcopen - pciterate - if red is > 0.1 But then how would I break out of the pciterate and use that found point, e.g. to get the distance between the found red point and the current black point? Cheers, Mike Quote Link to comment Share on other sites More sharing options...
rayman Posted July 30, 2014 Share Posted July 30, 2014 (edited) something like this? float thr = .1; int maxDst = 5; int maxPts = 30; int clRed = -1; int pthandle = pcopen(0, "P", @P, maxDst, maxPts); while(pciterate(pthandle)){ vector ptCd; pcimport(pthandle,"Cd",ptCd); int ptIx; pcimport(pthandle,"point.number",ptIx); if(ptCd.x>thr){ clRed = ptIx; break; } } pcclose(pthandle); if(clRed>-1){ vector distVec = point(0,"P",clRed); float dist = length(distVec-@P); i@clPt = clRed; f@redDst = dist; } Edited July 30, 2014 by rayman 2 Quote Link to comment Share on other sites More sharing options...
michaelb-01 Posted July 30, 2014 Author Share Posted July 30, 2014 That looks like it should work! Thanks Pavel i'll try it now! Quote Link to comment Share on other sites More sharing options...
michaelb-01 Posted July 30, 2014 Author Share Posted July 30, 2014 That works great! However i'm using a foreach sop to iterate over the primitives so I need to find the nearest red point in one of the primitives (that doesnt exist inside the foreach sop) so i'm trying to reference a node above it but now i'm just getting 0 for the redDst attribute.. any ideas what i'm doing wrong? Here's the basic hip file im testing with: https://dl.dropboxusercontent.com/u/18098614/triangle_flip_v3.hip Thanks for your help, Mike Quote Link to comment Share on other sites More sharing options...
Annon Posted July 30, 2014 Share Posted July 30, 2014 PCFilter and get P. If you use pcImport you can get the distance or the point number of the point it's iterating on as well. http://www.sidefx.com/docs/houdini13.0/nodes/vop/pcimport 1 Quote Link to comment Share on other sites More sharing options...
michaelb-01 Posted July 30, 2014 Author Share Posted July 30, 2014 Thanks for the advice, I have it pretty much working now but the rotation is behaving slightly odd, each primitive starts to rotate in one direction then (I think) at 90 degrees it flips to the other side... Is there a problem with my rotation vop sop? https://dl.dropboxusercontent.com/u/18098614/triangle_flip_v3.hip Thanks, Mike Quote Link to comment Share on other sites More sharing options...
wateryfield Posted July 30, 2014 Share Posted July 30, 2014 (edited) That works great! However i'm using a foreach sop to iterate over the primitives so I need to find the nearest red point in one of the primitives (that doesnt exist inside the foreach sop) so i'm trying to reference a node above it but now i'm just getting 0 for the redDst attribute.. any ideas what i'm doing wrong? Here's the basic hip file im testing with: https://dl.dropboxusercontent.com/u/18098614/triangle_flip_v3.hip Thanks for your help, Mike I created a simple vopsop to find the nearest red point for each black points. Hope it help. find_near_point.hip Edited July 30, 2014 by wateryfield Quote Link to comment Share on other sites More sharing options...
michaelb-01 Posted July 30, 2014 Author Share Posted July 30, 2014 Hey I dont think the file attached properly? I got that working thanks Pavel's code if you take a look at my hip file posted above (https://dl.dropboxus...gle_flip_v3.hip) Cheers Quote Link to comment Share on other sites More sharing options...
michaelb-01 Posted August 3, 2014 Author Share Posted August 3, 2014 I just went through your file and its very helpful. Thanks! 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.