Commit f66c3df5 authored by schurade's avatar schurade
Browse files

[ADD] make tube thickness adjustable

parent 22eed1f3
......@@ -58,11 +58,10 @@ void WCreateColorArraysThread::threadMain()
pc += (*m_lineLengths)[i]*3;
}
float r, g, b, rr, gg, bb;
float x1, x2, y1, y2, z1, z2;
float lastx, lasty, lastz;
for ( size_t i = m_left; i < m_right; ++i )
for ( int i = m_left; i < m_right; ++i )
{
x1 = (*m_vertices)[pc];
y1 = (*m_vertices)[pc + 1];
......
......@@ -198,6 +198,10 @@ void WMFiberDisplay::properties()
{
m_useTubesProp = m_properties2->addProperty( "Use Tubes", "Draw fiber tracts as fake tubes.", false );
m_coloring = m_properties2->addProperty( "Global/Local coloring", "Switches the coloring between global and local.", true );
m_tubeThickness = m_properties2->addProperty( "Tube thickness", "Adjusts the thickness of tubes", 50.,
boost::bind( &WMFiberDisplay::adjustTubes, this ) );
m_tubeThickness->setMin( 0 );
m_tubeThickness->setMax( 1000 );
}
void WMFiberDisplay::toggleTubes()
......@@ -212,6 +216,9 @@ void WMFiberDisplay::toggleTubes()
osg::ref_ptr<osg::Uniform>( new osg::Uniform( "globalColor", 1 ) );
osg::StateSet* rootState = m_osgNode->getOrCreateStateSet();
rootState->addUniform( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "globalColor", 1 ) ) );
m_uniformTubeThickness = osg::ref_ptr<osg::Uniform>( new osg::Uniform( "u_thickness", static_cast<float>( m_tubeThickness->get() ) ) );
rootState->addUniform( m_uniformTubeThickness );
}
else
{
......@@ -230,3 +237,11 @@ void WMFiberDisplay::toggleColoring()
m_tubeDrawable->dirtyDisplayList();
}
}
void WMFiberDisplay::adjustTubes()
{
if ( m_tubeThickness->changed() )
{
m_uniformTubeThickness->set( static_cast<float>( m_tubeThickness->get() ) );
}
}
......@@ -116,6 +116,7 @@ protected:
private:
WPropBool m_coloring; //!< Enable/Disable global (true) or local (false) coloring of the fiber tracts
WPropBool m_useTubesProp; //!< Property indicating whether to use tubes for the fibers tracts.
WPropDouble m_tubeThickness; //!< Property determining the thickness of tubes .
WBoolFlag m_noData; //!< Flag indicating whether there is data to display.
......@@ -150,6 +151,8 @@ private:
*/
osg::ref_ptr< WShader >m_shader;
osg::ref_ptr<osg::Uniform> m_uniformTubeThickness; //!< tube thickness
/**
* switches between fiber display and tube representation
*/
......@@ -160,6 +163,11 @@ private:
*/
void toggleColoring();
/**
* changes tube parameters
*/
void adjustTubes();
/**
* Node callback to handle updates properly
*/
......
......@@ -2,6 +2,7 @@ varying float tangent_dot_view;
varying vec3 tangentR3;
varying float s_param;
varying vec4 myColor;
uniform float u_thickness;
void main()
{
......@@ -9,7 +10,7 @@ void main()
vec3 tangent;
float thickness = 0.01;
float thickness = 0.01 * u_thickness/ 100.;
tangentR3 = gl_Normal;
tangent = (gl_ModelViewProjectionMatrix * vec4(gl_Normal,0.)).xyz; //< transform our tangent vector
......
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