Re: [osg-users] Update node color on demand

2018-11-26 Thread Trajce Nikolov NICK
Hi, try in void ColorVisitor::apply(osg::Geode ) { . if (colorArrays) { for (unsigned int i = 0; i < colorArrays->size(); i++) { osg::Vec4 *color = >operator [](i); // // could also use *color =

Re: [osg-users] Update node color on demand

2018-11-26 Thread Diego Mancilla
Hello Trajce, The visitor class implementation is on my previous post on this thread. I took that code from Gordon Tomlison's OSG Samples, and it works when is used previous to the rendering as you can see on my initial post (other thread:

Re: [osg-users] Update node color on demand

2018-11-26 Thread Trajce Nikolov NICK
Hi Diego, can you post your Visitor code? It can be something like missing calling ->dirty() on the color array or such On Mon, Nov 26, 2018 at 8:30 PM Diego Mancilla wrote: > Hello, > > I have tried Eran's suggestion with no success. I have successfully > created the handler, and it gets

Re: [osg-users] Update node color on demand

2018-11-26 Thread Diego Mancilla
Hello, I have tried Eran's suggestion with no success. I have successfully created the handler, and it gets called but no color change... My current code: On main: Code: _lines = osgDB::readNodeFile("lines.dxf"); _topo->setDataVariance(osg::Object::DYNAMIC); osg::Geode* geode = new

Re: [osg-users] Update node color on demand

2018-11-26 Thread Diego Mancilla
Hello Eran, Thank you again. I will try what you suggest. Cheers, -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=75244#75244 ___ osg-users mailing list osg-users@lists.openscenegraph.org

Re: [osg-users] Update node color on demand

2018-11-24 Thread Eran Cohen
Hi Diego, You can pass user events to the viewer (and thus to its Event Handlers): Code: // This struct will be passed to the event handler with the relevant parameters (for example, the node you want to affect and the color to change it to) struct ChangeColorEvent : public osg::Referenced {

Re: [osg-users] Update node color on demand

2018-11-24 Thread Diego Mancilla
Hello Eran, Thank you very much for your answer. I should have been more explicit, due to the fact than I'm a newbie on OSG (and 3D development). I have an OSG viewer embedded on a Qt5 application. So the idea is that the user can change the color of one node (some dxf lines) on demand

Re: [osg-users] Update node color on demand

2018-11-24 Thread Eran Cohen
Hi, To respond to user events you can either inherit from osg::Callback and install it on your node as an EventCallback: Code: class ColorCallback : public osg::Callback { public: virtual bool run(osg::Object* object, osg::Object* data) override { auto nv =

[osg-users] Update node color on demand

2018-11-24 Thread Diego Mancilla
Hello, I'm trying to change a node color on demand from my application. The idea is that the user, once the initial rendering took place can change the color of a node by pressing a key (or something similar). I know already hoy to change the color using a NodeVisitor (previous to the