« Return to Thread: modify the real mesh using Mesh_modifier

Re: modify the real mesh using Mesh_modifier

by Timothy M. Shead :: Rate this Message:

Reply to Author | View in Thread

Carsten Haubold wrote:
> Ah okay, I fogot to add mesh_sink to the interfaces, I didnt look at
> that line :)
>
> But the problem still is, when I add the Plugin I need to select it
> before I'm able to change the value, but as soon as I do that my
> selection gets discarded and thus the new value is not applyed to any
> point.
I've committed some fixes to NubsSetWeight, there were several issues
worth mentioning:

* When you make a selection, then "apply" a modifier, the selection has
to be stored somewhere.  That somewhere is your modifier, so you will
see that it now derives from k3d::mesh_selection_sink, which provides
the storage.
* When you are a selection sink, you have to "merge" the stored
selection with your input before you can test for selections.  This may
seem a little funny, but it enables us to mix interactive selection with
pipeline components that create/modify selections, and it also makes it
possible to write modifiers that use *multiple* selections.
* You wouldn't have noticed any of this in the deformation modifiers,
because they derive from a different base-class that handles these details.
* You can't modify your inputs!  Const-casting was trying to tell you
something here.
* A mesh is a three-level hiearchy: mesh -> gprim -> arrays.  We do
shallow-copying at all levels, so when you go to modify anything, you
generally have to create a deep copy of the gprim, and then deep copies
of any arrays you wish to modify.  Note the calls to k3d::make_unique()
that do this deep-copying, and return a non-const object that you can
modify.
* Selections are floating-point weights in K-3D, not bools.  Although
it's an under-utilized feature at a UI level, the idea is that modifiers
should - wherever reasonable - use the selection to weight their
operation.  In this case you'll note that I used k3d::mix() to do a
linear interpolation between the original and new weights.  Since
selections are currently all 0.0 or 1.0, this works the way one would
expect, but "fuzzy" selections in the future will Just Work also.

Cheers,
Tim





-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

 « Return to Thread: modify the real mesh using Mesh_modifier

LightInTheBox - Buy quality products at wholesale price!