jon3de Posted October 23, 2015 Share Posted October 23, 2015 (edited) Hi, For educational purposes I try to replace things I can do with point SOPs with small VEX codes in attributeWrangle. I do that to get a little bit warm with the language also I read that it computes faster than a regular point SOP. ( Not that it would be necessary for my small learning scenes but....anyway) I created a attribute called "displaceValue" and wanted to use this to color the CD attribute. But there has to be a mistake in the code and I can´t find it. The attached picture explains it better. I would be thankful for some help. I also tried something like " @Cd = {(@ptnum/@numpt),0,0};" which also does not work. kind regards Jonathan EDIT: Ah....it works with: @displaceValue = float(@ptnum)/float(@numpt); @Cd = set(@displaceValue,0,0); So i think the curly brackets caused the error... Are the curly brackets just for fast "values" and no attributes or variables? If someone wants to explain the error in more detail to me I would appreciate that. Edited October 23, 2015 by jon3de Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted October 23, 2015 Share Posted October 23, 2015 You can't have variables inside of brackets like that. You would have to do: @Cd = set(@displaceValue, 0, 0); 2 Quote Link to comment Share on other sites More sharing options...
mestela Posted October 23, 2015 Share Posted October 23, 2015 (edited) Another way which can sometimes be easier to read is dot syntax: @Cd = 0; @Cd.r = @displaceValue; @Cd is one of the few special values that automatically converts itself to a vector, so @Cd=0; gets converted to @Cd={0,0,0}; You can also call the suffix as r/g/b, or x/y/z, or an array index, all are useful depending on circumstance. Ie, @Cd.x = 1; @Cd.r = 1; @Cd[0] = 1; are all the same, and will make the points red component to 1. Edited October 23, 2015 by mestela 1 Quote Link to comment Share on other sites More sharing options...
jon3de Posted October 23, 2015 Author Share Posted October 23, 2015 Thanks a lot for the additional info. By the way...I always get a zero value if I write the @ptnum and @numpt without the "float" is that because that are integers by default? And is the way I converted them the right way? Or is there a better way to handle this? Thanks again for all the help. Jon Quote Link to comment Share on other sites More sharing options...
f1480187 Posted October 23, 2015 Share Posted October 23, 2015 You are right. int a=3, b=2; i@i = a / b; f@f = (float) a / b; No need to cast both sides of expression to float, by the way. The right side will be converted implicitly. There will be an Implicit Bingo in single wrangle. 1 Quote Link to comment Share on other sites More sharing options...
jon3de Posted October 23, 2015 Author Share Posted October 23, 2015 Ah got it... So with your help I have now: @displaceValue = (float) @ptnum/@numpt; @Cd = 0; @Cd.r = fit01(@displaceValue,1,0); @P.y += @Cd.r*3.5; it works just fine! 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.