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

Miles Green Miles.Green at al.com.au
Tue May 10 19:40:48 EDT 2011


Hi,
 sorry for not explaining better, basically I was able to create the 
vertex attribute fine but zeros were populating the values

last night I found the solution in this older sidefx forum post:
http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=20697&highlight=HDK+vertex

and basically I can swap my old code of:

GEO_Point *vertP;
vertP = prim_poly_ptr->getVertex(point_idx).getPt();
uvHandle.setElement(vertP);
tempVect.assign(1, 1, 1);
uvHandle.setV3(tempVect);  //FAILED WITH HANDLES


---with----


GEO_Vertex  *vert;
vert =  &prim_poly_ptr->getVertex(point_idx);
tempVect.assign(1, 1, 1);
vert->setValue<UT_Vector3>(vertUV, tempVect);   //NOW USE SET VALUE

and finally values are written to those pesky Vertex attributes.

I think half of my problem was constantly referring to the houdini 10 
HDK docs online (as they come up fist in google) and not the 11 HDK docs 
as I should have.

thanks
   Miles

p.s. yes your right my code should have addVertexAttrib() not 
addPointAttrib(),  my mistake in the simplified example I posted

Olex P wrote:
> 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
>>
>>     
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>   

-- 

Miles Green
FX Lead

T: +61 2 9383 4800 (main)
T: +61 2 835 32378 (direct)
F: +61 2 9383 4801 (fax)

Animal Logic

*See our latest work at http://www.animallogic.com/work*

Please think of the environment before printing this email. This email 
and any attachments may be confidential and/or privileged. If you are 
not the intended recipient of this email, you must not disclose or use 
the information contained in it. Please notify the sender immediately 
and delete this document if you have received it in error. We do not 
guarantee this email is error or virus free.






More information about the Sidefx-houdini-list mailing list