Commit b6f819b7 authored by Alexander Wiebel's avatar Alexander Wiebel

[ADD] possibility to change color of isosurface

parent e396b2b1
......@@ -210,6 +210,8 @@ void WMMarchingCubes::properties()
m_opacityProp->setMax( 100 );
m_useTextureProp = m_properties->addProperty( "Use Texture", "Use texturing of the surface?", false );
m_surfaceColor = m_properties->addProperty( "Surface Color", "Description.", WColor( 0.3, 0.3, 0.3, 1.0 ) );
}
void WMMarchingCubes::generateSurfacePre( double isoValue )
......@@ -684,7 +686,8 @@ void WMMarchingCubes::renderMesh( boost::shared_ptr< WTriangleMesh2 > mesh )
// colors
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back( osg::Vec4( .9f, .9f, 0.9f, 1.0f ) );
WColor c = m_surfaceColor->get( true );
colors->push_back( osg::Vec4( c.getRed(), c.getGreen(), c.getBlue(), 1.0f ) );
surfaceGeometry->setColorArray( colors );
surfaceGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
......@@ -1012,7 +1015,7 @@ WTriangleMesh2 WMMarchingCubes::load( std::string /*fileName*/ )
return triMesh;
}
void WMMarchingCubes::updateTextures()
void WMMarchingCubes::updateGraphics()
{
if ( m_active->get() )
{
......@@ -1023,6 +1026,17 @@ void WMMarchingCubes::updateTextures()
m_surfaceGeode->setNodeMask( 0x0 );
}
if( m_surfaceColor->changed() )
{
osg::Vec4Array* colors = new osg::Vec4Array;
WColor c = m_surfaceColor->get( true );
colors->push_back( osg::Vec4( c.getRed(), c.getGreen(), c.getBlue(), 1.0f ) );
osg::ref_ptr< osg::Geometry > surfaceGeometry = m_surfaceGeode->getDrawable( 0 )->asGeometry();
surfaceGeometry->setColorArray( colors );
surfaceGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
}
if ( m_textureChanged || m_opacityProp->changed() || m_useTextureProp->changed() )
{
m_textureChanged = false;
......
......@@ -159,7 +159,7 @@ public:
/**
* updates textures and shader parameters
*/
void updateTextures();
void updateGraphics();
protected:
/**
......@@ -258,6 +258,7 @@ private:
WPropDouble m_isoValueProp; //!< Property holding the iso value
WPropInt m_opacityProp; //!< Property holding the opacity valueassigned to the surface
WPropBool m_useTextureProp; //!< Property indicating whether to use texturing with scalar data sets.
WPropColor m_surfaceColor; //!< Property determining the color for the surface if no textures are displayed
/**
* True when textures haven changed.
......@@ -348,7 +349,7 @@ inline void SurfaceNodeCallback::operator()( osg::Node* node, osg::NodeVisitor*
{
if ( m_module )
{
m_module->updateTextures();
m_module->updateGraphics();
}
traverse( node, nv );
}
......
......@@ -96,7 +96,7 @@ void lookupTex(inout vec4 col, in int type, in sampler3D tex, in float threshol
void main()
{
vec4 col = vec4(0.3, 0.3, 0.3, 1.0);
vec4 col = gl_Color;
vec4 ambient = vec4(0.0);
vec4 diffuse = vec4(0.0);
......
......@@ -8,5 +8,7 @@ void main()
prepareLight();
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}
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