Changed osgvolume example to use the new tf plugin rather than having local code for reading transfer function

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14450 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-09-16 17:40:13 +00:00
parent f3ba656303
commit acbad2424e
3 changed files with 68 additions and 173 deletions

View File

@@ -301,44 +301,6 @@ osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent
}
osg::TransferFunction1D* readTransferFunctionFile(const std::string& filename, float colorScale=1.0f)
{
std::string foundFile = osgDB::findDataFile(filename);
if (foundFile.empty())
{
std::cout<<"Error: could not find transfer function file : "<<filename<<std::endl;
return 0;
}
std::cout<<"Reading transfer function "<<filename<<std::endl;
osg::TransferFunction1D::ColorMap colorMap;
osgDB::ifstream fin(foundFile.c_str());
while(fin)
{
float value, red, green, blue, alpha;
fin >> value >> red >> green >> blue >> alpha;
if (fin)
{
std::cout<<"value = "<<value<<" ("<<red<<", "<<green<<", "<<blue<<", "<<alpha<<")"<<std::endl;
colorMap[value] = osg::Vec4(red*colorScale,green*colorScale,blue*colorScale,alpha*colorScale);
}
}
if (colorMap.empty())
{
std::cout<<"Error: No values read from transfer function file: "<<filename<<std::endl;
return 0;
}
osg::TransferFunction1D* tf = new osg::TransferFunction1D;
tf->assign(colorMap);
return tf;
}
class TestSupportOperation: public osg::GraphicsOperation
{
public:
@@ -512,11 +474,7 @@ int main( int argc, char **argv )
std::string tranferFunctionFile;
while (arguments.read("--tf",tranferFunctionFile))
{
transferFunction = readTransferFunctionFile(tranferFunctionFile);
}
while (arguments.read("--tf-255",tranferFunctionFile))
{
transferFunction = readTransferFunctionFile(tranferFunctionFile,1.0f/255.0f);
transferFunction = osgDB::readFile<osg::TransferFunction1D>(tranferFunctionFile);
}
while(arguments.read("--test"))