[osg-users] different materials for a geometry and highlight

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Thu Sep 22 04:03:52 PDT 2016

Am 9/22/2016 um 12:23 PM schrieb Gianni Ambrosio:
> SMesserschmidt wrote:
>> So basically you are raping the primitive sets to color the primitive?
> Yes, that's why at the beginning I asked help to suggest me the best way to implement this. Nobody replied so I found this way.
Maybe your questions was a bit to vague and you took a shot in the dark 
with your primitive set attempt.
You were asking for material not for color, so I assumed something else.
> SMesserschmidt wrote:
>> That is certainly a complicated way in case you simply have a bunch of triangles which you want to re-color during selection. I'd advice to use an additional vertex-attribute (per vertex) holding your "color-index" and evaluate it in the vertex-shader and modify this based on the intersected indices.
> In fact it is a little tricky even if I'm not sure I would have a bunch of nodes to change. But who knows ...
> Anyway thans for the hint. I'm trying to understand what does that means exactly but if in the menwhile you can explain me a little bit in detail it would be nice.
The minimalistic way would be to simply add uniform face colors (vertex 
color) for each face in your geometry and change the appropriate face in 
the buffer. So you have a buffer with n-entries where n is the number of 
faces your primitive set creates.
As you are using indexed vertices you simply need to find out which face 
is affected by the picked indices and modify those color entries.
I'd like to help you here with some example, but I'm chasing a project 
deadline right now. The only advice I can give is to start with a 
minimal example, modifying the colors without picking to understand what 
is going on and then to integrate picking and interaction.

> Regards,
> Gianni
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68694#68694
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list