Jump to content

get a level in vex ?


wildparky

Recommended Posts

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 ?

Link to comment
Share on other sites

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 :unsure:

PS: This topic should maybe be moved to VEX.

-- Mario.

Link to comment
Share on other sites

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 &lt; curneighbourconunt; i++){
     tempnum = getneighbour(curpt, i , 0);
     if (tempnum &lt; curpt){
  curpt = tempnum;
  break;
	} 
    }
  level += 1;
  if (curpt&lt;=0) walk = 0;
 }
addattribute("level", level);
}

Link to comment
Share on other sites

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 &lt; curneighbourcount; i++){
     tempnum = getneighbour(curpt, i , 0);
     if (tempnum &lt; curpt){
  curpt = tempnum;
  break;
	}
     brokenmesh += 1; 
    }
  if (brokenmesh == curneighbourcount) break; 
  level += 1;
  if (curpt&lt;=0) walk = 0;
 }
addattribute("level", level);
}

Link to comment
Share on other sites

Sorry....bug fix...

Hey Andrew;

Nicely done! :D

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" :P. 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

Link to comment
Share on other sites

>>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) :)

:rolleyes:

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...