Re: [osg-users] Toggling between wireframe modes

2018-11-07 Thread Igor Naigovzin
Init

auto scene = new osg::Group;
auto swtch = new osg::Switch;
auto scribe = new osgFX::Scribe;
auto node = osgDB::readNodeFile(..);
scene->addChild(swtch);
swtch->addChild(node);
swtch->addChild(scribe);
scribe->addChild(node);
swtch->setSingleChildOn(0);
viewer->setSceneData(scene);


void enterWireFrame(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer*
viewer)
{
osg::Node* scene = viewer->getSceneData();
osg::Switch* swtch = scene->asGroup()->getChild(0)->asSwitch();
swtch->setSingleChildOn(1);
}


void exitWireFrame(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer*
viewer)
{
osg::Node* scene = viewer->getSceneData();
osg::Switch* swtch = scene->asGroup()->getChild(0)->asSwitch();
swtch->setSingleChildOn(0);
}


On Wed, Nov 7, 2018 at 4:50 PM Charlie Tan  wrote:

> Hi,
>
> I just began using OSG for one of my projects. Basically one of the tasks
> is to enable/disable wireframe mode. I have tried to follow the
> osgkeyboardmouse example and tried to implement a different version(where
> you don't have to click on the model, but push a keyboard key) to toggle
> between the modes.
>
> To do this, I use 2 functions, enterWireFrame() and exitWireFrame() to
> toggle between the wireframe modes:
>
> void enterWireFrame(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer*
> viewer)
> {
>   osg::Node* scene = viewer->getSceneData();
>
>   osg::Group* parent = scene->getParent(0);
>   osg::Node* node = parent->getChild(0);
>
>   auto scribe = new osgFX::Scribe();
>   scribe->addChild(node);
>
>   parent->replaceChild(node, scribe);
> }
>
>
>
> void exitWireFrame(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer*
> viewer)
> {
> osg::Node* scene = viewer->getSceneData();
>
> osg::Group* parent = scene->getParent(0);
> osg::Node* node = (dynamic_cast(scene))->getChild(0);
>
> parent->replaceChild(parent, node);
> }
>
>
> I then ran enterWireFrame() followed by exitWireFrame(). I am able to
> render the wireframe after the 1st function, but the 2nd function does not
> do anything at all.
>
> I am totally new to OSG and would very much appreciate if someone could
> point me in the right direction where my mistake lies (probably in the 2nd
> function, but I can't figure it out).
>
> Thank you!
>
> Cheers,
> Charlie
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75172#75172
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] FBO question

2007-09-16 Thread Igor Naigovzin
Hello to all!
I have a simple question.
I want to render a two cameras (two different render surfaces) by exactly
the same scene.
But the two cameras are with different sizes.
I.e. the two cameras has to show me the same picture, but not the same size.
1. I'm using CameraNode and frame buffer object in order to render the scene
to the texture.
2***. I use the same texture for two cameras.
3. If I use RenderImplementationTarget as image then everything is OK.
But if I use RenderImplementationTarget as texture then only one camera
shows me the texture.

Is there any way to use the same texture rendered to frame buffer object for
the two cameras without copying it?
Or maybe there is another way to do this purpose?

Thank you a lot!

*** This is how I am doing it:

  root
   / \
  /   \
   CameraNodepolygon
   |
   |
   scene

CameraNode has a mask (only main camera traverses the CameraNode)
Both cameras render the polygon with the prerenderred (by frame buffer
object) texture.


===
  Igor Naigovzin
  Technion - CS and Biology Student
  Rafael - Software Developer
  email: [EMAIL PROTECTED]
===
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org