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
HDK: how to set vertex value
2731 3 0- skydave
- Member
- 15 posts
- Joined: March 2010
- Offline
- graham
- Member
- 1908 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);
}
}
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
- skydave
- Member
- 15 posts
- Joined: March 2010
- Offline
- graham
- Member
- 1908 posts
- Joined: Nov. 2006
- Online
-
- Quick Links