Alexandre Posted November 20, 2018 Share Posted November 20, 2018 Hi everyone ! I'm learning VEX (from CGwiki and Entagma) and I don't understand why the result of the following code is 0 whereas it should be 3... what did I misunderstand ? int myarray[] = {2, 3, 4, 5}; int foo = myarray[1]; printf("%i \n",i@foo); Thanks ! Alexandre Quote Link to comment Share on other sites More sharing options...
3dome Posted November 20, 2018 Share Posted November 20, 2018 you print out i@foo which is an attribute that does not exist so it gets initialized right in the printf() and default initialization is 0. you want to print your variable foo Quote Link to comment Share on other sites More sharing options...
Alexandre Posted November 20, 2018 Author Share Posted November 20, 2018 Ahhh yes... thank you I'm still a noob Quote Link to comment Share on other sites More sharing options...
Alexandre Posted November 20, 2018 Author Share Posted November 20, 2018 Another question which is a step further... but still low level I want to access to a specific float attribute called d (related to a distance), I have tried attrib, point, pointattrib... I don't understand how to access to the nth value of d. Moreover I don't understand what mean the integer "&success" in the help function In the example in attachment I would expect to get 1.49176 instead of 30 times "0.0000" thanks ! Alexandre Quote Link to comment Share on other sites More sharing options...
Atom Posted November 20, 2018 Share Posted November 20, 2018 You should give up using prints with vex, just use the spreadsheet as your print out. There is no need to fetch the point value of @d from the point that you are running over. Just use @d. Vex is a sand box. when you enter the wrangle, the information about points is made available to the wrangle, kind of like a copy. You can operate upon those entries, then when you exit the wrangle internal housekeeping remaps everything to make the output work correctly. This prevents you from performing certain operations typical in a top-down programming language. It also prevents you from messing up indicies. Try using two wrangle, one to add new points and the other to review or revise those points. You are trying to print @d for point #1. Try... if(@ptnum==1) print("%02d\n",@d); You should not ignore the success flag either. Pass a valid variable, not 0. Also I don't think primuv returns a point that you can just pass to addpoint. It returns the value at the UV coordinate. This would cause all the other operations on that point to be suspect. Your getting 30 zeros because the pointattrib is failing, you are not examining success and a zero is returned just as the documentation states. Quote Link to comment Share on other sites More sharing options...
Alexandre Posted November 20, 2018 Author Share Posted November 20, 2018 ok I understand thanks for the advice ! Quote Link to comment Share on other sites More sharing options...
Alexandre Posted November 20, 2018 Author Share Posted November 20, 2018 concerning primuv, this is not from me but cgwiki, it seems to work as I am projecting points on my semi-phere as shown in attachment 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.