[Solved]HDK - copy attributes

   2826   2   0
User Avatar
Member
255 posts
Joined: Aug. 2009
Offline
I have two GU_Detail(geo1, geo2) and I want copy/move point attributes from geo1 to primitive attributes in geo2(if they dont exist).
I dont care about values, I am just want to copy names and types of attributes.

Cannot find any example for this
Edited by - Jan. 5, 2013 13:54:56
https://vimeo.com/user3251535 [vimeo.com]
https://twitter.com/milansuk [twitter.com]
https://github.com/milansuk [github.com]
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
You should be able to do something like this:

const GA_Attribute *source_attr;
const GA_AttributeDict *dict;
GA_AttributeDict::iterator a_it;
GA_RWAttributeRef dest_gah;

dict = &geo1->pointAttribs();

for (a_it=dict->begin(GA_SCOPE_PUBLIC); !a_it.atEnd(); ++a_it)
{
source_attr = a_it.attrib();

dest_gah = geo2->findPrimAttrib(*source_attr);

if (dest_gah.isInvalid())
geo2->addPrimAttrib(source_attr);
}
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
255 posts
Joined: Aug. 2009
Offline
thank you,
I simplify and modify it for my purpose:
GA_Attribute* src_attr;
GA_FOR_ALL_PRIMITIVE_ATTRIBUTES(input_1, src_attr)
{
gdp->addPointAttrib(src_attr);
}
PS: I think its not necessary to test if attribute is valid, It works fine
https://vimeo.com/user3251535 [vimeo.com]
https://twitter.com/milansuk [twitter.com]
https://github.com/milansuk [github.com]
  • Quick Links