Show
Ignore:
Timestamp:
08/18/08 17:08:04 (6 years ago)
Author:
robert
Message:

Added --mip command line option which enables Maximum Intensity Projection filtering

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp

    r7892 r8777  
    3333#include <osg/PrimitiveSet> 
    3434#include <osg/Endian> 
     35#include <osg/BlendFunc> 
     36#include <osg/BlendEquation> 
    3537 
    3638#include <osgDB/Registry> 
     
    746748                       float /*xSize*/, float /*ySize*/, float /*zSize*/, 
    747749                       float /*xMultiplier*/, float /*yMultiplier*/, float /*zMultiplier*/, 
    748                        unsigned int /*numSlices*/=500, float /*sliceEnd*/=1.0f, float alphaFuncValue=0.02f) 
     750                       unsigned int /*numSlices*/=500, float /*sliceEnd*/=1.0f, float alphaFuncValue=0.02f, bool maximumIntensityProjection = false) 
    749751{ 
    750752    osg::Geode* geode = new osg::Geode; 
     
    864866    stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON); 
    865867 
     868    if (maximumIntensityProjection) 
     869    { 
     870        stateset->setAttribute(new osg::BlendFunc(osg::BlendFunc::ONE, osg::BlendFunc::ONE)); 
     871        stateset->setAttribute(new osg::BlendEquation(osg::BlendEquation::RGBA_MAX)); 
     872    } 
     873 
    866874    { 
    867875        osg::Geometry* geom = new osg::Geometry; 
     
    944952                       float xSize, float ySize, float zSize, 
    945953                       float xMultiplier, float yMultiplier, float zMultiplier, 
    946                        unsigned int numSlices=500, float sliceEnd=1.0f, float alphaFuncValue=0.02f) 
     954                       unsigned int numSlices=500, float sliceEnd=1.0f, float alphaFuncValue=0.02f, bool maximumIntensityProjection = false) 
    947955{ 
    948956    bool two_pass = normalmap_3d.valid() && (image_3d->getPixelFormat()==GL_RGB || image_3d->getPixelFormat()==GL_RGBA); 
     
    10221030    material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); 
    10231031    stateset->setAttributeAndModes(material); 
     1032     
     1033    if (maximumIntensityProjection) 
     1034    { 
     1035        stateset->setAttribute(new osg::BlendFunc(osg::BlendFunc::ONE, osg::BlendFunc::ONE)); 
     1036        stateset->setAttribute(new osg::BlendEquation(osg::BlendEquation::RGBA_MAX)); 
     1037    } 
    10241038     
    10251039    osg::Vec3 lightDirection(1.0f,-1.0f,1.0f); 
     
    14351449    arguments.getApplicationUsage()->addCommandLineOption("--images [filenames]","Specify a stack of 2d images to build the 3d volume from."); 
    14361450    arguments.getApplicationUsage()->addCommandLineOption("--shader","Use OpenGL Shading Language."); 
     1451    arguments.getApplicationUsage()->addCommandLineOption("--mip","Use Maximum Intensity Projection (MIP) filtering."); 
    14371452    arguments.getApplicationUsage()->addCommandLineOption("--xSize <size>","Relative width of rendered brick."); 
    14381453    arguments.getApplicationUsage()->addCommandLineOption("--ySize <size>","Relative length of rendered brick."); 
     
    14831498    bool createNormalMap = false; 
    14841499    while (arguments.read("-n")) createNormalMap=true; 
     1500     
     1501    bool maximumIntensityProjection = false; 
     1502    while(arguments.read("--mip")) maximumIntensityProjection = true; 
    14851503 
    14861504    float xSize=1.0f, ySize=1.0f, zSize=1.0f; 
     
    15991617                               xSize, ySize, zSize, 
    16001618                               xMultiplier, yMultiplier, zMultiplier, 
    1601                                numSlices, sliceEnd, alphaFunc); 
     1619                               numSlices, sliceEnd, alphaFunc, maximumIntensityProjection); 
    16021620    } 
    16031621    else 
     
    16071625                               xSize, ySize, zSize, 
    16081626                               xMultiplier, yMultiplier, zMultiplier, 
    1609                                numSlices, sliceEnd, alphaFunc); 
     1627                               numSlices, sliceEnd, alphaFunc, maximumIntensityProjection); 
    16101628    } 
    16111629