[osg-users] Add multiple OverlayNode.

Atlas Simen superjalien at hotmail.com
Sat Jun 8 19:30:33 PDT 2019


Hi,

How do I add multiple OverlayNode to a scene? I read the post "Viewer with 2 overlay nodes", using setOverlayTextureUnit to distinguish each OverlayNode, but this is limited by the number of multiple texture units supported. On my desktop, the number of multiple texture units supported by the graphics card is 4, and the maximum available texture unit is 3, which means I can only add 3 OverlayNode to the scene at most.


Code:

osg::ref_ptr<osg::Node> baseModel = createBase(osg::Vec3(center.x(), center.y(), baseHeight),radius);
osg::ref_ptr<osg::Node> movingModel = createMovingModel(center,radius*0.8f);

osg::ref_ptr<osg::Node> baseModel2 = createBase(osg::Vec3(center.x() + radius * 2, center.y() + radius * 0, baseHeight), radius);
osg::ref_ptr<osg::Node> movingModel2 = createMovingModel(osg::Vec3(center.x() + radius * 2, center.y() + radius * 0, center.z()), radius*0.8f);

if (overlay)
{
osgSim::OverlayNode* overlayNode = new osgSim::OverlayNode(technique);
overlayNode->setContinuousUpdate(true);
overlayNode->setOverlaySubgraph(movingModel);
overlayNode->setOverlayBaseHeight(baseHeight-0.01);
overlayNode->setOverlayTextureUnit(1);//default
overlayNode->addChild(baseModel);
root->addChild(overlayNode);

osgSim::OverlayNode* overlayNode2 = new osgSim::OverlayNode(technique);
overlayNode2->setContinuousUpdate(true);
overlayNode2->setOverlaySubgraph(movingModel2);
overlayNode2->setOverlayBaseHeight(baseHeight - 0.01);
overlayNode->setOverlayTextureUnit(2);
overlayNode2->addChild(baseModel2);
root->addChild(overlayNode2);
}
else
{
root->addChild(baseModel);
root->addChild(baseModel2);
}

root->addChild(movingModel);
root->addChild(movingModel2);


 

Thank you!

Cheers,
Simen

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



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: osganimate.cpp
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190609/d341857e/attachment.ksh>


More information about the osg-users mailing list