Tom Posted February 13, 2012 Share Posted February 13, 2012 (edited) Hi, I wanted to go deeper in houdini and want to learn VEX, at least at basic level 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 February 13, 2012 by Tom Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted February 13, 2012 Share Posted February 13, 2012 you can call components of a vector by using P.x, P.y or P.z ! cheers, Manu 1 Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted February 13, 2012 Share Posted February 13, 2012 Also, there is getcomp/setcomp vex functions.. 1 Quote Link to comment Share on other sites More sharing options...
anim Posted February 14, 2012 Share Posted February 14, 2012 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 Quote Link to comment Share on other sites More sharing options...
Tom Posted February 15, 2012 Author Share Posted February 15, 2012 (edited) Thanks for answers, but... I cant get this working, insted of moving all points up by same value, it does this: 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: 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 February 15, 2012 by Tom Quote Link to comment Share on other sites More sharing options...
anim Posted February 15, 2012 Share Posted February 15, 2012 what about this one? sop move_up(float height=0) { P.y += height; } 1 Quote Link to comment Share on other sites More sharing options...
Tom Posted February 18, 2012 Author Share Posted February 18, 2012 (edited) Thanks anim, it realy worked! From 9 lines went to 1 How that += function works( maybe documented)? Edited February 18, 2012 by Tom Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted February 18, 2012 Share Posted February 18, 2012 sumthing += anotherthing is the same as sumthing = sumthing + anotherthing 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.