Commit 4141889b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added tf generation example to DVR module.

parent 4e7a277d
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <cmath>
#include <osg/Geode> #include <osg/Geode>
#include <osg/Group> #include <osg/Group>
...@@ -31,6 +32,7 @@ ...@@ -31,6 +32,7 @@
#include <osg/ShapeDrawable> #include <osg/ShapeDrawable>
#include <osg/StateAttribute> #include <osg/StateAttribute>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include "../../common/WColor.h" #include "../../common/WColor.h"
#include "../../common/WPropertyHelper.h" #include "../../common/WPropertyHelper.h"
...@@ -172,6 +174,50 @@ osg::ref_ptr< osg::Image > genWhiteNoise( size_t resX ) ...@@ -172,6 +174,50 @@ osg::ref_ptr< osg::Image > genWhiteNoise( size_t resX )
return randImage; 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() void WMDirectVolumeRendering::moduleMain()
{ {
m_shader = osg::ref_ptr< WGEShader > ( new WGEShader( "WMDirectVolumeRendering", m_localPath ) ); m_shader = osg::ref_ptr< WGEShader > ( new WGEShader( "WMDirectVolumeRendering", m_localPath ) );
......
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