Jump to content

Learning VEX


Tom

Recommended Posts

Hi, I wanted to go deeper in houdini and want to learn VEX, at least at basic level :D

So I have very basic question:

Is there some easier/faster way to get "y" value from P, as you can see in example I use vop_vectofloat, but I think that I saw somewhere faster way how to do this

sop
move_y(float height = 5)

{
    float tx;
    float ty;
    float tz;
    float sum;
    vector vec;

    vop_vectofloat(P, tx, ty, tz);

    sum = ty + height;

    vec = vop_floattovec(tx, sum, tz);

    P = vec;    

}

Thanks in advance,

Tom

Edited by Tom
Link to comment
Share on other sites

I don't recommend you to learn VEX by looking at code converted from VOPs, that's not clean and contains lots of VOP wrappers and lots of intermediate variables

look at VEX docs for start or at direct VEX examples in forums

for example doc to accessing individual vector components http://www.sidefx.com/docs/houdini11.1/vex/lang#id438334

Link to comment
Share on other sites

Thanks for answers, but...

I cant get this working, insted of moving all points up by same value, it does this:

vex1.png

Source geometry I used was default grid.

The code I used is below, I try'ed bunch of combinations and result was same or a grid in that direction, this is just shortest code:

#pragma label height Height
#pragma range height 0 5

sop
move_up(float height = 0)
{

    vector sum = (P.x, P.y + height, P.z);

    P = sum;

}

Here is other version:

vex2n.png

and code:

#pragma label height Height
#pragma range height 0 5

sop
move_up(float height = 0)
{
    float sum;
    vector tempP;
    float ty = getcomp(P, 1);

    tempP = P;

    sum = ty + height;

    vector final = (P.x, sum, P.z);

    P = tempP + final;

}

That one pragma what I made is also doing nothing, if I change values.

I'm missing something?

Edited by Tom
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...