30 #include <osg/Drawable>
31 #include <osg/Geometry>
33 #include "WEEGEvent.h"
34 #include "WHeadSurfaceCallback.h"
35 #include "core/common/WFlag.h"
36 #include "core/common/WPropertyTypes.h"
37 #include "core/common/WPropertyVariable.h"
40 WPropDouble colorSensitivity,
41 std::shared_ptr<
WFlag< std::shared_ptr< WEEGEvent > > > event )
42 : m_currentColorSensitivity( 1.0 ),
43 m_currentTime( -1.0 ),
44 m_channelIDs( channelIDs ),
45 m_colorSensitivity( colorSensitivity ),
53 std::shared_ptr< WEEGEvent >
event =
m_event->get();
54 const double time =
event->getTime();
57 osg::Geometry* geometry =
static_cast< osg::Geometry*
>( drawable );
60 osg::FloatArray* texCoords =
static_cast< osg::FloatArray*
>( geometry->getTexCoordArray( 0 ) );
63 const std::size_t size = 256u;
64 const std::vector< double >& values =
event->getValues();
65 for( std::size_t vertexID = 0; vertexID < texCoords->size(); ++vertexID )
67 (*texCoords)[vertexID] = values[
m_channelIDs[vertexID]] * ( 0.5 - 0.5 / size ) / colorSensitivity + 0.5;
72 for( std::size_t vertexID = 0; vertexID < texCoords->size(); ++vertexID )
74 (*texCoords)[vertexID] = 0.5f;
78 geometry->setTexCoordArray( 0, texCoords );
80 osg::Vec4Array* colors =
new osg::Vec4Array;
81 colors->push_back( osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f ) );
82 geometry->setColorArray( colors );
83 geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
Class to have a simple notification/condition system for simple flags.
virtual void update(osg::NodeVisitor *, osg::Drawable *drawable)
Callback method called by the NodeVisitor.
WHeadSurfaceCallback(const std::vector< std::size_t > &channelIDs, WPropDouble colorSensitivity, std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event)
Constructor.
const std::vector< std::size_t > m_channelIDs
the mapping from vertex indices to channel IDs
WPropDouble m_colorSensitivity
The sensitivity of the color map as property.
std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event
event marking a special time position as WFlag
double m_currentColorSensitivity
the sensitivity of the color map which is currently used
double m_currentTime
The time position which is currently used.