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
4141889b
Commit
4141889b
authored
Apr 15, 2011
by
Sebastian Eichelbaum
Browse files
[ADD] - added tf generation example to DVR module.
parent
4e7a277d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
src/modules/directVolumeRendering/WMDirectVolumeRendering.cpp
...modules/directVolumeRendering/WMDirectVolumeRendering.cpp
+46
-0
No files found.
src/modules/directVolumeRendering/WMDirectVolumeRendering.cpp
View file @
4141889b
...
...
@@ -24,6 +24,7 @@
#include <string>
#include <utility>
#include <cmath>
#include <osg/Geode>
#include <osg/Group>
...
...
@@ -31,6 +32,7 @@
#include <osg/ShapeDrawable>
#include <osg/StateAttribute>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include "../../common/WColor.h"
#include "../../common/WPropertyHelper.h"
...
...
@@ -172,6 +174,50 @@ osg::ref_ptr< osg::Image > genWhiteNoise( size_t resX )
return
randImage
;
}
/**
* Example TF generator. This will be extended with some strategy-pattern later.
*
* \return TF as image.
*/
osg
::
ref_ptr
<
osg
::
Image
>
genTF
()
{
const
size_t
resX
=
256
;
osg
::
ref_ptr
<
osg
::
Image
>
tfImage
=
new
osg
::
Image
();
tfImage
->
allocateImage
(
resX
,
1
,
1
,
GL_RGBA
,
GL_UNSIGNED_BYTE
);
unsigned
char
*
tf
=
tfImage
->
data
();
for
(
size_t
x
=
0
;
x
<
resX
;
++
x
)
{
if
(
x
>
127
)
{
double
i
=
(
static_cast
<
double
>
(
x
-
128
)
/
128.0
)
*
2.0
*
15.0
;
size_t
imod
=
fmod
(
i
,
2
);
std
::
cout
<<
imod
<<
std
::
endl
;
if
(
imod
==
0
)
{
tf
[
4
*
x
+
0
]
=
255
;
tf
[
4
*
x
+
1
]
=
86
;
tf
[
4
*
x
+
2
]
=
86
;
tf
[
4
*
x
+
3
]
=
127
;
//26;
}
else
{
tf
[
4
*
x
+
0
]
=
255
;
tf
[
4
*
x
+
1
]
=
191
;
tf
[
4
*
x
+
2
]
=
0
;
tf
[
4
*
x
+
3
]
=
64
;
//26;
}
}
if
(
x
<=
127
)
{
tf
[
4
*
x
+
0
]
=
0
;
tf
[
4
*
x
+
1
]
=
94
;
tf
[
4
*
x
+
2
]
=
255
;
tf
[
4
*
x
+
3
]
=
2
*
(
127
-
x
);
}
}
return
tfImage
;
}
void
WMDirectVolumeRendering
::
moduleMain
()
{
m_shader
=
osg
::
ref_ptr
<
WGEShader
>
(
new
WGEShader
(
"WMDirectVolumeRendering"
,
m_localPath
)
);
...
...
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