[Sidefx-houdini-list] HDK: [adding vertex attributes]
Miles Green
Miles.Green at al.com.au
Tue May 10 03:47:51 EDT 2011
Hi,
any coders out there have any tips on how to add vertex attributes to
polygons?
I'm trying to add some vertex Uv's to my polys with no luck..
example appended HDK below
thanks
Miles
//////////// EXTENDED HDK EXAMPLE ////////////
void addPolygon(GU_Detail * gdp)
{
int point_idx;
const int num_points = 3;
GEO_PrimPoly *prim_poly_ptr;
GEO_Point * added_points[num_points];
static float zero[3] = { 0, 0, 0 };
UT_Vector3 tempVect;
//--------VERTEX HANDLE AND ATTRIBUTE CREATION-----------
gdp->addPointAttrib("uv", 3 * sizeof(float), GB_ATTRIB_FLOAT, zero);
gdp->addVariableName("uv", "UV");
uvHandle = gdp->getPointAttribute("uv");
// Add new points to the gdp.
for(point_idx = 0; point_idx < num_points; point_idx++)
{
// Append a new point
added_points[point_idx] = gdp->appendPoint ();
// Set its coordinates
added_points[point_idx]->getPos().assign(somex,some.y,some.z,1.0);
}
// Append a new polygon primitive. Primitive types are defined in
prim_poly_ptr = dynamic_cast<GEO_PrimPoly*>(gdp->appendPrimitive
(GEOPRIMPOLY ));
prim_poly_ptr->setSize (0);
// Append vertices that form this primitive
for(point_idx = 0; point_idx < num_points; point_idx++)
{
prim_poly_ptr->appendVertex (added_points[point_idx]);
//---------FAIL TO SET VERTEX ATTRS-----------
GEO_Point *vertP;
vertP = prim_poly_ptr->getVertex(point_idx).getPt();
uvHandle.setElement(vertP);
tempVect.assign(1, 1, 1);
uvHandle.setV3(tempVect);
}
// Close the primitive to make it a polygon instead of a polyline.
prim_poly_ptr->close ();
}
//////////// HDK EXAMPLE ////////////
More information about the Sidefx-houdini-list
mailing list