Commit 5f6d4824 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] drop down menu to select illustration type

parent c061d567
......@@ -167,7 +167,7 @@ void WMSurfaceIllustrator::properties()
m_opacity->setMin( 0.0 );
m_opacity->setMax( 100.0 );
// Allow the user to select different colormodes
// Allow the user to select different color modes
boost::shared_ptr< WItemSelection > colorModes( boost::shared_ptr< WItemSelection >( new WItemSelection() ) );
colorModes->addItem( "Single Color", "The whole surface is colored using the default color." );
colorModes->addItem( "From Mesh", "The surface is colored according to the mesh." );
......@@ -188,6 +188,20 @@ void WMSurfaceIllustrator::properties()
m_parameterWidth->setMin( 0.0 );
m_parameterWidth->setMax( 2.0 );
// Allow the user to select different rendering modes
boost::shared_ptr< WItemSelection > illustrationModes( boost::shared_ptr< WItemSelection >( new WItemSelection() ) );
illustrationModes->addItem( "X-slab", "Slab normal to x-axis." );
illustrationModes->addItem( "Stream ribbon", "A range of streamlines (if red color represents s-parameter of surface)." );
illustrationModes->addItem( "Time ribbon", "A range timelines (if green color represents t-parameter of surface)." );
illustrationModes->addItem( "View-dependent opacity", "Less opaque where surface normal parallel to view direction." );
illustrationModes->addItem( "View-dependent opacity (inverted)", "More opqaue where surface normal parallel to view direction." );
m_illustrationMode = m_coloringGroup->addProperty( "Illustration mode",
"Choose one of the types of illustrating the surface.",
illustrationModes->getSelectorFirst(),
m_propCondition );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_illustrationMode );
// call WModule's initialization
WModule::properties();
}
......@@ -273,6 +287,8 @@ void WMSurfaceIllustrator::renderMesh( boost::shared_ptr< WTriangleMesh > mesh )
geode->getOrCreateStateSet()->addUniform( m_colorMapTransformation );
geode->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_parameterCenter", m_parameterCenter ) );
geode->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropDouble >( "u_parameterWidth", m_parameterWidth ) );
WItemSelector illustrationModeSelector = m_illustrationMode->get( true );
geode->getOrCreateStateSet()->addUniform( new osg::Uniform( "u_renderingType", static_cast<int>( illustrationModeSelector.getItemIndexOfSelected( 0 ) ) ) );
// apply shader only to mesh
m_shader->apply( geode );
......
......@@ -151,6 +151,11 @@ private:
*/
WPropDouble m_parameterWidth;
/**
* Select the type of illustration applied in the shader
*/
WPropSelection m_illustrationMode;
/**
* A condition used to notify about changes in several properties.
*/
......
......@@ -44,6 +44,10 @@ uniform float u_parameterCenter;
* The width of the parameter interval to be selected
*/
uniform float u_parameterWidth;
/**
* Chooses the type of rendering that should be performed within this shader
*/
uniform int u_renderingType;
#include "WGEShadingTools.glsl"
......@@ -52,15 +56,7 @@ void main()
vec4 col = gl_Color;
//col.rgb = vec3( .7);
float widthHalf = u_parameterWidth / 2.0;
// Streamribbon
//if( col.r > u_parameterCenter + widthHalf || col.r < u_parameterCenter - widthHalf ) discard;
// Timeribbon
//if( col.g > u_parameterCenter + widthHalf || col.g < u_parameterCenter - widthHalf) discard;
// Slab
//if( verpos.x > u_parameterCenter + widthHalf || verpos.x < u_parameterCenter - widthHalf ) discard;
vec2 param = col.rg;
// calculate lighting
float light = blinnPhongIlluminationIntensity( normalize( -v_normal ) );
......@@ -72,10 +68,32 @@ void main()
vec3 normal = normalize( v_normal );
float dotNorm = dot( vec3( 0.0, 0.0, 1.0 ), normal );
dotNorm *= sign( dotNorm );
// View-dependent transparency
//col.a = 1 - dotNorm * dotNorm;
// Unnatural opposite effect
col.a = dotNorm* dotNorm;
if( u_renderingType == 0 )
{
// Slab
if( verpos.x > u_parameterCenter + widthHalf || verpos.x < u_parameterCenter - widthHalf ) discard;
}
else if( u_renderingType == 1 )
{
// Streamribbon
if( param.s > u_parameterCenter + widthHalf || param.s < u_parameterCenter - widthHalf ) discard;
}
else if( u_renderingType == 2 )
{
// Timeribbon
if( param.t > u_parameterCenter + widthHalf || param.t < u_parameterCenter - widthHalf) discard;
}
else if( u_renderingType == 3 )
{
// View-dependent transparency
col.a = 1 - dotNorm * dotNorm;
}
else if( u_renderingType == 4 )
{
// Unnatural opposite effect
col.a = dotNorm* dotNorm;
}
gl_FragColor = col;
......
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