Show
Ignore:
Timestamp:
02/02/09 15:43:27 (6 years ago)
Author:
robert
Message:

Refactored osg::TransferFunction?1D to use an std::map internally which is kept in sync with the actual osg::Image that is passed to the GPU.

Added .osg support for osg::TransferFunction?1D.

Updated wrappers

Files:
1 modified

Legend:

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

    r9613 r9618  
    717717    std::cout<<"Reading transfer function "<<filename<<std::endl; 
    718718 
    719     osg::TransferFunction1D::ValueMap valueMap; 
     719    osg::TransferFunction1D::ColorMap colorMap; 
    720720    osgDB::ifstream fin(foundFile.c_str()); 
    721721    while(fin) 
     
    726726        { 
    727727            std::cout<<"value = "<<value<<" ("<<red<<", "<<green<<", "<<blue<<", "<<alpha<<")"<<std::endl; 
    728             valueMap[value] = osg::Vec4(red,green,blue,alpha); 
    729         } 
    730     } 
    731      
    732     if (valueMap.empty()) 
     728            colorMap[value] = osg::Vec4(red,green,blue,alpha); 
     729        } 
     730    } 
     731     
     732    if (colorMap.empty()) 
    733733    { 
    734734        std::cout<<"Error: No values read from transfer function file: "<<filename<<std::endl; 
     
    737737     
    738738    osg::TransferFunction1D* tf = new osg::TransferFunction1D; 
    739     tf->assign(valueMap, true); 
     739    tf->assign(colorMap); 
    740740     
    741741    return tf; 
     
    852852        transferFunction = readTransferFunctionFile(tranferFunctionFile); 
    853853    } 
     854     
     855    while(arguments.read("--test")) 
     856    { 
     857        transferFunction = new osg::TransferFunction1D; 
     858        transferFunction->setColor(0.0, osg::Vec4(1.0,0.0,0.0,0.0)); 
     859        transferFunction->setColor(0.5, osg::Vec4(1.0,1.0,0.0,0.5)); 
     860        transferFunction->setColor(1.0, osg::Vec4(0.0,0.0,1.0,1.0)); 
     861    } 
     862 
     863    while(arguments.read("--test2")) 
     864    { 
     865        transferFunction = new osg::TransferFunction1D; 
     866        transferFunction->setColor(0.0, osg::Vec4(1.0,0.0,0.0,0.0)); 
     867        transferFunction->setColor(0.5, osg::Vec4(1.0,1.0,0.0,0.5)); 
     868        transferFunction->setColor(1.0, osg::Vec4(0.0,0.0,1.0,1.0)); 
     869        transferFunction->assign(transferFunction->getColorMap()); 
     870    } 
    854871 
    855872    unsigned int numSlices=500; 
     
    976993            if (fin) 
    977994            { 
    978                 osg::TransferFunction1D::ValueMap valueMap; 
     995                osg::TransferFunction1D::ColorMap colorMap; 
    979996                float value = 0.0; 
    980997                while(fin && value<=1.0) 
     
    9841001                    if (fin)  
    9851002                    { 
    986                         valueMap[value] = osg::Vec4(red/255.0f,green/255.0f,blue/255.0f,alpha/255.0f); 
     1003                        colorMap[value] = osg::Vec4(red/255.0f,green/255.0f,blue/255.0f,alpha/255.0f); 
    9871004                        std::cout<<"value = "<<value<<" ("<<red<<", "<<green<<", "<<blue<<", "<<alpha<<")"; 
    988                         std::cout<<"  ("<<valueMap[value]<<")"<<std::endl; 
     1005                        std::cout<<"  ("<<colorMap[value]<<")"<<std::endl; 
    9891006                    } 
    9901007                    value += 1/255.0; 
    9911008                } 
    9921009 
    993                 if (valueMap.empty()) 
     1010                if (colorMap.empty()) 
    9941011                { 
    9951012                    std::cout<<"Error: No values read from transfer function file: "<<transfer_filename<<std::endl; 
     
    9981015 
    9991016                transferFunction = new osg::TransferFunction1D; 
    1000                 transferFunction->assign(valueMap, true); 
     1017                transferFunction->assign(colorMap); 
    10011018            } 
    10021019        }