[Sidefx-houdini-list] HDK - UV Attribute From Internal UV

jlait at sidefx.com jlait at sidefx.com
Mon May 7 14:40:42 EDT 2007


On Sat, May 05, 2007 at 03:33:33AM -0700, Jaideep Khadilkar wrote:
> HI..........
> 
> How to find the value of a point attribute at an In between point on
> a Primitive with UV , using HDK????
> 
> Basically I have an Input GDP with number of polygons., and a UV
> attribute. For any Internal uv value , I want to find out what is
> the UV Attribute value at that point. This is no problem for NURB
> Surface as Internal uv and 
>  UV attribute are same. But for a polygon object, how can I access
>  UV attribute from internal uv. 

    I don't think the internal uv matches the UV attribute in NURBs.
    It will match in the specific case where the NURBs have been
textured using the Texture SOP, but in general, they can be different.

> I thought, I can be done with "evaluateInteriorPointWAttrib", but
> don't know how to use it.

    This is the correct thing to use.  The following code snippet has
two main branches.  The first handles point "uv" attributes, the
second vertex attributes.  The current gdp is "gdp" and the primitive
to evaluate is "prim".  We store the result in a UT_Vector3 called
"uvpos".  "pos" is a UT_Vector4 that is the location evaluated,
discarded in this case.  "u" and "v" are the internal uvs to evaluate.

uvoff = gdp->findTextureAttribute(GEO_POINT_DICT);
if (uvoff >= 0)		// Has point attribute
{
    GB_FloatOffsets	foffsets(1,0);
    GB_AttributeData	adata;

    // Build a table listing which attributes are floating point.
    gdp->pointAttribs().getFloatOffsets(foffsets);

    // Resize our attribute data to fit the evaluated attribute
    adata.changeSize(gdp->pointAttribs().getAlloc());

    prim->evaluateInteriorPointWAttrib(pos, adata, foffsets,
				    u, v);
    uvpos = *(UT_Vector3 *) adata.getData(uvoff);
}
else
{
    uvoff = gdp->findTextureAttribute(GEO_VERTEX_DICT);
    if (uvoff >= 0)		// Has vertex attributes
    {
	GB_FloatOffsets		foffsets(0,0);
	GB_AttributeData	adata;

	// Build a table listing which attributes are floating point.
	gdp->vertexAttribs().getFloatOffsets(foffsets);

	// Resize our attribute data to fit the evaluated attribute
	adata.changeSize(gdp->vertexAttribs().getAlloc());

	prim->evaluateInteriorPointWAttrib(pos, adata, foffsets,
					u, v);
	uvpos = *(UT_Vector3 *) adata.getData(uvoff);
    }
}
-- 
        - Jeff Lait




More information about the Sidefx-houdini-list mailing list