Jump to content

Assign uv vertex attribute


Recommended Posts

Hi,

I'm creating polygon geometry and I'd like to add a uv vertex attribute.

The creation of the attribute is done with:

GB_AttributeRef uvRef = gdp.addVertexAttrib("uv", 3, GB_ATTRIB_FLOAT, NULL);

It seems that uvs have to be floats to let houdini read them correctly.

But now I have no idea how to assign my values. For normales it works fine with:

prim_poly_ptr->getVertex(vtxId).setValue<UT_Vector3>(normalRef, n);

Unfortunatly there seems to be no float3 type for the uvs. And assigning a vector like;

prim_poly_ptr->getVertex(vtxId).setValue<UT_Vector3>(uvRef, UT_Vector3(1, 2, 0));

crashes my program. Any tips?

Link to comment
Share on other sites

I don't know much about the HDK, but would it even make sense to have uv's stored as vectors (do they form a vector space? Maybe they do, dunno)

From the docs:

http://www.sidefx.com/docs/hdk11.0/hdk_geometry_attributes.html#getsetAttributes

and in particular:

ppt->setValue<float>(uv_id, u, 0);

ppt->setValue<float>(uv_id, v, 1);

and

float life[2];

ppt->set<float>(life_id, life, 2);

Edited by Macha
Link to comment
Share on other sites

Still having a problem. It seems that my vertex attribute definition is wrong. I set it with:

GB_AttributeRef uvRef = gdp.addVertexAttrib("uv", 3, GB_ATTRIB_FLOAT, NULL);

This results in this attribute line in my .geo file:

uv 0 float

But it should look like this:

uv 3 float 0 0 0

And of course because its wrong, noting is set or the tool crashes as soon as I try to set a value.

Any ideas what can be wrong with my method to add an vertex attribute?

edit: Okay I found the problem. The size of the attribute as to be given in bytes not in number of elements, so this will work.

GB_AttributeRef uvRef = gdp.addVertexAttrib("uv", sizeof(float) * 3, GB_ATTRIB_FLOAT, NULL);

Edited by haggi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...