Jump to content

Updating Displayed Normals ?


Recommended Posts

I've written a SOP that defines a fixed number of points, then depending on the input parameters moves these points around and builds a new set of primitives. For efficiency I don't gdp->clearAndDestroy() each time, instead I delete all the primitives and define a new bunch on top of the existing points. This works except that when displaying, the resulting surface normals (opengl display only, ie not attributes) aren't being recalculated properly. Simply appending a Facet SOP with no operations selected is enough to get things displaying correctly again. So I'm guessing the clearAndDestroy() is clearing some cached values, how can I do it manually ?

Thanks,

Drew

Link to comment
Share on other sites

Yep, that fixed it. I'd trawled across a lot of examples, docs and headers and hadn't run into it ...

Thanks.

Doing

gdp->normal();

will recompute the normals, is that all you need?

Si

Link to comment
Share on other sites

Oops, it didn't fix it. This actually adds a normal point attribute.

-Drew

Yep, that fixed it. I'd trawled across a lot of examples, docs and headers and hadn't run into it ...

Thanks.

Link to comment
Share on other sites

Oops, it didn't fix it. This actually adds a normal point attribute.

-Drew

duplicate answer in another thread.

Sorry, I assumed you must have point normals coming in, i've never seen a problem with building geometry with no normals where it shaded wrong. I tend to just do a test for N, if it exists I recalculate them if it doesn't I leave them alone. Odd....

Link to comment
Share on other sites

For the record the following solution for this was provided by MarkE on the devkit list ...

For OGL display, we compute normals into an "internal" attribute. You

probably just want to clear that.

You can do that by:

gdp->destroyPointAttrib("internalN", sizeof(UT_Vector3), GB_ATTRIB_MIXED);

and in a similar vein over on the sidefx forums, Ondrej gave this solution to another similar sounding situation. I wonder if I should really be doing this, probably more expensive operation, instead ? Without knowing whats going on underneath it's hard to know the correct answer.

You'll probably want to call gdp->notifyCache(GU_CACHE_ALL) to ensure that any caches (including display caches) are rebuilt.

-Drew

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...