BlackPariah Posted October 28, 2016 Share Posted October 28, 2016 Hello! New Houdini user here with barely 3 weeks in... so please bare with me I'm trying to write a small VEX function/expression to translate an object along it's Y axis by an exponential function... like gravity. The math behind is simple but I'm having trouble expressing it in VEX... I tried the following line with a VEX attribute wrangle node on a default sphere and it's giving me errors and the sphere just disappears on the 1st frame: t.y = t.y + (9.8 * ($T ^ 2)); If someone could steer me in the right direction I would appreciate it thank you :-) Quote Link to comment Share on other sites More sharing options...
fsimerey Posted October 28, 2016 Share Posted October 28, 2016 (edited) Use the good attributes see here http://www.sidefx.com/docs/houdini15.5/vex/snippets#attributes For your case the good expression is this: @P.y = @P.y + 9.8 * pow(@Time, 2); and you can simplify with: @P.y += 9.8 * pow(@Time, 2); But if you want a gravity effect, subtract is the better way Edited October 28, 2016 by fsimerey Quote Link to comment Share on other sites More sharing options...
Sepu Posted October 28, 2016 Share Posted October 28, 2016 (edited) I think this is what you are looking for float gravity = 9.8; @P.y += gravity * (pow(@Time, 2)); I believe the "$" expression isn't valid in Vex, however you can use it in hscript ... check out the help docs to see what is the correct syntax for Vex. http://www.sidefx.com/docs/houdini15.5/vex/snippets Edited October 28, 2016 by Sepu Quote Link to comment Share on other sites More sharing options...
BlackPariah Posted October 29, 2016 Author Share Posted October 29, 2016 (edited) Wow great stuff thank you guys I ran into one small issue now... & the object in question will keep accelerating forever with this method. My guess is I would need some kind of a loop or if / then structure to define a maximum limit of the result... I'm not numerically inclined so it's difficult for me to put it in numbers... more so with VEX. Maybe I'm way over my head with this but it would help a lot if I could see an example of how to structure the code... if it's not asking too much I'd appreciate it thank you again Edited October 29, 2016 by BlackPariah Quote Link to comment Share on other sites More sharing options...
fsimerey Posted October 29, 2016 Share Posted October 29, 2016 float gravity = pow(@Time, 2); if (@Time > ch("limit")) { float increment = pow(ch("limit"), 2) - pow(ch("limit") - @TimeInc, 2); gravity = pow(ch("limit"), 2) + increment * ((@Frame - ch("limit") / @TimeInc) - 1); } @P.y += -9.8 * gravity; Here an example. The limit is a time value in seconds. Don't forget to click on the white button on the right of the editor area to spare parameter. Quote Link to comment Share on other sites More sharing options...
BlackPariah Posted October 30, 2016 Author Share Posted October 30, 2016 I didn't notice that button on the side... my head is spinning just reading the code here but I'll figure it out from the example... thanks a lot Francois 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.