The Question about GB_ATTRIBTYP on HDK v11

   3526   4   1
User Avatar
Member
4 posts
Joined: Sept. 2010
Offline
houdini v10 oold code
int pt_material = inst_gdp->addPointAttrib(“vm_surface”, sizeof ( UT_String ), GB_ATTRIB_STRING, 0 );
UT_String* mat = ppt->castAttribData<UT_String> ( pt_material );
*mat = myPointAttributes.shader;


However, GB_ATTRIB_STRING is deleted in GB_ATTRIBTYPE at hodini v11

Therefore, I come up with some code
int def = -1;
GB_AttributeRef pt_material = inst_gdp->addPointAttrib(“vm_surface”, sizeof ( int ), GB_ATTRIB_INDEX, &def );
UT_String* mat = ppt->castAttribData<UT_String> ( pt_material );
*mat = myPointAttributes.shader;


there is no error while compiling but there is error using hodini and mat value cannot entered.

Like below Examples code, Please let me know the instruction of UT_STRING.

Old attribute code looks something like:
int Cd_offset;
UT_Vector3 *Cd;
Cd_offset = gdp->findDiffuseAttribute(GEO_POINT_DICT);
if (Cd_offset >= 0)
{
FOR_ALL_GPOINTS(gdp, pp)
{
Cd = ppt->castAttribData<UT_Vector3>(Cd_offset);
Cd->assign(1, 0, 0); // Set to red
}
}

The equivalent new code would look like:
GB_AttributeRef Cd_ref;
Cd_ref = gdp->findNormalAttribute(GEO_POINT_DICT);
if (Cd_ref.isValid())
{
FOR_ALL_GPOINTS(gdp, pp)
{
ppt->setValue<UT_Vector3>(Cd_ref, UT_Vector3(1, 0, 0));
}
}
User Avatar
Member
543 posts
Joined: July 2005
Offline
Gee, this source code snippet looks really familiar …

:-)


Mark
========================================================
You are no age between space
User Avatar
Member
89 posts
Joined: April 2008
Offline
Hi,

It looks to me like you're trying to assign the string directly to the attribute value, but what a string attribute wants is the index to a string that you've entered into the attribute's string index table.

I think the “easy” way to deal with strings is to use a GEO_AttributeHandle.

Untested:
int def = -1;
inst_gdp->addPointAttrib(“vm_surface”, sizeof ( int ), GB_ATTRIB_INDEX, &def );
GEO_AttributeHandle matAttribHandle = inst_gdp->getPointAttribute(“vm_surface”);

if ( matAttribHandle.isAttributeValid() ) {
matAttribHandle.setElement(ppt);
matAttribHandle.setString(myPointAttributes.shader);
}
User Avatar
Member
4 posts
Joined: Sept. 2010
Offline
it was a great idea to use GEO_AttributeHandle to approach to the matter. it worked without errors and helped a lot, however i dont think it worked properly becuase of other problems. thank you~!!
User Avatar
Member
4 posts
Joined: Sept. 2010
Offline
xionmark
Gee, this source code snippet looks really familiar …

:-)


Mark


^^;; It is so hard to convert houdini v10 to v11 :cry:
  • Quick Links