Commit 35724d0a authored by cornimueller's avatar cornimueller
Browse files

[ADD] EEG View module now displays the head surface using a delaunay triangulation

parent 9aa533c3
......@@ -24,6 +24,8 @@
#include <string>
#include <osgUtil/DelaunayTriangulator>
#include "../../graphicsEngine/WGEUtils.h"
#include "../../kernel/WKernel.h"
#include "WMEEGView.h"
......@@ -340,6 +342,38 @@ void WMEEGView::redraw()
m_rootNode3d->addChild( textGeode );
}
// draw head surface
osg::ref_ptr< osg::Vec3Array > positions( new osg::Vec3Array );
for( size_t channel = 0; channel < nbChannels; ++channel )
{
positions->push_back( wge::osgVec3( m_eeg->getChannelPosition( channel ) ) );
}
osg::ref_ptr< osg::Vec3Array > normals( new osg::Vec3Array );
osg::ref_ptr< osgUtil::DelaunayTriangulator> triangulator( new osgUtil::DelaunayTriangulator( positions, normals ) );
if( triangulator->triangulate() )
{
osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray( positions );
geometry->setNormalArray( normals );
geometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back( osg::Vec4( 1.0, 1.0, 1.0, 1.0 ) );
geometry->setColorArray( colors );
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
geometry->addPrimitiveSet( triangulator->getTriangles() );
osg::Geode* geode = new osg::Geode;
geode->addDrawable( geometry );
m_rootNode3d->addChild( geode );
}
else
{
errorLog() << "Couldn't triangulate head surface";
}
if( m_wasActive )
{
debugLog() << "Adding rootNode to scene after redraw";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment