Cain&Able Posted December 18, 2015 Share Posted December 18, 2015 Hey, I have a bunch of points with 3 float attributes, b[0] b[1], b[2] If I want to access only the second attribute, specifically through a wrangle (for learning), how would I do this? I've tried @foo = point(@p,"b",1) but that only returns the first attribute value. Presumably because I'm not asking for an array? Thanks! Quote Link to comment Share on other sites More sharing options...
mestela Posted December 18, 2015 Share Posted December 18, 2015 Could you post a hip of what you're trying to do? The question and your code could be interpreted in several ways, a .hip would make it clearer. Quote Link to comment Share on other sites More sharing options...
Shinjipierre Posted December 18, 2015 Share Posted December 18, 2015 @atest = v@b[1]; Quote Link to comment Share on other sites More sharing options...
f1480187 Posted December 18, 2015 Share Posted December 18, 2015 3-float is a tuple, not an array. Difference in attribute access: foo = f[]@attr[1] versus foo = v@attr.y foo = v@attr[1] They also shows differently in Spreadsheet. Arrays displays as bulk of values inside brackets, tuples have a column per each component. 3-float is an attribute itself, not three attributes, so, if you want second component by retrieving an attribute from points, use constructs like this: // For vectors, normals, colors, positions, 3-floats. vector foo = point(0, "b", @ptnum); float bar = foo.y; // For float arrays. float foo[] = point(0, "b", @ptnum); float bar = foo[1]; But it is just a longer version of @-access syntax. Typically we use point() function when want to access an attribute of some specific point number, not from same point being processed. 1 Quote Link to comment Share on other sites More sharing options...
Cain&Able Posted December 19, 2015 Author Share Posted December 19, 2015 That's excellent! Thanks, perfectly explained and does what I need. Cheers 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.