[Sidefx-houdini-list] HDK: [adding vertex attributes]

Olex P hoknamahn at gmail.com
Tue May 10 09:56:24 EDT 2011


Hi Miles,

I'm a bit confused. Are you talking about Maya vertex attributes or
about Houdini ones? As they are different. If it's supposed to be
Houdini vertices then this method

[code]gdp->addPointAttrib("uv", 3 * sizeof(float), GB_ATTRIB_FLOAT,
zero);[/code]

is wrong as it adds a point attribute. So addVertexAttrib() will do
what you want.
And you didn't say what exactly isn't working. If you see a point uv
attribute on middle click on your HDKed SOP then your code is okay :)


On Tue, May 10, 2011 at 8:47 AM, Miles Green <Miles.Green at al.com.au> wrote:
> 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  ////////////
>
>
>
>
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>



More information about the Sidefx-houdini-list mailing list