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));
}
}
The Question about GB_ATTRIBTYP on HDK v11
3524 4 1- idiotik
- Member
- 4 posts
- Joined: Sept. 2010
- Offline
- xiondebra
- Member
- 543 posts
- Joined: July 2005
- Offline
- mrice
- 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);
}
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);
}
- idiotik
- Member
- 4 posts
- Joined: Sept. 2010
- Offline
- idiotik
- Member
- 4 posts
- Joined: Sept. 2010
- Offline
-
- Quick Links