Skip to content

Commit 4345a19

Browse files
author
Daniel Wickeroth
committed
MADIconnect: render transparency correctely
1 parent fb6b1e6 commit 4345a19

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/OpenCOVER/plugins/ukoeln/MADIconnect/MADIconnect.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,13 @@ void MADIconnect::handleMessage(Message *m)
546546
int rgb[3];
547547
tb >> rgb[0] >> rgb[1] >> rgb[2];
548548

549-
float transparency;
549+
float transparency = 0.0f;
550550
tb >> transparency;
551551

552-
std::cout << "MADIconnect::Color RGBA: " << rgb[0] << ", " << rgb[1] << ", " << rgb[2] << ", " << transparency << std::endl;
552+
const float alpha = std::max(0.f, std::min(1.f, 1.f - transparency));
553+
554+
std::cout << "MADIconnect::Color RGBA: " << rgb[0] << ", " << rgb[1] << ", "
555+
<< rgb[2] << ", " << alpha << std::endl;
553556

554557
// Apply color to all neurons
555558
int numNeurons = 0;
@@ -577,7 +580,15 @@ void MADIconnect::handleMessage(Message *m)
577580
if (geode)
578581
{
579582
cout << "MADIconnect:: Found geode." << endl;
580-
VRSceneGraph::instance()->setColor(geode, rgb, 1.0f);
583+
VRSceneGraph::instance()->setColor(geode, rgb, alpha);
584+
if (alpha < 0.999f)
585+
{
586+
cout << "MADIconnect:: Setting transparency." << endl;
587+
osg::StateSet* ss = geode->getOrCreateStateSet();
588+
ss->setMode(GL_BLEND, osg::StateAttribute::ON);
589+
ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
590+
}
591+
581592
found = true;
582593
}
583594
else

0 commit comments

Comments
 (0)