From 3cec676d9830bb1a40d724b5096c4d92544d7a25 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Aug 2008 15:08:04 +0000 Subject: [PATCH] Added --mip command line option which enables Maximum Intensity Projection filtering --- examples/osgvolume/osgvolume.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/examples/osgvolume/osgvolume.cpp b/examples/osgvolume/osgvolume.cpp index 885ac63c4..4d1d88df8 100644 --- a/examples/osgvolume/osgvolume.cpp +++ b/examples/osgvolume/osgvolume.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -745,7 +747,7 @@ osg::Node* createShaderModel(osg::ref_ptr& image_3d, osg::ref_ptrgetOrCreateStateSet(); @@ -863,6 +865,12 @@ osg::Node* createShaderModel(osg::ref_ptr& image_3d, osg::ref_ptrsetMode(GL_CULL_FACE, osg::StateAttribute::ON); + if (maximumIntensityProjection) + { + stateset->setAttribute(new osg::BlendFunc(osg::BlendFunc::ONE, osg::BlendFunc::ONE)); + stateset->setAttribute(new osg::BlendEquation(osg::BlendEquation::RGBA_MAX)); + } + { osg::Geometry* geom = new osg::Geometry; @@ -943,7 +951,7 @@ osg::Node* createModel(osg::ref_ptr& image_3d, osg::ref_ptrgetPixelFormat()==GL_RGB || image_3d->getPixelFormat()==GL_RGBA); @@ -1022,6 +1030,12 @@ osg::Node* createModel(osg::ref_ptr& image_3d, osg::ref_ptrsetDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); stateset->setAttributeAndModes(material); + if (maximumIntensityProjection) + { + stateset->setAttribute(new osg::BlendFunc(osg::BlendFunc::ONE, osg::BlendFunc::ONE)); + stateset->setAttribute(new osg::BlendEquation(osg::BlendEquation::RGBA_MAX)); + } + osg::Vec3 lightDirection(1.0f,-1.0f,1.0f); lightDirection.normalize(); @@ -1434,6 +1448,7 @@ int main( int argc, char **argv ) arguments.getApplicationUsage()->addCommandLineOption("-s ","Number of slices to create."); arguments.getApplicationUsage()->addCommandLineOption("--images [filenames]","Specify a stack of 2d images to build the 3d volume from."); arguments.getApplicationUsage()->addCommandLineOption("--shader","Use OpenGL Shading Language."); + arguments.getApplicationUsage()->addCommandLineOption("--mip","Use Maximum Intensity Projection (MIP) filtering."); arguments.getApplicationUsage()->addCommandLineOption("--xSize ","Relative width of rendered brick."); arguments.getApplicationUsage()->addCommandLineOption("--ySize ","Relative length of rendered brick."); arguments.getApplicationUsage()->addCommandLineOption("--zSize ","Relative height of rendered brick."); @@ -1482,6 +1497,9 @@ int main( int argc, char **argv ) bool createNormalMap = false; while (arguments.read("-n")) createNormalMap=true; + + bool maximumIntensityProjection = false; + while(arguments.read("--mip")) maximumIntensityProjection = true; float xSize=1.0f, ySize=1.0f, zSize=1.0f; while (arguments.read("--xSize",xSize)) {} @@ -1598,7 +1616,7 @@ int main( int argc, char **argv ) internalFormatMode, xSize, ySize, zSize, xMultiplier, yMultiplier, zMultiplier, - numSlices, sliceEnd, alphaFunc); + numSlices, sliceEnd, alphaFunc, maximumIntensityProjection); } else { @@ -1606,7 +1624,7 @@ int main( int argc, char **argv ) internalFormatMode, xSize, ySize, zSize, xMultiplier, yMultiplier, zMultiplier, - numSlices, sliceEnd, alphaFunc); + numSlices, sliceEnd, alphaFunc, maximumIntensityProjection); } if (!outputFile.empty())