Jump to content

VEX : point -> pointwrangle


Recommended Posts

Hi,

 

first off, I'm totally new to any kind of programming language.

 

Yet I'm trying to convert a point SOP expression into VEX in a pointwrangle.

 

$TX * ($TY / $YMAX)  is the line I'm trying to write in VEX.

 

My problem is the $YMAX

I reckon $TX becomes @P.x

but I'm not able to find the equivalent for $YMAX

 

$YMAX is the maximum value of any point in the Y axis, right? (I'm not even sure)

 

So I searched the help for a max function, but it seems to be only to compare between 2 thing.

 

Can anyone help and correct me?

 

thanks.

Edited by 6ril
  • Like 1
Link to comment
Share on other sites

try this:

whenever you see "&" sign, sort of means it will modify the data in it.

here is the function from the documentation:

void getbbox(int input, vector min&, vector max&)

 

-----code----

//empty vectors

vector min; 

vector max;

 

getbbox(0, min, max); //find bbox

 

f@ymax = max.y; //export

edit: should be float sorry

Edited by willow wafflebeard
  • Like 1
Link to comment
Share on other sites

Another question :

 

this "expression"

 

$TX * (($TY / $YMAX)+1)

 

is from this very nice tutorial of Konstantin Magnus - > https://vimeo.com/112114913

(Procedural Modeling of a Shampoo Tube)

 

It's actually a very important part of the procedural modeling method. It's reshaping a tube into the body of the shampoo tube. In one point node.

 

 x: $TX * ((($TY / $YMAX)+1)*0.45)      y:  $TY   z: $TZ * (1.02 - ($TY / $YMAX))

 

but unfortunately, he doesn't develop the though process leading to this expression.

 

So my question is, how does one come to approach simple pinching on a tube, with such an expression ?

 

I'm aware this question might sound rather naive, you might tell me "learn your maths!" or something. But I'm just wondering if there's some "references" somewhere, or,

Konstantin, would you mind telling me how you figured this one? Did you create it out of the blue ?

 

 

I imagine that, by analysing what you need to do to the points, on the different axis, to get the shape you want, there's an "obvious" relation between the amount you need to move them and the height (y) of each point, but,

I'm sensing that my background would have lead me to a soft selection approach rather then this nice mathematical approach.

Should I worry about that ? Does it mean the Houdini isn't the tool I should try to learn ?

Link to comment
Share on other sites

$TX * ((($TY / $YMAX)+1)*0.45)

should translates into VEX as

float ymax = ch("ymax");
float multiplier = ch("multiplier");
@P[0] = (@P[0] * ((@P[1] / ymax) + 1) * multiplier);

You need to add 2 parameters to your attribWrangle interface.

It can be done manually via the little gear on top, or since H14, by clicking the "plug icon" next to the VEX expression field, H will create any parameter that you have referenced in your code via the ch() expression.

 

In the ymax parameter, just type this expression : bbox(opinputpath(".", ), D_YMAX)

and it will read the maximum Y value on the first input (index ) of the current node (".")

The good thing about the second parameter, called multiplier is that you can now play in real time with the value and see how it affect the shape in your viewport.

 

If you know the shape of your object is supposed to follow a certain pattern (pinch on a certain axis, bulge elsewhere, ...) you can code the pattern and just use parameters to find the correct values.

Experiment with ramp parameters, called within VEX via chramp("name", attribute).

  • Like 1
Link to comment
Share on other sites

sorry for the broad answer, but: your mindset regarding 3d graphics changes the longer you use houdini. so its defintely worth keeping at it. and talking about 'wanting to use the soft selection node' i think its only natural to first try the things you know from other packages. but over time you will appreciate building your own tools that are based on simple mathematics, because they are more elegant and direct and because you know exactly what they do.

 

 

 

as far as i remember i didnt write this expression in one go. rather i first put in what i knew was necessary like the relative height of each point and then i started adding stuff to see what happens. nowadays i would probably do it more with VOPs and wrangles, i guess.

 

two more recommendations:

http://www.gametutor.com/live/tutorials/houdini/

 

and once you got that and you dont mind it being in russian:

Edited by konstantin magnus
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...