Changeset 61


Ignore:
Timestamp:
Dec 14, 2004, 10:26:37 PM (20 years ago)
Author:
darran
Message:
  • Added AlphaFunc? for threshold (-alphamin <float>) culling of pixels
  • Prettified Ole's source code modifications to swwreader ;-)
Location:
Swollen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Swollen/include/swwreader.h

    r53 r61  
    149149    std::vector<triangle_list> _connectivity;
    150150
    151     // alpha based culling
     151    // define alpha (transparency) function
    152152    float _alphamax, _alphamin, _heightmax, _heightmin;
    153153
  • Swollen/swollen/watersurface.cpp

    r60 r61  
    5656    _stateset->setAttribute(osgBlendFunc);
    5757    _stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
     58    _stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
    5859
     60    // discard pixels with an alpha value below threshold
    5961    osg::AlphaFunc* alphaFunc = new osg::AlphaFunc;
    60    
    61     //Commented out by OMN
    62     //alphaFunc->setFunction( osg::AlphaFunc::GEQUAL, _sww->getAlphaThreshold() );
    63     //_stateset->setAttributeAndModes( alphaFunc, osg::StateAttribute::ON );
    64    
    65     _stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
     62    alphaFunc->setFunction( osg::AlphaFunc::GREATER, _sww->getAlphaMin() );
     63    _stateset->setAttributeAndModes( alphaFunc, osg::StateAttribute::ON );
    6664
    6765    // automatically generate texture coords
  • Swollen/swwreader/swwreader.cpp

    r60 r61  
    292292    for (iv=0; iv < _npoints; iv++)
    293293    {
    294         height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z();
     294        height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z();
    295295       
    296         if (height < _heightmin) {
    297           alpha = 0.0;
    298         } else {
    299           alpha = alphascale*(height - _heightmin) + _alphamin;
    300           if( alpha > _alphamax ) alpha = _alphamax;     
     296        if (height < _heightmin)
     297        {
     298            alpha = 0.0;
     299        }
     300        else
     301        {
     302            alpha = alphascale * (height - _heightmin) + _alphamin;
     303            if( alpha > _alphamax )
     304                alpha = _alphamax;       
    301305        }
    302         _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) );
     306        _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) );
    303307    }
    304308
Note: See TracChangeset for help on using the changeset viewer.