wildparky Posted December 18, 2003 Share Posted December 18, 2003 Hi guys! I want to calculate a accumulated point distance from 'pt0' in the vex or vop. i think ... ==== sop scalarfield() { ... for ( i=0;i<level;i++) .. neighptnum = getneighbour(ptnum, 0, 0); success1 = import("P", adata1, 0, neighptnum); diff1 = P - adata1; len = length(diff1); vec = set(len, 0, 0); newadata = vec; addattribute("distlength", newadata); if ("" != "") addvariablename("distlength", ""); } ================================ pt4 have 3(level) neighbor (4:3-1-0) pt3 have 2(level) neighbor (3:1-0) pt1 have 1(level) neighbor (1:0) ================================= How can i get a level of current point in vex ? Quote Link to comment Share on other sites More sharing options...
wildparky Posted December 18, 2003 Author Share Posted December 18, 2003 ...... 0 = level 1 1 = level 2 2 & 3 = level 3 4 & 5 = level 4 Quote Link to comment Share on other sites More sharing options...
wildparky Posted December 18, 2003 Author Share Posted December 18, 2003 pt4 & pt5 => 3time ' neighbor distance ' calculation . pt2 & pt3 => 2time ' neighbor distance ' calculation . pt1 & pt0 => 1time ' neighbor distance ' calculation . Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted December 18, 2003 Share Posted December 18, 2003 Hi Wildparky, Hard to tell what it is you're up to exactly; except maybe a tree search (n-ary depth-first)? But then, that would have nothing to do with distance (in the Eucledian sense); so what do you mean when you say "accumulated distance"? And how does it relate to your "levels"? Never used the getneighbour() function before; but just scanning the docs, I noticed it says that the order of traversal is not guaranteed -- I read that as meaning that you can't count on it doing an orderly spiral outward from P. (not that that would necessarily help, if I understand you correctly). What is it you're trying to accomplish? -- there may be other ways in which to tackle the problem. Sorry I got no answers... just more questions PS: This topic should maybe be moved to VEX. -- Mario. Quote Link to comment Share on other sites More sharing options...
David Gary Posted December 18, 2003 Share Posted December 18, 2003 I don't think you need to get the point-level to compute an accumulated distance. Why not use a while loop, and increment a variable (set to 0 for the first step). To me, the problem is more: how do you set/get the path through the mesh ( how do you choose your neighbor?) Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted December 18, 2003 Share Posted December 18, 2003 Not sure. May be this helps. sop level() { int i, tempnum, curneighbourconunt; int level = 0; int walk = 1; int curpt = ptnum; while (walk){ curneighbourconunt = getneighbourcount(curpt, 0); for (i = 0; i < curneighbourconunt; i++){ tempnum = getneighbour(curpt, i , 0); if (tempnum < curpt){ curpt = tempnum; break; } } level += 1; if (curpt<=0) walk = 0; } addattribute("level", level); } Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted December 18, 2003 Share Posted December 18, 2003 Sorry....bug fix... sop level() { int i, tempnum, curneighbourcount, brokenmesh; int level = 0; int walk = 1; int curpt = ptnum; while (walk){ brokenmesh = 0; curneighbourcount = getneighbourcount(curpt, 0); for (i = 0; i < curneighbourcount; i++){ tempnum = getneighbour(curpt, i , 0); if (tempnum < curpt){ curpt = tempnum; break; } brokenmesh += 1; } if (brokenmesh == curneighbourcount) break; level += 1; if (curpt<=0) walk = 0; } addattribute("level", level); } Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted December 19, 2003 Share Posted December 19, 2003 Sorry....bug fix... Hey Andrew; Nicely done! Now if you could do something to not have to walk all the way to pt0 for every point.... that would be the "cherry on top" . But I guess there's no way to tag points as "visited" on the fly, is there? Wildparky: Andrew's sop is your answer. But it depends on all point numbers increasing monotonically from some root point. An L-System, for example, would have points numbered in this way automatically. But that's the kind of topology you seem to be working with so it should be OK. Cheers! -- Mario Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted December 19, 2003 Share Posted December 19, 2003 >>But I guess there's no way to tag points as "visited" on the fly, is there? You right...its impossible >> But it depends on all point numbers increasing monotonically from some root point. You can fix any "crazy mesh" with help of Sort SOP (by vertex order) Quote Link to comment Share on other sites More sharing options...
wildparky Posted December 20, 2003 Author Share Posted December 20, 2003 thanks again Andrew. and Mario Marengo i edit something soplevel(float min=0,max=1,rolloff=0){ int i, tempnum,tempnum2, curneighbourcount, brokenmesh; int level = 0; int walk = 1; int curpt = ptnum; float dist = 0; vector cp,np; while (walk) { dist.hipnc Quote Link to comment Share on other sites More sharing options...
wildparky Posted December 21, 2003 Author Share Posted December 21, 2003 a little fix Cd = smooth(min,max,dist,rolloff); >>What is it you're trying to accomplish? -- there may be other ways in which to tackle the problem. could you tell me the ways? Mario Marengo Chris Bernardi - Shading a Coral Reef page 143 'Scalar Fields' he used a mel script. distx.hipnc Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted December 21, 2003 Share Posted December 21, 2003 Just for fun distx3.zip 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.