HDK: how to set vertex value

   2700   3   0
User Avatar
Member
15 posts
Joined: March 2010
Offline
Hi,

in a custom HDK app I create a bgeo object. I can add a vertex attribute to my PolyPrimitive which shows up in houdini properly. Now I use the following code to set the value of a specific vertex:


gdp.addVertexAttrib( “uv”, size, type, 0 );
attr = gdp.getVertexAttribute(“uv”);

if(attr.isAttributeValid())
for( GEO_Primitive *curPrim = gdp.primitives().head(); curPrim != 0; curPrim = gdp.primitives().next(curPrim) )
for (int j = 0; j < curPrim->getVertexCount(); ++j)
{
attr.setElement( curPrim, &curPrim->getVertex(j) );
attr.setV3( UT_Vector3( … ) )
}


but the problem is that all the values turn out 0 when loaded in houdini.

Now my question is: what is the correct way of setting vertex attribute values in HDK?

Thanks for any help or hints,
David
User Avatar
Member
1907 posts
Joined: Nov. 2006
Online
This works fine for me.
attr_ref = gdp->addVertexAttrib(“uv”, sizeof(float), GB_ATTRIB_FLOAT,0);

FOR_ALL_PRIMITIVES(gdp, prim)
{
num_vertices = prim->getVertexCount();

for (unsigned vert_idx=0; vert_idx < num_vertices; vert_idx++)
{
vtx = &prim->getVertex(vert_idx);
vtx->setValue<float>(attr_ref, 3.5);
}
}
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
15 posts
Joined: March 2010
Offline
Thanks for your reply Graham,

I'm using version 10.0 of the HDK and there the GEO_Vertex class or any of its base classes don't have a setValue method. Are you using a different HDK version? I'll try the castAttributeData method on the GB_AttributeElem base class as soon as I'm back at work.

David
User Avatar
Member
1907 posts
Joined: Nov. 2006
Online
Yeah that code is for Houdini 11 only, sorry. The castAttributeData method should be the right way to go about it in 10.
Graham Thompson, Technical Artist @ Rockstar Games
  • Quick Links