Macha Posted September 29, 2014 Share Posted September 29, 2014 (edited) I make a detail attribute called orids const char * attName= "orids"; GA_RWAttributeRef oridsAtt = gdp->findIntTuple(GA_ATTRIB_GLOBAL, attName, setSize); if (!oridsAtt.isValid()) { oridsAtt = gdp->addIntTuple(GA_ATTRIB_GLOBAL, attName, setSize); } GA_RWHandleI oridsHandle(oridsAtt.getAttribute()); and I want to populate it from values that I have stored in a set. I probably have to convert the set to an array, but whatever I try, I cannot set the values except for the first array item. For example, as a test, this will just set the first array item to 5 and leave all others on 0: GA_Size gasize(setSize); GA_Offset gaoffset; int test[] = {1,2,3,4,5}; oridsHandle.setBlock(gaoffset, gasize, test); I also tried looping over the set and setting the attribute that way: int i=0; for (set<int>::iterator it=oridsSet.begin();it!=oridsSet.end(); ++it) { oridsHandle.set(GA_Offset(i++),*it); } But again, it only sets the value in the very first array position. How do I set array detail attributes? Edited September 29, 2014 by Macha Quote Link to comment Share on other sites More sharing options...
nicholas_yue Posted September 30, 2014 Share Posted September 30, 2014 Hi, I have set vertex array attribute with this call successfully. gdp->setAttributeFromArray() Give that a try. Cheers Quote Link to comment Share on other sites More sharing options...
edward Posted September 30, 2014 Share Posted September 30, 2014 (edited) int i=0; for (set<int>::iterator it=oridsSet.begin();it!=oridsSet.end(); ++it) { oridsHandle.set(GA_Offset(0), i++, *it); } Edited October 2, 2014 by edward Edited w/bug fix Quote Link to comment Share on other sites More sharing options...
Macha Posted September 30, 2014 Author Share Posted September 30, 2014 (edited) Thanks, that looks like it works! (with i++) Edited September 30, 2014 by Macha Quote Link to comment Share on other sites More sharing options...
ffaria Posted October 28, 2014 Share Posted October 28, 2014 Edward, I too ran into this problem, and though your solution works, I have a big block of data that I'm writing to the node and would like, for performance reasons, to write it as a block. Is there a reason why the GA_RWHandleI::setBlock method writes all the values as the same? Is it a bug in the hdk implementation? Thanks. Fernando. Quote Link to comment Share on other sites More sharing options...
edward Posted October 29, 2014 Share Posted October 29, 2014 No, it's not a bug. setBlock() sets the data from the range [source, source + nelements) to the *elements* [startoff to startoff + nelements) using the given source stride and component. If you had a point attribute, then this would set the attribute values for nelements number of points. In the case of the detail (aka global) attribute, there is only ONE element. So it doesn't make sense to use setBlock(). In this case we have an attribute of length setSize which we want to set all of its components. Here's a rough pic. Quote Link to comment Share on other sites More sharing options...
ffaria Posted October 29, 2014 Share Posted October 29, 2014 Thank you for your explanation, that makes sense. My question then is, if I have a large number of floats that I want to add to an object (they are weights for a deformation algorithm, so they are not particular to any point but to the whole mesh), what would be the fastest way to do it without setting them one by one inside a loop? Quote Link to comment Share on other sites More sharing options...
edward Posted October 29, 2014 Share Posted October 29, 2014 Weights for a deformation algorithm should be per point. But anyhow, there's nothing wrong with doing loops. 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.