get a level in vex ?

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

len = length(diff1);

vec = set(len, 0, 0);

if ("" != "")

}

================================

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 ?

......

0 = level 1

1 = level 2

2 & 3 = level 3

4 & 5 = level 4

Share on other sites

pt4 & pt5 => 3time ' neighbor distance ' calculation .

pt2 & pt3 => 2time ' neighbor distance ' calculation .

pt1 & pt0 => 1time ' neighbor distance ' calculation .

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

PS: This topic should maybe be moved to VEX.

-- Mario.

Share on other sites

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

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;
}
}

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;
}
}

Share on other sites

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

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)

Share on other sites

thanks again Andrew. and Mario Marengo

i edit something

sop

level(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

Share on other sites

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

Just for fun

distx3.zip

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×