HI Émeric,

If you want to just change the display of a small number of selected
triangles then I'd suggest using a separate osg::Geometry that contains the
triangles that you want to effect.  This osg::Geometry would be dynamically
updated as you select different triangles.

The way to get this custom osg::Geometry triangles to display in place of
the original osg::Geometry is use the depth buffer to prevent both sets of
triangles overwriting each other.  If the case of opaque triangle it'd be
easy, you could simply use osg::PolygonOffset to push the selected
osg::Geometry in front of the original, or set the draw order to pre-draw
the selected osg::Geometry and set the depth test to only accept LESS (see
osg::Depth/glDepth), or render the selected osg::Geometry second and set
the depth test to accept LEQUAL (less than or equal).  You control the draw
order using osg::StateSet::setRenderBindDetails(binNum, "name"));

If you want to render the selected triangles transparent then you'll need
to prevent the original triangle from drawing by rendering the selected
osg::Geometry first with depth write turn on, but color mask set to off
(false,false,false,false see osg::ColorMask) and with depth test set to
LESS (for the main scene included the original osg::Geometry), and then a
second pass would have the selected osg::Geometry rendered in the
transparent bin, with depth test set to LEQUAL, and color mask back on.

Robert.


On 27 January 2014 09:29, Émeric MASCHINO <[email protected]> wrote:

> Hi Nick,
>
> Thanks for the pointers.
>
> > although they are right in the book about colors being vertex attributes
> I
> > think You can achieve the effect You are after by using osg::Material and
> > adjusting the alpha and then use a proper Blending Function. Have a look
> at
> > osghud example it has blended quad on top of the screen.
>
> If I'm not mistaken, osg::Material is part of a node's StateSet,
> that's only available starting at the Geode or Geometry level.
> So, altering the blending function there will impact all the triangle
> faces of my model, not only the selected one.
>
> > If You want to show/hide then probably the best is to use setNodeMask on
> > Your osg::Geode containing the osg::Geometry
>
> Here again, since setNodeMask is only available starting at the Geode
> level, this would require that I put all the individual triangle faces
> of the model in separate Geodes in order to individually show/hide
> them.
> Indeed, I don't know beforehand which triangle face will be selected
> by the end-user.
>
>      Émeric
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to