Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
2daf47f6
Commit
2daf47f6
authored
Nov 25, 2010
by
Alexander Wiebel
Browse files
[ADD] allow to change context width interactively
parent
ce748f03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
src/modules/sliceContext/WMSliceContext.cpp
src/modules/sliceContext/WMSliceContext.cpp
+4
-4
src/modules/sliceContext/WMSliceContext.h
src/modules/sliceContext/WMSliceContext.h
+2
-2
src/modules/sliceContext/shaders/WMSliceContext-fragment.glsl
...modules/sliceContext/shaders/WMSliceContext-fragment.glsl
+27
-4
No files found.
src/modules/sliceContext/WMSliceContext.cpp
View file @
2daf47f6
...
...
@@ -73,8 +73,8 @@ const std::string WMSliceContext::getDescription() const
void
WMSliceContext
::
connectors
()
{
// The input fiber dataset
m_fiberInput
=
boost
::
shared_ptr
<
WModuleInputData
<
WDataSetFibers
>
>
(
new
WModuleInputData
<
WDataSetFibers
>
(
shared_from_this
(),
"fibers"
,
"The fiber dataset to use as context."
)
m_fiberInput
=
boost
::
shared_ptr
<
WModuleInputData
<
const
WDataSetFibers
>
>
(
new
WModuleInputData
<
const
WDataSetFibers
>
(
shared_from_this
(),
"fibers"
,
"The fiber dataset to use as context."
)
);
// As properties, every connector needs to be added to the list of connectors.
...
...
@@ -128,7 +128,7 @@ void WMSliceContext::moduleMain()
// To query whether an input was updated, simply ask the input:
bool
dataUpdated
=
m_fiberInput
->
updated
();
boost
::
shared_ptr
<
WDataSetFibers
>
fibers
=
m_fiberInput
->
getData
();
boost
::
shared_ptr
<
const
WDataSetFibers
>
fibers
(
m_fiberInput
->
getData
()
)
;
bool
dataValid
=
fibers
;
if
(
!
(
dataValid
&&
dataUpdated
)
)
...
...
@@ -226,7 +226,7 @@ osg::ref_ptr< osg::Geode > WMSliceContext::genTractGeode( const std::vector< siz
for
(
size_t
i
=
0
;
i
<
vertices
->
size
();
++
i
)
{
double
distance
=
fabs
(
m_crosshairProp
->
get
()[
0
]
-
(
*
vertices
)[
i
][
0
]
);
texCoords
->
push_back
(
wmath
::
WPosition
(
distance
,
0.0
,
0.0
)
);
texCoords
->
push_back
(
wmath
::
WPosition
(
distance
,
m_contextWidthProp
->
get
()
,
0.0
)
);
}
geometry
->
setTexCoordArray
(
0
,
texCoords
);
...
...
src/modules/sliceContext/WMSliceContext.h
View file @
2daf47f6
...
...
@@ -135,7 +135,7 @@ private:
*/
void
checkContainment
(
std
::
vector
<
size_t
>*
selected
,
bool
counting
,
double
distance
)
const
;
boost
::
shared_ptr
<
WModuleInputData
<
WDataSetFibers
>
>
m_fiberInput
;
//!< The fiber dataset which is going to be filtered.
boost
::
shared_ptr
<
WModuleInputData
<
const
WDataSetFibers
>
>
m_fiberInput
;
//!< The fiber dataset which is going to be filtered.
WPropPosition
m_crosshairProp
;
//!< position of the navigation
WPropInt
m_insideCountProp
;
//!< The number of positions of a fiber that have to be inside the context for the fiber to be considered.
...
...
@@ -144,7 +144,7 @@ private:
boost
::
shared_ptr
<
WCondition
>
m_propCondition
;
//!< A condition used to notify about changes in several properties.
wmath
::
WPosition
m_current
;
//!< The current position of the slices.
boost
::
shared_ptr
<
WDataSetFibers
>
m_tracts
;
//!< The fiber data set used for the context.
boost
::
shared_ptr
<
const
WDataSetFibers
>
m_tracts
;
//!< The fiber data set used for the context.
osg
::
ref_ptr
<
WGEManagedGroupNode
>
m_osgNode
;
//!< OSG node for this module.
osg
::
ref_ptr
<
osg
::
Group
>
m_rootNode
;
//!< OSG node for this module.
...
...
src/modules/sliceContext/shaders/WMSliceContext-fragment.glsl
View file @
2daf47f6
...
...
@@ -3,14 +3,37 @@ varying vec4 myColor;
/*
* simple fragment shader that uses a texture on fibers
*/
void
onlyNearFibers
()
{
float
distance
=
gl_TexCoord
[
0
].
x
;
// float maxDist = gl_TexCoord[0].y;
// float normalizedDistance = distance / maxDist;
// normalizedDistance = clamp ( normalizedDistance, 0.0, 1.0 );
vec4
color
=
myColor
;
color
.
a
=
.
1
;
if
(
distance
>
1
)
color
.
a
=
0
;
gl_FragColor
=
color
;
}
void
main
()
{
vec4
color
=
myColor
;
float
alpha
=
1
-
(
gl_TexCoord
[
0
].
x
/
100
.
);
float
distance
=
gl_TexCoord
[
0
].
x
;
float
maxDist
=
gl_TexCoord
[
0
].
y
;
distance
=
clamp
(
distance
,
0
,
maxDist
);
float
alpha
=
1
-
(
distance
/
maxDist
);
alpha
*=
alpha
;
alpha
*=
alpha
;
alpha
*=
alpha
;
alpha
*=
alpha
;
alpha
*=
alpha
;
float
darkness
=
clamp
(
alpha
*
.
3
,
0
.
0
,
1
.
0
);
alpha
=
clamp
(
pow
(
alpha
,
100
.
)
+
.
1
,
0
.
0
,
1
.
0
);
color
=
vec4
(
darkness
,
clamp
(
.
5
-
darkness
,
0
.
0
,
1
.
0
),
1
.
0
,
alpha
)
;
//color = vec4( darkness, clamp( .5 - darkness, 0.0, 1.0), 1
.0, .0
1 + alpha
);
color
.
a
=
.
01
+
alpha
;
gl_FragColor
=
color
;
}
// onlyNearFibers();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment