[osg-users] osgFX::Outline and Stencil

Théo NASSOUR charbel.nassour at gmail.com
Wed Jun 22 04:59:35 PDT 2016


Hi,

I have Two views in my scene, both of them are in a Composite Viewer. I have added the outline to the truck, and then i have added the truck to my scene. Why only under the viewport of the cube i have the outline.

Here is a part of my code, and i have attached an image of the result

///OSG Scene : View
osg::ref_ptr<osgViewer::View> mView;
osg::ref_ptr<osgViewer::View> mCubeView;
///OSG Scene : Viewer
osg::ref_ptr<osgViewer::CustomCompositeViewer> mViewer;

...

osg::ref_ptr<osg::DisplaySettings> ds = osg::DisplaySettings::instance();
ds->setMinimumNumStencilBits(8);
mView->getCamera()->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
mView->getCamera()->setClearStencil(0);
mView->getCamera()->setViewport(new osg::Viewport(0, 0, mTraits->width, mTraits->height));
mViewer->addView(mView.get());
mCubeView->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
mCubeView->getCamera()->setRenderOrder(osg::Camera::POST_RENDER);
mCubeView->getCamera()->setClearStencil(0);
mCubeView->getCamera()->setViewport(new osg::Viewport((mTraits->width - 175), (mTraits->height - 175), 150, 150,));
mViewer->addView(mCubeView.get());
...
mView->setSceneData(mSceneData.get());
...

{
osg::ref_ptr<osg::Node> outlineModel = osgDB::readNodeFile("D:\\Data\\New_Test\\OpenSceneGraph-3.4.0\\OpenSceneGraph\\build\\x64\\bin\\dumptruck.osgt");
// create outline effect
osg::ref_ptr<osgFX::Outline> outline = new osgFX::Outline;
mSceneData->addChild(outline.get());
outline->setWidth(8);
outline->setColor(osg::Vec4(1, 1, 0, 1));
outline->addChild(outlineModel.get());
}

Thank you!

Cheers,
Théo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=67735#67735




Attachments: 
http://forum.openscenegraph.org//files/truck_628.png





More information about the osg-users mailing list